codex-to-im 1.0.52 → 1.0.53

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/daemon.mjs CHANGED
@@ -1237,6 +1237,11 @@ function buildPostContent(text2) {
1237
1237
  function htmlToFeishuMarkdown(html) {
1238
1238
  return html.replace(/<b>(.*?)<\/b>/gi, "**$1**").replace(/<strong>(.*?)<\/strong>/gi, "**$1**").replace(/<i>(.*?)<\/i>/gi, "*$1*").replace(/<em>(.*?)<\/em>/gi, "*$1*").replace(/<code>(.*?)<\/code>/gi, "`$1`").replace(/<br\s*\/?>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<[^>]+>/g, "").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/\n{3,}/g, "\n\n").trim();
1239
1239
  }
1240
+ function buildFinalCardSummary(terminalStatus, footer) {
1241
+ const label = terminalStatus === "error" ? "\u6267\u884C\u5931\u8D25" : terminalStatus === "interrupted" ? "\u5DF2\u4E2D\u65AD" : "\u5DF2\u5B8C\u6210";
1242
+ const elapsed = footer?.elapsed?.trim();
1243
+ return elapsed ? `${label} \xB7 ${elapsed}` : label;
1244
+ }
1240
1245
  function normalizeToolStatusForRender(status, options) {
1241
1246
  if (status !== "running" || !options.terminalStatus) return status;
1242
1247
  return options.terminalStatus === "completed" ? "complete" : "error";
@@ -1360,7 +1365,11 @@ function buildFinalCardJson(text2, tasks, tools, footer, terminalStatus) {
1360
1365
  }
1361
1366
  return JSON.stringify({
1362
1367
  schema: "2.0",
1363
- config: { wide_screen_mode: true },
1368
+ config: {
1369
+ streaming_mode: false,
1370
+ wide_screen_mode: true,
1371
+ summary: { content: buildFinalCardSummary(terminalStatus, footer) }
1372
+ },
1364
1373
  body: { elements }
1365
1374
  });
1366
1375
  }
@@ -1422,9 +1431,24 @@ var CARD_THROTTLE_MS = 1e3;
1422
1431
  var CARD_REQUEST_TIMEOUT_MS = 15e3;
1423
1432
  var CARD_FINALIZE_FLUSH_WAIT_EXTRA_MS = 1e3;
1424
1433
  var CARD_FULL_REFRESH_INTERVAL_MS = 5 * 6e4;
1434
+ var FINAL_CARD_FULL_TEXT_MAX_CHARS = 12e3;
1435
+ var FINAL_CARD_PREVIEW_CHARS = 4e3;
1425
1436
  var INITIAL_STREAMING_STATUS = "\u5904\u7406\u4E2D";
1426
1437
  var EMPTY_STREAMING_TASKS = "";
1427
1438
  var EMPTY_STREAMING_TOOLS = "";
1439
+ function shouldDeliverFinalTextSeparately(text2) {
1440
+ return text2.trim().length > FINAL_CARD_FULL_TEXT_MAX_CHARS;
1441
+ }
1442
+ function buildFinalCardTextPreview(text2) {
1443
+ const trimmed = text2.trim();
1444
+ if (!trimmed) return "";
1445
+ const preview = trimmed.slice(0, FINAL_CARD_PREVIEW_CHARS).trimEnd();
1446
+ return `${preview}
1447
+
1448
+ ---
1449
+
1450
+ \u56DE\u590D\u8F83\u957F\uFF0C\u5B8C\u6574\u5185\u5BB9\u5C06\u7EE7\u7EED\u4EE5\u666E\u901A\u6D88\u606F\u53D1\u9001\u3002`;
1451
+ }
1428
1452
  function buildStreamingCardBody(content, tasksText, toolsText, statusText) {
1429
1453
  return {
1430
1454
  schema: "2.0",
@@ -1997,7 +2021,9 @@ var FeishuAdapter = class extends BaseChannelAdapter {
1997
2021
 
1998
2022
  ${trimmedResponse}`;
1999
2023
  }
2000
- const finalCardJson = buildFinalCardJson(finalText, state.taskItems, state.toolCalls, footer, status);
2024
+ const deliverTextSeparately = shouldDeliverFinalTextSeparately(finalText);
2025
+ const cardText = deliverTextSeparately ? buildFinalCardTextPreview(finalText) : finalText;
2026
+ const finalCardJson = buildFinalCardJson(cardText, state.taskItems, state.toolCalls, footer, status);
2001
2027
  state.sequence++;
2002
2028
  await this.withFeishuRequestTimeout(cardKey, "card.update", () => cardkit.card.update({
2003
2029
  path: { card_id: state.cardId },
@@ -2013,7 +2039,7 @@ ${trimmedResponse}`;
2013
2039
  await this.waitBeforeTerminalReaction();
2014
2040
  await this.addTerminalReaction(cardKey, state.messageId, terminalReactionEmoji);
2015
2041
  }
2016
- return true;
2042
+ return !deliverTextSeparately;
2017
2043
  } catch (err) {
2018
2044
  console.warn("[feishu-adapter] Card finalize failed:", err instanceof Error ? err.message : err);
2019
2045
  return false;
@@ -3352,6 +3378,7 @@ function clearAllPauses() {
3352
3378
  var utils_exports = {};
3353
3379
  __export(utils_exports, {
3354
3380
  arrayReplaceAt: () => arrayReplaceAt,
3381
+ asciiTrim: () => asciiTrim,
3355
3382
  assign: () => assign,
3356
3383
  escapeHtml: () => escapeHtml,
3357
3384
  escapeRE: () => escapeRE,
@@ -3359,6 +3386,7 @@ __export(utils_exports, {
3359
3386
  has: () => has,
3360
3387
  isMdAsciiPunct: () => isMdAsciiPunct,
3361
3388
  isPunctChar: () => isPunctChar,
3389
+ isPunctCharCode: () => isPunctCharCode,
3362
3390
  isSpace: () => isSpace,
3363
3391
  isString: () => isString,
3364
3392
  isValidEntityCode: () => isValidEntityCode,
@@ -4186,6 +4214,9 @@ var xmlDecoder = getDecoder(decode_data_xml_default);
4186
4214
  function decodeHTML(str, mode = DecodingMode.Legacy) {
4187
4215
  return htmlDecoder(str, mode);
4188
4216
  }
4217
+ function decodeHTMLStrict(str) {
4218
+ return htmlDecoder(str, DecodingMode.Strict);
4219
+ }
4189
4220
 
4190
4221
  // node_modules/entities/lib/esm/generated/encode-html.js
4191
4222
  function restoreDiff(arr) {
@@ -4411,6 +4442,9 @@ function isWhiteSpace(code2) {
4411
4442
  function isPunctChar(ch) {
4412
4443
  return regex_default4.test(ch) || regex_default5.test(ch);
4413
4444
  }
4445
+ function isPunctCharCode(code2) {
4446
+ return isPunctChar(fromCodePoint2(code2));
4447
+ }
4414
4448
  function isMdAsciiPunct(ch) {
4415
4449
  switch (ch) {
4416
4450
  case 33:
@@ -4457,6 +4491,24 @@ function normalizeReference(str) {
4457
4491
  }
4458
4492
  return str.toLowerCase().toUpperCase();
4459
4493
  }
4494
+ function isAsciiTrimmable(c) {
4495
+ return c === 32 || c === 9 || c === 10 || c === 13;
4496
+ }
4497
+ function asciiTrim(str) {
4498
+ let start2 = 0;
4499
+ for (; start2 < str.length; start2++) {
4500
+ if (!isAsciiTrimmable(str.charCodeAt(start2))) {
4501
+ break;
4502
+ }
4503
+ }
4504
+ let end = str.length - 1;
4505
+ for (; end >= start2; end--) {
4506
+ if (!isAsciiTrimmable(str.charCodeAt(end))) {
4507
+ break;
4508
+ }
4509
+ }
4510
+ return str.slice(start2, end + 1);
4511
+ }
4460
4512
  var lib = { mdurl: mdurl_exports, ucmicro: uc_exports };
4461
4513
 
4462
4514
  // node_modules/markdown-it/lib/helpers/index.mjs
@@ -5209,12 +5261,27 @@ function replace(state) {
5209
5261
  var QUOTE_TEST_RE = /['"]/;
5210
5262
  var QUOTE_RE = /['"]/g;
5211
5263
  var APOSTROPHE = "\u2019";
5212
- function replaceAt(str, index, ch) {
5213
- return str.slice(0, index) + ch + str.slice(index + 1);
5264
+ function addReplacement(replacements, tokenIdx, pos, ch) {
5265
+ if (!replacements[tokenIdx]) {
5266
+ replacements[tokenIdx] = [];
5267
+ }
5268
+ replacements[tokenIdx].push({ pos, ch });
5269
+ }
5270
+ function applyReplacements(str, replacements) {
5271
+ let result = "";
5272
+ let lastPos = 0;
5273
+ replacements.sort((a, b) => a.pos - b.pos);
5274
+ for (let i = 0; i < replacements.length; i++) {
5275
+ const replacement = replacements[i];
5276
+ result += str.slice(lastPos, replacement.pos) + replacement.ch;
5277
+ lastPos = replacement.pos + 1;
5278
+ }
5279
+ return result + str.slice(lastPos);
5214
5280
  }
5215
5281
  function process_inlines(tokens, state) {
5216
5282
  let j;
5217
5283
  const stack = [];
5284
+ const replacements = {};
5218
5285
  for (let i = 0; i < tokens.length; i++) {
5219
5286
  const token = tokens[i];
5220
5287
  const thisLevel = tokens[i].level;
@@ -5227,9 +5294,9 @@ function process_inlines(tokens, state) {
5227
5294
  if (token.type !== "text") {
5228
5295
  continue;
5229
5296
  }
5230
- let text2 = token.content;
5297
+ const text2 = token.content;
5231
5298
  let pos = 0;
5232
- let max = text2.length;
5299
+ const max = text2.length;
5233
5300
  OUTER:
5234
5301
  while (pos < max) {
5235
5302
  QUOTE_RE.lastIndex = pos;
@@ -5263,8 +5330,8 @@ function process_inlines(tokens, state) {
5263
5330
  break;
5264
5331
  }
5265
5332
  }
5266
- const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
5267
- const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
5333
+ const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctCharCode(lastChar);
5334
+ const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctCharCode(nextChar);
5268
5335
  const isLastWhiteSpace = isWhiteSpace(lastChar);
5269
5336
  const isNextWhiteSpace = isWhiteSpace(nextChar);
5270
5337
  if (isNextWhiteSpace) {
@@ -5292,7 +5359,7 @@ function process_inlines(tokens, state) {
5292
5359
  }
5293
5360
  if (!canOpen && !canClose) {
5294
5361
  if (isSingle) {
5295
- token.content = replaceAt(token.content, t.index, APOSTROPHE);
5362
+ addReplacement(replacements, i, t.index, APOSTROPHE);
5296
5363
  }
5297
5364
  continue;
5298
5365
  }
@@ -5313,18 +5380,8 @@ function process_inlines(tokens, state) {
5313
5380
  openQuote = state.md.options.quotes[0];
5314
5381
  closeQuote = state.md.options.quotes[1];
5315
5382
  }
5316
- token.content = replaceAt(token.content, t.index, closeQuote);
5317
- tokens[item.token].content = replaceAt(
5318
- tokens[item.token].content,
5319
- item.pos,
5320
- openQuote
5321
- );
5322
- pos += closeQuote.length - 1;
5323
- if (item.token === i) {
5324
- pos += openQuote.length - 1;
5325
- }
5326
- text2 = token.content;
5327
- max = text2.length;
5383
+ addReplacement(replacements, i, t.index, closeQuote);
5384
+ addReplacement(replacements, item.token, item.pos, openQuote);
5328
5385
  stack.length = j;
5329
5386
  continue OUTER;
5330
5387
  }
@@ -5338,10 +5395,13 @@ function process_inlines(tokens, state) {
5338
5395
  level: thisLevel
5339
5396
  });
5340
5397
  } else if (canClose && isSingle) {
5341
- token.content = replaceAt(token.content, t.index, APOSTROPHE);
5398
+ addReplacement(replacements, i, t.index, APOSTROPHE);
5342
5399
  }
5343
5400
  }
5344
5401
  }
5402
+ Object.keys(replacements).forEach(function(tokenIdx) {
5403
+ tokens[tokenIdx].content = applyReplacements(tokens[tokenIdx].content, replacements[tokenIdx]);
5404
+ });
5345
5405
  }
5346
5406
  function smartquotes(state) {
5347
5407
  if (!state.md.options.typographer) {
@@ -6530,10 +6590,13 @@ function html_block(state, startLine, endLine, silent) {
6530
6590
  return HTML_SEQUENCES[i][2];
6531
6591
  }
6532
6592
  let nextLine = startLine + 1;
6593
+ const endsOnBlankLine = HTML_SEQUENCES[i][1].test("");
6533
6594
  if (!HTML_SEQUENCES[i][1].test(lineText)) {
6534
6595
  for (; nextLine < endLine; nextLine++) {
6535
6596
  if (state.sCount[nextLine] < state.blkIndent) {
6536
- break;
6597
+ if (endsOnBlankLine || !state.isEmpty(nextLine)) {
6598
+ break;
6599
+ }
6537
6600
  }
6538
6601
  pos = state.bMarks[nextLine] + state.tShift[nextLine];
6539
6602
  max = state.eMarks[nextLine];
@@ -6586,7 +6649,7 @@ function heading(state, startLine, endLine, silent) {
6586
6649
  token_o.markup = "########".slice(0, level);
6587
6650
  token_o.map = [startLine, state.line];
6588
6651
  const token_i = state.push("inline", "", 0);
6589
- token_i.content = state.src.slice(pos, max).trim();
6652
+ token_i.content = asciiTrim(state.src.slice(pos, max));
6590
6653
  token_i.map = [startLine, state.line];
6591
6654
  token_i.children = [];
6592
6655
  const token_c = state.push("heading_close", "h" + String(level), -1);
@@ -6639,9 +6702,10 @@ function lheading(state, startLine, endLine) {
6639
6702
  }
6640
6703
  }
6641
6704
  if (!level) {
6705
+ state.parentType = oldParentType;
6642
6706
  return false;
6643
6707
  }
6644
- const content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
6708
+ const content = asciiTrim(state.getLines(startLine, nextLine, state.blkIndent, false));
6645
6709
  state.line = nextLine + 1;
6646
6710
  const token_o = state.push("heading_open", "h" + String(level), 1);
6647
6711
  token_o.markup = String.fromCharCode(marker);
@@ -6680,7 +6744,7 @@ function paragraph(state, startLine, endLine) {
6680
6744
  break;
6681
6745
  }
6682
6746
  }
6683
- const content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
6747
+ const content = asciiTrim(state.getLines(startLine, nextLine, state.blkIndent, false));
6684
6748
  state.line = nextLine;
6685
6749
  const token_o = state.push("paragraph_open", "p", 1);
6686
6750
  token_o.map = [startLine, state.line];
@@ -6819,15 +6883,37 @@ StateInline.prototype.push = function(type, tag, nesting) {
6819
6883
  StateInline.prototype.scanDelims = function(start2, canSplitWord) {
6820
6884
  const max = this.posMax;
6821
6885
  const marker = this.src.charCodeAt(start2);
6822
- const lastChar = start2 > 0 ? this.src.charCodeAt(start2 - 1) : 32;
6886
+ let lastChar;
6887
+ if (start2 === 0) {
6888
+ lastChar = 32;
6889
+ } else if (start2 === 1) {
6890
+ lastChar = this.src.charCodeAt(0);
6891
+ if ((lastChar & 63488) === 55296) {
6892
+ lastChar = 65533;
6893
+ }
6894
+ } else {
6895
+ lastChar = this.src.charCodeAt(start2 - 1);
6896
+ if ((lastChar & 64512) === 56320) {
6897
+ const highSurr = this.src.charCodeAt(start2 - 2);
6898
+ lastChar = (highSurr & 64512) === 55296 ? 65536 + (highSurr - 55296 << 10) + (lastChar - 56320) : 65533;
6899
+ } else if ((lastChar & 64512) === 55296) {
6900
+ lastChar = 65533;
6901
+ }
6902
+ }
6823
6903
  let pos = start2;
6824
6904
  while (pos < max && this.src.charCodeAt(pos) === marker) {
6825
6905
  pos++;
6826
6906
  }
6827
6907
  const count = pos - start2;
6828
- const nextChar = pos < max ? this.src.charCodeAt(pos) : 32;
6829
- const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
6830
- const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
6908
+ let nextChar = pos < max ? this.src.charCodeAt(pos) : 32;
6909
+ if ((nextChar & 64512) === 55296) {
6910
+ const lowSurr = this.src.charCodeAt(pos + 1);
6911
+ nextChar = (lowSurr & 64512) === 56320 ? 65536 + (nextChar - 55296 << 10) + (lowSurr - 56320) : 65533;
6912
+ } else if ((nextChar & 64512) === 56320) {
6913
+ nextChar = 65533;
6914
+ }
6915
+ const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctCharCode(lastChar);
6916
+ const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctCharCode(nextChar);
6831
6917
  const isLastWhiteSpace = isWhiteSpace(lastChar);
6832
6918
  const isNextWhiteSpace = isWhiteSpace(nextChar);
6833
6919
  const left_flanking = !isNextWhiteSpace && (!isNextPunctChar || isLastWhiteSpace || isLastPunctChar);
@@ -7580,7 +7666,7 @@ function entity(state, silent) {
7580
7666
  } else {
7581
7667
  const match2 = state.src.slice(pos).match(NAMED_RE);
7582
7668
  if (match2) {
7583
- const decoded = decodeHTML(match2[0]);
7669
+ const decoded = decodeHTMLStrict(match2[0]);
7584
7670
  if (decoded !== match2[0]) {
7585
7671
  if (!silent) {
7586
7672
  const token = state.push("text_special", "", 0);
@@ -7933,10 +8019,6 @@ var defaultSchemas = {
7933
8019
  };
7934
8020
  var tlds_2ch_src_re = "a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]";
7935
8021
  var tlds_default = "biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|\u0440\u0444".split("|");
7936
- function resetScanCache(self) {
7937
- self.__index__ = -1;
7938
- self.__text_cache__ = "";
7939
- }
7940
8022
  function createValidator(re) {
7941
8023
  return function(text2, pos) {
7942
8024
  const tail = text2.slice(pos);
@@ -7964,8 +8046,11 @@ function compile(self) {
7964
8046
  return tpl.replace("%TLDS%", re.src_tlds);
7965
8047
  }
7966
8048
  re.email_fuzzy = RegExp(untpl(re.tpl_email_fuzzy), "i");
8049
+ re.email_fuzzy_global = RegExp(untpl(re.tpl_email_fuzzy), "ig");
7967
8050
  re.link_fuzzy = RegExp(untpl(re.tpl_link_fuzzy), "i");
8051
+ re.link_fuzzy_global = RegExp(untpl(re.tpl_link_fuzzy), "ig");
7968
8052
  re.link_no_ip_fuzzy = RegExp(untpl(re.tpl_link_no_ip_fuzzy), "i");
8053
+ re.link_no_ip_fuzzy_global = RegExp(untpl(re.tpl_link_no_ip_fuzzy), "ig");
7969
8054
  re.host_fuzzy_test = RegExp(untpl(re.tpl_host_fuzzy_test), "i");
7970
8055
  const aliases = [];
7971
8056
  self.__compiled__ = {};
@@ -8020,23 +8105,15 @@ function compile(self) {
8020
8105
  "(" + self.re.schema_test.source + ")|(" + self.re.host_fuzzy_test.source + ")|@",
8021
8106
  "i"
8022
8107
  );
8023
- resetScanCache(self);
8024
- }
8025
- function Match(self, shift) {
8026
- const start2 = self.__index__;
8027
- const end = self.__last_index__;
8028
- const text2 = self.__text_cache__.slice(start2, end);
8029
- this.schema = self.__schema__.toLowerCase();
8030
- this.index = start2 + shift;
8031
- this.lastIndex = end + shift;
8032
- this.raw = text2;
8033
- this.text = text2;
8034
- this.url = text2;
8035
- }
8036
- function createMatch(self, shift) {
8037
- const match2 = new Match(self, shift);
8038
- self.__compiled__[match2.schema].normalize(match2, self);
8039
- return match2;
8108
+ }
8109
+ function Match(text2, schema, index, lastIndex) {
8110
+ const raw = text2.slice(index, lastIndex);
8111
+ this.schema = schema.toLowerCase();
8112
+ this.index = index;
8113
+ this.lastIndex = lastIndex;
8114
+ this.raw = raw;
8115
+ this.text = raw;
8116
+ this.url = raw;
8040
8117
  }
8041
8118
  function LinkifyIt(schemas, options) {
8042
8119
  if (!(this instanceof LinkifyIt)) {
@@ -8049,10 +8126,6 @@ function LinkifyIt(schemas, options) {
8049
8126
  }
8050
8127
  }
8051
8128
  this.__opts__ = assign2({}, defaultOptions, options);
8052
- this.__index__ = -1;
8053
- this.__last_index__ = -1;
8054
- this.__schema__ = "";
8055
- this.__text_cache__ = "";
8056
8129
  this.__schemas__ = assign2({}, defaultSchemas, schemas);
8057
8130
  this.__compiled__ = {};
8058
8131
  this.__tlds__ = tlds_default;
@@ -8070,55 +8143,34 @@ LinkifyIt.prototype.set = function set(options) {
8070
8143
  return this;
8071
8144
  };
8072
8145
  LinkifyIt.prototype.test = function test(text2) {
8073
- this.__text_cache__ = text2;
8074
- this.__index__ = -1;
8075
8146
  if (!text2.length) {
8076
8147
  return false;
8077
8148
  }
8078
- let m, ml, me, len, shift, next, re, tld_pos, at_pos;
8149
+ let m, re;
8079
8150
  if (this.re.schema_test.test(text2)) {
8080
8151
  re = this.re.schema_search;
8081
8152
  re.lastIndex = 0;
8082
8153
  while ((m = re.exec(text2)) !== null) {
8083
- len = this.testSchemaAt(text2, m[2], re.lastIndex);
8084
- if (len) {
8085
- this.__schema__ = m[2];
8086
- this.__index__ = m.index + m[1].length;
8087
- this.__last_index__ = m.index + m[0].length + len;
8088
- break;
8154
+ if (this.testSchemaAt(text2, m[2], re.lastIndex)) {
8155
+ return true;
8089
8156
  }
8090
8157
  }
8091
8158
  }
8092
8159
  if (this.__opts__.fuzzyLink && this.__compiled__["http:"]) {
8093
- tld_pos = text2.search(this.re.host_fuzzy_test);
8094
- if (tld_pos >= 0) {
8095
- if (this.__index__ < 0 || tld_pos < this.__index__) {
8096
- if ((ml = text2.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy)) !== null) {
8097
- shift = ml.index + ml[1].length;
8098
- if (this.__index__ < 0 || shift < this.__index__) {
8099
- this.__schema__ = "";
8100
- this.__index__ = shift;
8101
- this.__last_index__ = ml.index + ml[0].length;
8102
- }
8103
- }
8160
+ if (text2.search(this.re.host_fuzzy_test) >= 0) {
8161
+ if (text2.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy) !== null) {
8162
+ return true;
8104
8163
  }
8105
8164
  }
8106
8165
  }
8107
8166
  if (this.__opts__.fuzzyEmail && this.__compiled__["mailto:"]) {
8108
- at_pos = text2.indexOf("@");
8109
- if (at_pos >= 0) {
8110
- if ((me = text2.match(this.re.email_fuzzy)) !== null) {
8111
- shift = me.index + me[1].length;
8112
- next = me.index + me[0].length;
8113
- if (this.__index__ < 0 || shift < this.__index__ || shift === this.__index__ && next > this.__last_index__) {
8114
- this.__schema__ = "mailto:";
8115
- this.__index__ = shift;
8116
- this.__last_index__ = next;
8117
- }
8167
+ if (text2.indexOf("@") >= 0) {
8168
+ if (text2.match(this.re.email_fuzzy) !== null) {
8169
+ return true;
8118
8170
  }
8119
8171
  }
8120
8172
  }
8121
- return this.__index__ >= 0;
8173
+ return false;
8122
8174
  };
8123
8175
  LinkifyIt.prototype.pretest = function pretest(text2) {
8124
8176
  return this.re.pretest.test(text2);
@@ -8131,16 +8183,87 @@ LinkifyIt.prototype.testSchemaAt = function testSchemaAt(text2, schema, pos) {
8131
8183
  };
8132
8184
  LinkifyIt.prototype.match = function match(text2) {
8133
8185
  const result = [];
8134
- let shift = 0;
8135
- if (this.__index__ >= 0 && this.__text_cache__ === text2) {
8136
- result.push(createMatch(this, shift));
8137
- shift = this.__last_index__;
8186
+ const type_schemed = [];
8187
+ const type_fuzzy_link = [];
8188
+ const type_fuzzy_email = [];
8189
+ let m, len, re;
8190
+ function choose(a, b) {
8191
+ if (!a) {
8192
+ return b;
8193
+ }
8194
+ if (!b) {
8195
+ return a;
8196
+ }
8197
+ if (a.index !== b.index) {
8198
+ return a.index < b.index ? a : b;
8199
+ }
8200
+ return a.lastIndex >= b.lastIndex ? a : b;
8201
+ }
8202
+ if (!text2.length) {
8203
+ return null;
8138
8204
  }
8139
- let tail = shift ? text2.slice(shift) : text2;
8140
- while (this.test(tail)) {
8141
- result.push(createMatch(this, shift));
8142
- tail = tail.slice(this.__last_index__);
8143
- shift += this.__last_index__;
8205
+ if (this.re.schema_test.test(text2)) {
8206
+ re = this.re.schema_search;
8207
+ re.lastIndex = 0;
8208
+ while ((m = re.exec(text2)) !== null) {
8209
+ len = this.testSchemaAt(text2, m[2], re.lastIndex);
8210
+ if (len) {
8211
+ type_schemed.push({
8212
+ schema: m[2],
8213
+ index: m.index + m[1].length,
8214
+ lastIndex: m.index + m[0].length + len
8215
+ });
8216
+ }
8217
+ }
8218
+ }
8219
+ if (this.__opts__.fuzzyLink && this.__compiled__["http:"]) {
8220
+ re = this.__opts__.fuzzyIP ? this.re.link_fuzzy_global : this.re.link_no_ip_fuzzy_global;
8221
+ re.lastIndex = 0;
8222
+ while ((m = re.exec(text2)) !== null) {
8223
+ type_fuzzy_link.push({
8224
+ schema: "",
8225
+ index: m.index + m[1].length,
8226
+ lastIndex: m.index + m[0].length
8227
+ });
8228
+ }
8229
+ }
8230
+ if (this.__opts__.fuzzyEmail && this.__compiled__["mailto:"]) {
8231
+ re = this.re.email_fuzzy_global;
8232
+ re.lastIndex = 0;
8233
+ while ((m = re.exec(text2)) !== null) {
8234
+ type_fuzzy_email.push({
8235
+ schema: "mailto:",
8236
+ index: m.index + m[1].length,
8237
+ lastIndex: m.index + m[0].length
8238
+ });
8239
+ }
8240
+ }
8241
+ const indexes = [0, 0, 0];
8242
+ let lastIndex = 0;
8243
+ for (; ; ) {
8244
+ const candidates = [
8245
+ type_schemed[indexes[0]],
8246
+ type_fuzzy_email[indexes[1]],
8247
+ type_fuzzy_link[indexes[2]]
8248
+ ];
8249
+ const candidate = choose(choose(candidates[0], candidates[1]), candidates[2]);
8250
+ if (!candidate) {
8251
+ break;
8252
+ }
8253
+ if (candidate === candidates[0]) {
8254
+ indexes[0]++;
8255
+ } else if (candidate === candidates[1]) {
8256
+ indexes[1]++;
8257
+ } else {
8258
+ indexes[2]++;
8259
+ }
8260
+ if (candidate.index < lastIndex) {
8261
+ continue;
8262
+ }
8263
+ const match2 = new Match(text2, candidate.schema, candidate.index, candidate.lastIndex);
8264
+ this.__compiled__[match2.schema].normalize(match2, this);
8265
+ result.push(match2);
8266
+ lastIndex = candidate.lastIndex;
8144
8267
  }
8145
8268
  if (result.length) {
8146
8269
  return result;
@@ -8148,17 +8271,14 @@ LinkifyIt.prototype.match = function match(text2) {
8148
8271
  return null;
8149
8272
  };
8150
8273
  LinkifyIt.prototype.matchAtStart = function matchAtStart(text2) {
8151
- this.__text_cache__ = text2;
8152
- this.__index__ = -1;
8153
8274
  if (!text2.length) return null;
8154
8275
  const m = this.re.schema_at_start.exec(text2);
8155
8276
  if (!m) return null;
8156
8277
  const len = this.testSchemaAt(text2, m[2], m[0].length);
8157
8278
  if (!len) return null;
8158
- this.__schema__ = m[2];
8159
- this.__index__ = m.index + m[1].length;
8160
- this.__last_index__ = m.index + m[0].length + len;
8161
- return createMatch(this, 0);
8279
+ const match2 = new Match(text2, m[2], m.index + m[1].length, m.index + m[0].length + len);
8280
+ this.__compiled__[match2.schema].normalize(match2, this);
8281
+ return match2;
8162
8282
  };
8163
8283
  LinkifyIt.prototype.tlds = function tlds(list2, keepOld) {
8164
8284
  list2 = Array.isArray(list2) ? list2 : [list2];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-to-im",
3
- "version": "1.0.52",
3
+ "version": "1.0.53",
4
4
  "description": "Installable Codex-to-IM bridge with local setup UI and background service",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/zhangle1987/codex-to-im#readme",
@@ -40,23 +40,24 @@
40
40
  "prepublishOnly": "npm run typecheck && npm run build"
41
41
  },
42
42
  "dependencies": {
43
- "@larksuiteoapi/node-sdk": "^1.65.0",
44
- "@openai/codex-sdk": "^0.133.0",
45
- "markdown-it": "^14.1.1",
43
+ "@larksuiteoapi/node-sdk": "^1.66.0",
44
+ "@openai/codex-sdk": "^0.135.0",
45
+ "markdown-it": "^14.2.0",
46
46
  "qrcode": "^1.5.4",
47
- "ws": "^8.20.1"
47
+ "ws": "^8.21.0"
48
48
  },
49
49
  "overrides": {
50
50
  "axios": "1.16.1",
51
51
  "follow-redirects": "1.16.0",
52
- "protobufjs": "7.5.9"
52
+ "protobufjs": "7.5.9",
53
+ "qs": "6.15.2"
53
54
  },
54
55
  "devDependencies": {
55
56
  "@types/markdown-it": "^14.1.2",
56
57
  "@types/node": "^22",
57
58
  "@types/ws": "^8.5.0",
58
59
  "esbuild": "^0.25.0",
59
- "tsx": "^4.21.0",
60
+ "tsx": "^4.22.3",
60
61
  "typescript": "^5"
61
62
  },
62
63
  "engines": {
@@ -15,7 +15,7 @@ import path from 'node:path';
15
15
  * - If upstream adds `windowsHide` natively, remove this script.
16
16
  */
17
17
  const PATCH_MARKER = 'windowsHide: process.platform === "win32"';
18
- const SUPPORTED_SDK_VERSION = /^0\.(11\d|12\d|13[0-3])\.\d+$/;
18
+ const SUPPORTED_SDK_VERSION = /^0\.(11\d|12\d|13[0-5])\.\d+$/;
19
19
 
20
20
  function logSkip(message) {
21
21
  console.warn(`[postinstall] ${message}`);