larkcc 0.12.0 → 0.12.2

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/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.12.1] - 2026-05-09
11
+
12
+ ### Added
13
+
14
+ - Tool result collapsible panels in CardKit mode: each tool call is shown as a collapsed panel with result preview in the final card
15
+ - Format tool result content by type: Read results use language-tagged code blocks (auto-detected from file extension), Bash results use bash code blocks
16
+ - Increase tool result truncation threshold from 500 to 2000 characters
17
+
18
+ ### Fixed
19
+
20
+ - Fix `collapsible_panel` field: `background_style` → `background_color` (align with official Feishu card JSON v2 spec)
21
+
10
22
  ## [0.12.0] - 2026-05-09
11
23
 
12
24
  ### Changed
package/dist/index.js CHANGED
@@ -136876,7 +136876,7 @@ function buildThinkingPanel(options) {
136876
136876
  {
136877
136877
  tag: "collapsible_panel",
136878
136878
  expanded: false,
136879
- background_style: "wathet",
136879
+ background_color: "wathet",
136880
136880
  header: {
136881
136881
  title: {
136882
136882
  tag: "markdown",
@@ -136909,12 +136909,105 @@ function buildThinkingPanel(options) {
136909
136909
  { tag: "hr" }
136910
136910
  ];
136911
136911
  }
136912
- var THINKING_OVERFLOW_TRUNCATE;
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;
136913
136965
  var init_duration = __esm({
136914
136966
  "src/format/duration.ts"() {
136915
136967
  "use strict";
136916
136968
  init_card_optimize();
136917
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
+ };
136918
137011
  }
136919
137012
  });
136920
137013
 
@@ -137501,7 +137594,7 @@ async function updateToolCard(client, msgId, label, detail, resultPreview) {
137501
137594
  elements.push({
137502
137595
  tag: "collapsible_panel",
137503
137596
  expanded: false,
137504
- background_style: "grey",
137597
+ background_color: "grey",
137505
137598
  header: {
137506
137599
  title: {
137507
137600
  tag: "plain_text",
@@ -137840,7 +137933,7 @@ var VERSION3;
137840
137933
  var init_version = __esm({
137841
137934
  "src/version.ts"() {
137842
137935
  "use strict";
137843
- VERSION3 = "0.12.0";
137936
+ VERSION3 = "0.12.2";
137844
137937
  }
137845
137938
  });
137846
137939
 
@@ -155022,7 +155115,10 @@ var init_cardkit = __esm({
155022
155115
  return;
155023
155116
  }
155024
155117
  const optimized = optimizeForCard(content);
155025
- const extraElements = this.buildThinkingElements(options?.thinking, options?.reasoningElapsedMs);
155118
+ const extraElements = [
155119
+ ...this.buildThinkingElements(options?.thinking, options?.reasoningElapsedMs),
155120
+ ...buildToolPanels(options?.toolResults ?? [])
155121
+ ];
155026
155122
  try {
155027
155123
  const finalCardJson = this.buildFinalCard(optimized, extraElements, options?.stats);
155028
155124
  await this.closeAndFinalize(finalCardJson);
@@ -155248,7 +155344,10 @@ ${displayContent}`;
155248
155344
  let cardContent = `\u{1F4DD} \u5185\u5BB9\u8F83\u957F\uFF0C\u5DF2\u5199\u5165\u4E91\u6587\u6863\uFF1A[${title}](${docUrl})`;
155249
155345
  const cleanupConfig = this.context.overflow.document.cleanup;
155250
155346
  await cleanupOldDocuments(token, cleanupConfig.max_docs, this.context.profile);
155251
- const extraElements = this.buildThinkingElements(options?.thinking, options?.reasoningElapsedMs);
155347
+ const extraElements = [
155348
+ ...this.buildThinkingElements(options?.thinking, options?.reasoningElapsedMs),
155349
+ ...buildToolPanels(options?.toolResults ?? [])
155350
+ ];
155252
155351
  const finalCardJson = this.buildFinalCard(cardContent, extraElements, options?.stats);
155253
155352
  await this.closeAndFinalize(finalCardJson);
155254
155353
  } catch (error) {
@@ -155546,6 +155645,7 @@ async function runAgent(prompt2, cwd2, config2, client, chatId, rootMsgId, image
155546
155645
  let reasoningStartTime = null;
155547
155646
  let toolCallCount = 0;
155548
155647
  const toolMsgMap = /* @__PURE__ */ new Map();
155648
+ const cardkitToolResults = [];
155549
155649
  const replyContext = buildReplyContext(config2, profile2, cwd2, chatId, rootMsgId);
155550
155650
  const isCardkitMode = config2.streaming?.mode === "cardkit";
155551
155651
  let cardkitCtrl = null;
@@ -155648,6 +155748,7 @@ async function runAgent(prompt2, cwd2, config2, client, chatId, rootMsgId, image
155648
155748
  const detail2 = formatInput(block.name, block.input ?? {});
155649
155749
  logger.tool(block.name, detail2);
155650
155750
  await cardkitCtrl?.updateStatus(`<text_tag color='orange'>${label2}</text_tag> \`${detail2}\``);
155751
+ cardkitToolResults.push({ id: block.id, name: block.name, label: label2, detail: detail2 });
155651
155752
  break;
155652
155753
  }
155653
155754
  if (SILENT_TOOLS.has(block.name)) break;
@@ -155671,6 +155772,9 @@ async function runAgent(prompt2, cwd2, config2, client, chatId, rootMsgId, image
155671
155772
  if (block.type === "tool_result" && block.tool_use_id) {
155672
155773
  if (isCardkitMode) {
155673
155774
  await cardkitCtrl?.clearStatus();
155775
+ const raw = typeof block.content === "string" ? block.content : JSON.stringify(block.content ?? "");
155776
+ const toolEntry = cardkitToolResults.find((t) => t.id === block.tool_use_id);
155777
+ if (toolEntry) toolEntry.resultPreview = truncate(raw, 500);
155674
155778
  break;
155675
155779
  }
155676
155780
  const toolInfo = toolMsgMap.get(block.tool_use_id);
@@ -155766,7 +155870,8 @@ async function runAgent(prompt2, cwd2, config2, client, chatId, rootMsgId, image
155766
155870
  duration: elapsedSeconds,
155767
155871
  toolCount: toolCallCount
155768
155872
  },
155769
- headerIconImgKey: config2.header_icon_img_key
155873
+ headerIconImgKey: config2.header_icon_img_key,
155874
+ toolResults: cardkitToolResults.filter((t) => t.resultPreview !== void 0).map(({ name, label, detail, resultPreview }) => ({ toolName: name, label, detail, resultPreview }))
155770
155875
  };
155771
155876
  if (cardkitCtrl) {
155772
155877
  await cardkitCtrl.complete(finalContent, completeOptions);