opencode-feishu 1.3.2 → 1.3.3

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
@@ -112767,55 +112767,6 @@ async function sendCardMessage(client, chatId, cardId) {
112767
112767
  );
112768
112768
  }
112769
112769
 
112770
- // src/feishu/markdown.ts
112771
- var MAX_CARD_BYTES = 28 * 1024;
112772
- var TRUNCATION_SUFFIX = "\n\n*\u5185\u5BB9\u8FC7\u957F\uFF0C\u5DF2\u622A\u65AD*";
112773
- var TRUNCATION_SUFFIX_BYTES = new TextEncoder().encode(TRUNCATION_SUFFIX).length;
112774
- var CODE_FENCE_BYTES = 4;
112775
- var HTML_TAG_RE = /<\/?\w+(?:\s[^>]*)?\/?>/g;
112776
- function cleanMarkdown(text) {
112777
- let result = text.replace(/<br\s*\/?>/gi, "\n");
112778
- const { segments, codeBlocks } = extractCodeBlocks(result);
112779
- result = segments.map((seg) => seg.replace(HTML_TAG_RE, "")).join("\0");
112780
- let idx = 0;
112781
- result = result.replace(/\0/g, () => codeBlocks[idx++] ?? "");
112782
- result = closeCodeBlocks(result);
112783
- return result;
112784
- }
112785
- function truncateMarkdown(text, limit = MAX_CARD_BYTES) {
112786
- const bytes = new TextEncoder().encode(text);
112787
- if (bytes.length <= limit) return text;
112788
- const effectiveLimit = limit - TRUNCATION_SUFFIX_BYTES - CODE_FENCE_BYTES;
112789
- if (effectiveLimit <= 0) return TRUNCATION_SUFFIX;
112790
- const truncated = new TextDecoder().decode(bytes.slice(0, effectiveLimit));
112791
- const lastNewline = truncated.lastIndexOf("\n");
112792
- const cutPoint = lastNewline > effectiveLimit * 0.8 ? lastNewline : truncated.length;
112793
- let result = truncated.slice(0, cutPoint);
112794
- result = closeCodeBlocks(result);
112795
- return result + TRUNCATION_SUFFIX;
112796
- }
112797
- function extractCodeBlocks(text) {
112798
- const segments = [];
112799
- const codeBlocks = [];
112800
- const re = /```[\s\S]*?```/g;
112801
- let lastIndex = 0;
112802
- let match;
112803
- while ((match = re.exec(text)) !== null) {
112804
- segments.push(text.slice(lastIndex, match.index));
112805
- codeBlocks.push(match[0]);
112806
- lastIndex = match.index + match[0].length;
112807
- }
112808
- segments.push(text.slice(lastIndex));
112809
- return { segments, codeBlocks };
112810
- }
112811
- function closeCodeBlocks(text) {
112812
- const matches = text.match(/```/g);
112813
- if (matches && matches.length % 2 !== 0) {
112814
- return text + "\n```";
112815
- }
112816
- return text;
112817
- }
112818
-
112819
112770
  // src/tools/send-card.ts
112820
112771
  var z2 = tool.schema;
112821
112772
  var TEMPLATE_COLORS = ["blue", "green", "orange", "red", "purple", "grey"];
@@ -112849,7 +112800,7 @@ function createSendCardTool(deps) {
112849
112800
  return "\u9519\u8BEF\uFF1A\u5F53\u524D\u4F1A\u8BDD\u4E0D\u5173\u8054\u98DE\u4E66\u804A\u5929\uFF0C\u65E0\u6CD5\u53D1\u9001\u5361\u7247";
112850
112801
  }
112851
112802
  const chatInfo = getChatInfoBySession(context.sessionID);
112852
- const card = buildCardFromDSL(args, chatId, chatInfo?.chatType ?? "p2p");
112803
+ const card = { type: "card_kit", data: buildCardFromDSL(args, chatId, chatInfo?.chatType ?? "p2p") };
112853
112804
  const result = await sendInteractiveCard(deps.feishuClient, chatId, card);
112854
112805
  if (result.ok) {
112855
112806
  deps.log("info", "Agent \u5361\u7247\u5DF2\u53D1\u9001", {
@@ -112908,7 +112859,7 @@ function buildCardFromDSL(args, chatId, chatType) {
112908
112859
  default:
112909
112860
  return {
112910
112861
  tag: "markdown",
112911
- content: truncateMarkdown(s.content ?? "", 28e3)
112862
+ content: s.content ?? ""
112912
112863
  };
112913
112864
  }
112914
112865
  }).filter(Boolean)
@@ -113931,6 +113882,55 @@ async function getOrCreateSession(client, sessionKey, directory) {
113931
113882
  return session;
113932
113883
  }
113933
113884
 
113885
+ // src/feishu/markdown.ts
113886
+ var MAX_CARD_BYTES = 28 * 1024;
113887
+ var TRUNCATION_SUFFIX = "\n\n*\u5185\u5BB9\u8FC7\u957F\uFF0C\u5DF2\u622A\u65AD*";
113888
+ var TRUNCATION_SUFFIX_BYTES = new TextEncoder().encode(TRUNCATION_SUFFIX).length;
113889
+ var CODE_FENCE_BYTES = 4;
113890
+ var HTML_TAG_RE = /<\/?\w+(?:\s[^>]*)?\/?>/g;
113891
+ function cleanMarkdown(text) {
113892
+ let result = text.replace(/<br\s*\/?>/gi, "\n");
113893
+ const { segments, codeBlocks } = extractCodeBlocks(result);
113894
+ result = segments.map((seg) => seg.replace(HTML_TAG_RE, "")).join("\0");
113895
+ let idx = 0;
113896
+ result = result.replace(/\0/g, () => codeBlocks[idx++] ?? "");
113897
+ result = closeCodeBlocks(result);
113898
+ return result;
113899
+ }
113900
+ function truncateMarkdown(text, limit = MAX_CARD_BYTES) {
113901
+ const bytes = new TextEncoder().encode(text);
113902
+ if (bytes.length <= limit) return text;
113903
+ const effectiveLimit = limit - TRUNCATION_SUFFIX_BYTES - CODE_FENCE_BYTES;
113904
+ if (effectiveLimit <= 0) return TRUNCATION_SUFFIX;
113905
+ const truncated = new TextDecoder().decode(bytes.slice(0, effectiveLimit));
113906
+ const lastNewline = truncated.lastIndexOf("\n");
113907
+ const cutPoint = lastNewline > effectiveLimit * 0.8 ? lastNewline : truncated.length;
113908
+ let result = truncated.slice(0, cutPoint);
113909
+ result = closeCodeBlocks(result);
113910
+ return result + TRUNCATION_SUFFIX;
113911
+ }
113912
+ function extractCodeBlocks(text) {
113913
+ const segments = [];
113914
+ const codeBlocks = [];
113915
+ const re = /```[\s\S]*?```/g;
113916
+ let lastIndex = 0;
113917
+ let match;
113918
+ while ((match = re.exec(text)) !== null) {
113919
+ segments.push(text.slice(lastIndex, match.index));
113920
+ codeBlocks.push(match[0]);
113921
+ lastIndex = match.index + match[0].length;
113922
+ }
113923
+ segments.push(text.slice(lastIndex));
113924
+ return { segments, codeBlocks };
113925
+ }
113926
+ function closeCodeBlocks(text) {
113927
+ const matches = text.match(/```/g);
113928
+ if (matches && matches.length % 2 !== 0) {
113929
+ return text + "\n```";
113930
+ }
113931
+ return text;
113932
+ }
113933
+
113934
113934
  // src/feishu/streaming-card.ts
113935
113935
  var StreamingCard = class {
113936
113936
  constructor(cardkit, feishuClient, chatId, log) {