codex-to-im 1.0.51 → 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 +238 -105
- package/package.json +8 -7
- package/scripts/patch-codex-sdk-windows-hide.js +1 -1
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(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/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: {
|
|
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
|
}
|
|
@@ -1417,13 +1426,29 @@ var DEDUP_MAX = 1e3;
|
|
|
1417
1426
|
var MAX_FILE_SIZE = 20 * 1024 * 1024;
|
|
1418
1427
|
var COMPLETED_EMOJI = "DONE";
|
|
1419
1428
|
var ERROR_EMOJI = "ERROR";
|
|
1429
|
+
var CARD_TERMINAL_REACTION_DELAY_MS = 2e3;
|
|
1420
1430
|
var CARD_THROTTLE_MS = 1e3;
|
|
1421
1431
|
var CARD_REQUEST_TIMEOUT_MS = 15e3;
|
|
1422
1432
|
var CARD_FINALIZE_FLUSH_WAIT_EXTRA_MS = 1e3;
|
|
1423
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;
|
|
1424
1436
|
var INITIAL_STREAMING_STATUS = "\u5904\u7406\u4E2D";
|
|
1425
1437
|
var EMPTY_STREAMING_TASKS = "";
|
|
1426
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
|
+
}
|
|
1427
1452
|
function buildStreamingCardBody(content, tasksText, toolsText, statusText) {
|
|
1428
1453
|
return {
|
|
1429
1454
|
schema: "2.0",
|
|
@@ -1496,6 +1521,7 @@ var FeishuAdapter = class extends BaseChannelAdapter {
|
|
|
1496
1521
|
cardRequestTimeoutMs = CARD_REQUEST_TIMEOUT_MS;
|
|
1497
1522
|
cardFinalizeFlushWaitExtraMs = CARD_FINALIZE_FLUSH_WAIT_EXTRA_MS;
|
|
1498
1523
|
cardFullRefreshIntervalMs = CARD_FULL_REFRESH_INTERVAL_MS;
|
|
1524
|
+
cardTerminalReactionDelayMs = CARD_TERMINAL_REACTION_DELAY_MS;
|
|
1499
1525
|
constructor(instance) {
|
|
1500
1526
|
super();
|
|
1501
1527
|
this.channelType = instance?.id || "feishu";
|
|
@@ -1995,7 +2021,9 @@ var FeishuAdapter = class extends BaseChannelAdapter {
|
|
|
1995
2021
|
|
|
1996
2022
|
${trimmedResponse}`;
|
|
1997
2023
|
}
|
|
1998
|
-
const
|
|
2024
|
+
const deliverTextSeparately = shouldDeliverFinalTextSeparately(finalText);
|
|
2025
|
+
const cardText = deliverTextSeparately ? buildFinalCardTextPreview(finalText) : finalText;
|
|
2026
|
+
const finalCardJson = buildFinalCardJson(cardText, state.taskItems, state.toolCalls, footer, status);
|
|
1999
2027
|
state.sequence++;
|
|
2000
2028
|
await this.withFeishuRequestTimeout(cardKey, "card.update", () => cardkit.card.update({
|
|
2001
2029
|
path: { card_id: state.cardId },
|
|
@@ -2004,12 +2032,14 @@ ${trimmedResponse}`;
|
|
|
2004
2032
|
sequence: state.sequence
|
|
2005
2033
|
}
|
|
2006
2034
|
}));
|
|
2035
|
+
this.activeCards.delete(cardKey);
|
|
2036
|
+
console.log(`[feishu-adapter] Card finalized: streamKey=${cardKey}, cardId=${state.cardId}, status=${status}, elapsed=${formatElapsed(elapsedMs)}`);
|
|
2007
2037
|
const terminalReactionEmoji = status === "completed" ? COMPLETED_EMOJI : status === "error" ? ERROR_EMOJI : null;
|
|
2008
|
-
if (terminalReactionEmoji) {
|
|
2038
|
+
if (terminalReactionEmoji && this.hasTerminalReactionApi()) {
|
|
2039
|
+
await this.waitBeforeTerminalReaction();
|
|
2009
2040
|
await this.addTerminalReaction(cardKey, state.messageId, terminalReactionEmoji);
|
|
2010
2041
|
}
|
|
2011
|
-
|
|
2012
|
-
return true;
|
|
2042
|
+
return !deliverTextSeparately;
|
|
2013
2043
|
} catch (err) {
|
|
2014
2044
|
console.warn("[feishu-adapter] Card finalize failed:", err instanceof Error ? err.message : err);
|
|
2015
2045
|
return false;
|
|
@@ -2017,6 +2047,15 @@ ${trimmedResponse}`;
|
|
|
2017
2047
|
this.activeCards.delete(cardKey);
|
|
2018
2048
|
}
|
|
2019
2049
|
}
|
|
2050
|
+
hasTerminalReactionApi() {
|
|
2051
|
+
const messageReaction = this.restClient?.im?.messageReaction;
|
|
2052
|
+
return typeof messageReaction?.create === "function";
|
|
2053
|
+
}
|
|
2054
|
+
async waitBeforeTerminalReaction() {
|
|
2055
|
+
const delayMs = Math.max(0, this.cardTerminalReactionDelayMs);
|
|
2056
|
+
if (delayMs <= 0) return;
|
|
2057
|
+
await new Promise((resolve2) => setTimeout(resolve2, delayMs));
|
|
2058
|
+
}
|
|
2020
2059
|
async addTerminalReaction(streamKey, messageId, emojiType) {
|
|
2021
2060
|
const messageReaction = this.restClient?.im?.messageReaction;
|
|
2022
2061
|
if (typeof messageReaction?.create !== "function") return;
|
|
@@ -3339,6 +3378,7 @@ function clearAllPauses() {
|
|
|
3339
3378
|
var utils_exports = {};
|
|
3340
3379
|
__export(utils_exports, {
|
|
3341
3380
|
arrayReplaceAt: () => arrayReplaceAt,
|
|
3381
|
+
asciiTrim: () => asciiTrim,
|
|
3342
3382
|
assign: () => assign,
|
|
3343
3383
|
escapeHtml: () => escapeHtml,
|
|
3344
3384
|
escapeRE: () => escapeRE,
|
|
@@ -3346,6 +3386,7 @@ __export(utils_exports, {
|
|
|
3346
3386
|
has: () => has,
|
|
3347
3387
|
isMdAsciiPunct: () => isMdAsciiPunct,
|
|
3348
3388
|
isPunctChar: () => isPunctChar,
|
|
3389
|
+
isPunctCharCode: () => isPunctCharCode,
|
|
3349
3390
|
isSpace: () => isSpace,
|
|
3350
3391
|
isString: () => isString,
|
|
3351
3392
|
isValidEntityCode: () => isValidEntityCode,
|
|
@@ -4173,6 +4214,9 @@ var xmlDecoder = getDecoder(decode_data_xml_default);
|
|
|
4173
4214
|
function decodeHTML(str, mode = DecodingMode.Legacy) {
|
|
4174
4215
|
return htmlDecoder(str, mode);
|
|
4175
4216
|
}
|
|
4217
|
+
function decodeHTMLStrict(str) {
|
|
4218
|
+
return htmlDecoder(str, DecodingMode.Strict);
|
|
4219
|
+
}
|
|
4176
4220
|
|
|
4177
4221
|
// node_modules/entities/lib/esm/generated/encode-html.js
|
|
4178
4222
|
function restoreDiff(arr) {
|
|
@@ -4398,6 +4442,9 @@ function isWhiteSpace(code2) {
|
|
|
4398
4442
|
function isPunctChar(ch) {
|
|
4399
4443
|
return regex_default4.test(ch) || regex_default5.test(ch);
|
|
4400
4444
|
}
|
|
4445
|
+
function isPunctCharCode(code2) {
|
|
4446
|
+
return isPunctChar(fromCodePoint2(code2));
|
|
4447
|
+
}
|
|
4401
4448
|
function isMdAsciiPunct(ch) {
|
|
4402
4449
|
switch (ch) {
|
|
4403
4450
|
case 33:
|
|
@@ -4444,6 +4491,24 @@ function normalizeReference(str) {
|
|
|
4444
4491
|
}
|
|
4445
4492
|
return str.toLowerCase().toUpperCase();
|
|
4446
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
|
+
}
|
|
4447
4512
|
var lib = { mdurl: mdurl_exports, ucmicro: uc_exports };
|
|
4448
4513
|
|
|
4449
4514
|
// node_modules/markdown-it/lib/helpers/index.mjs
|
|
@@ -5196,12 +5261,27 @@ function replace(state) {
|
|
|
5196
5261
|
var QUOTE_TEST_RE = /['"]/;
|
|
5197
5262
|
var QUOTE_RE = /['"]/g;
|
|
5198
5263
|
var APOSTROPHE = "\u2019";
|
|
5199
|
-
function
|
|
5200
|
-
|
|
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);
|
|
5201
5280
|
}
|
|
5202
5281
|
function process_inlines(tokens, state) {
|
|
5203
5282
|
let j;
|
|
5204
5283
|
const stack = [];
|
|
5284
|
+
const replacements = {};
|
|
5205
5285
|
for (let i = 0; i < tokens.length; i++) {
|
|
5206
5286
|
const token = tokens[i];
|
|
5207
5287
|
const thisLevel = tokens[i].level;
|
|
@@ -5214,9 +5294,9 @@ function process_inlines(tokens, state) {
|
|
|
5214
5294
|
if (token.type !== "text") {
|
|
5215
5295
|
continue;
|
|
5216
5296
|
}
|
|
5217
|
-
|
|
5297
|
+
const text2 = token.content;
|
|
5218
5298
|
let pos = 0;
|
|
5219
|
-
|
|
5299
|
+
const max = text2.length;
|
|
5220
5300
|
OUTER:
|
|
5221
5301
|
while (pos < max) {
|
|
5222
5302
|
QUOTE_RE.lastIndex = pos;
|
|
@@ -5250,8 +5330,8 @@ function process_inlines(tokens, state) {
|
|
|
5250
5330
|
break;
|
|
5251
5331
|
}
|
|
5252
5332
|
}
|
|
5253
|
-
const isLastPunctChar = isMdAsciiPunct(lastChar) ||
|
|
5254
|
-
const isNextPunctChar = isMdAsciiPunct(nextChar) ||
|
|
5333
|
+
const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctCharCode(lastChar);
|
|
5334
|
+
const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctCharCode(nextChar);
|
|
5255
5335
|
const isLastWhiteSpace = isWhiteSpace(lastChar);
|
|
5256
5336
|
const isNextWhiteSpace = isWhiteSpace(nextChar);
|
|
5257
5337
|
if (isNextWhiteSpace) {
|
|
@@ -5279,7 +5359,7 @@ function process_inlines(tokens, state) {
|
|
|
5279
5359
|
}
|
|
5280
5360
|
if (!canOpen && !canClose) {
|
|
5281
5361
|
if (isSingle) {
|
|
5282
|
-
|
|
5362
|
+
addReplacement(replacements, i, t.index, APOSTROPHE);
|
|
5283
5363
|
}
|
|
5284
5364
|
continue;
|
|
5285
5365
|
}
|
|
@@ -5300,18 +5380,8 @@ function process_inlines(tokens, state) {
|
|
|
5300
5380
|
openQuote = state.md.options.quotes[0];
|
|
5301
5381
|
closeQuote = state.md.options.quotes[1];
|
|
5302
5382
|
}
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
tokens[item.token].content,
|
|
5306
|
-
item.pos,
|
|
5307
|
-
openQuote
|
|
5308
|
-
);
|
|
5309
|
-
pos += closeQuote.length - 1;
|
|
5310
|
-
if (item.token === i) {
|
|
5311
|
-
pos += openQuote.length - 1;
|
|
5312
|
-
}
|
|
5313
|
-
text2 = token.content;
|
|
5314
|
-
max = text2.length;
|
|
5383
|
+
addReplacement(replacements, i, t.index, closeQuote);
|
|
5384
|
+
addReplacement(replacements, item.token, item.pos, openQuote);
|
|
5315
5385
|
stack.length = j;
|
|
5316
5386
|
continue OUTER;
|
|
5317
5387
|
}
|
|
@@ -5325,10 +5395,13 @@ function process_inlines(tokens, state) {
|
|
|
5325
5395
|
level: thisLevel
|
|
5326
5396
|
});
|
|
5327
5397
|
} else if (canClose && isSingle) {
|
|
5328
|
-
|
|
5398
|
+
addReplacement(replacements, i, t.index, APOSTROPHE);
|
|
5329
5399
|
}
|
|
5330
5400
|
}
|
|
5331
5401
|
}
|
|
5402
|
+
Object.keys(replacements).forEach(function(tokenIdx) {
|
|
5403
|
+
tokens[tokenIdx].content = applyReplacements(tokens[tokenIdx].content, replacements[tokenIdx]);
|
|
5404
|
+
});
|
|
5332
5405
|
}
|
|
5333
5406
|
function smartquotes(state) {
|
|
5334
5407
|
if (!state.md.options.typographer) {
|
|
@@ -6517,10 +6590,13 @@ function html_block(state, startLine, endLine, silent) {
|
|
|
6517
6590
|
return HTML_SEQUENCES[i][2];
|
|
6518
6591
|
}
|
|
6519
6592
|
let nextLine = startLine + 1;
|
|
6593
|
+
const endsOnBlankLine = HTML_SEQUENCES[i][1].test("");
|
|
6520
6594
|
if (!HTML_SEQUENCES[i][1].test(lineText)) {
|
|
6521
6595
|
for (; nextLine < endLine; nextLine++) {
|
|
6522
6596
|
if (state.sCount[nextLine] < state.blkIndent) {
|
|
6523
|
-
|
|
6597
|
+
if (endsOnBlankLine || !state.isEmpty(nextLine)) {
|
|
6598
|
+
break;
|
|
6599
|
+
}
|
|
6524
6600
|
}
|
|
6525
6601
|
pos = state.bMarks[nextLine] + state.tShift[nextLine];
|
|
6526
6602
|
max = state.eMarks[nextLine];
|
|
@@ -6573,7 +6649,7 @@ function heading(state, startLine, endLine, silent) {
|
|
|
6573
6649
|
token_o.markup = "########".slice(0, level);
|
|
6574
6650
|
token_o.map = [startLine, state.line];
|
|
6575
6651
|
const token_i = state.push("inline", "", 0);
|
|
6576
|
-
token_i.content = state.src.slice(pos, max)
|
|
6652
|
+
token_i.content = asciiTrim(state.src.slice(pos, max));
|
|
6577
6653
|
token_i.map = [startLine, state.line];
|
|
6578
6654
|
token_i.children = [];
|
|
6579
6655
|
const token_c = state.push("heading_close", "h" + String(level), -1);
|
|
@@ -6626,9 +6702,10 @@ function lheading(state, startLine, endLine) {
|
|
|
6626
6702
|
}
|
|
6627
6703
|
}
|
|
6628
6704
|
if (!level) {
|
|
6705
|
+
state.parentType = oldParentType;
|
|
6629
6706
|
return false;
|
|
6630
6707
|
}
|
|
6631
|
-
const content = state.getLines(startLine, nextLine, state.blkIndent, false)
|
|
6708
|
+
const content = asciiTrim(state.getLines(startLine, nextLine, state.blkIndent, false));
|
|
6632
6709
|
state.line = nextLine + 1;
|
|
6633
6710
|
const token_o = state.push("heading_open", "h" + String(level), 1);
|
|
6634
6711
|
token_o.markup = String.fromCharCode(marker);
|
|
@@ -6667,7 +6744,7 @@ function paragraph(state, startLine, endLine) {
|
|
|
6667
6744
|
break;
|
|
6668
6745
|
}
|
|
6669
6746
|
}
|
|
6670
|
-
const content = state.getLines(startLine, nextLine, state.blkIndent, false)
|
|
6747
|
+
const content = asciiTrim(state.getLines(startLine, nextLine, state.blkIndent, false));
|
|
6671
6748
|
state.line = nextLine;
|
|
6672
6749
|
const token_o = state.push("paragraph_open", "p", 1);
|
|
6673
6750
|
token_o.map = [startLine, state.line];
|
|
@@ -6806,15 +6883,37 @@ StateInline.prototype.push = function(type, tag, nesting) {
|
|
|
6806
6883
|
StateInline.prototype.scanDelims = function(start2, canSplitWord) {
|
|
6807
6884
|
const max = this.posMax;
|
|
6808
6885
|
const marker = this.src.charCodeAt(start2);
|
|
6809
|
-
|
|
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
|
+
}
|
|
6810
6903
|
let pos = start2;
|
|
6811
6904
|
while (pos < max && this.src.charCodeAt(pos) === marker) {
|
|
6812
6905
|
pos++;
|
|
6813
6906
|
}
|
|
6814
6907
|
const count = pos - start2;
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
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);
|
|
6818
6917
|
const isLastWhiteSpace = isWhiteSpace(lastChar);
|
|
6819
6918
|
const isNextWhiteSpace = isWhiteSpace(nextChar);
|
|
6820
6919
|
const left_flanking = !isNextWhiteSpace && (!isNextPunctChar || isLastWhiteSpace || isLastPunctChar);
|
|
@@ -7567,7 +7666,7 @@ function entity(state, silent) {
|
|
|
7567
7666
|
} else {
|
|
7568
7667
|
const match2 = state.src.slice(pos).match(NAMED_RE);
|
|
7569
7668
|
if (match2) {
|
|
7570
|
-
const decoded =
|
|
7669
|
+
const decoded = decodeHTMLStrict(match2[0]);
|
|
7571
7670
|
if (decoded !== match2[0]) {
|
|
7572
7671
|
if (!silent) {
|
|
7573
7672
|
const token = state.push("text_special", "", 0);
|
|
@@ -7920,10 +8019,6 @@ var defaultSchemas = {
|
|
|
7920
8019
|
};
|
|
7921
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]";
|
|
7922
8021
|
var tlds_default = "biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|\u0440\u0444".split("|");
|
|
7923
|
-
function resetScanCache(self) {
|
|
7924
|
-
self.__index__ = -1;
|
|
7925
|
-
self.__text_cache__ = "";
|
|
7926
|
-
}
|
|
7927
8022
|
function createValidator(re) {
|
|
7928
8023
|
return function(text2, pos) {
|
|
7929
8024
|
const tail = text2.slice(pos);
|
|
@@ -7951,8 +8046,11 @@ function compile(self) {
|
|
|
7951
8046
|
return tpl.replace("%TLDS%", re.src_tlds);
|
|
7952
8047
|
}
|
|
7953
8048
|
re.email_fuzzy = RegExp(untpl(re.tpl_email_fuzzy), "i");
|
|
8049
|
+
re.email_fuzzy_global = RegExp(untpl(re.tpl_email_fuzzy), "ig");
|
|
7954
8050
|
re.link_fuzzy = RegExp(untpl(re.tpl_link_fuzzy), "i");
|
|
8051
|
+
re.link_fuzzy_global = RegExp(untpl(re.tpl_link_fuzzy), "ig");
|
|
7955
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");
|
|
7956
8054
|
re.host_fuzzy_test = RegExp(untpl(re.tpl_host_fuzzy_test), "i");
|
|
7957
8055
|
const aliases = [];
|
|
7958
8056
|
self.__compiled__ = {};
|
|
@@ -8007,23 +8105,15 @@ function compile(self) {
|
|
|
8007
8105
|
"(" + self.re.schema_test.source + ")|(" + self.re.host_fuzzy_test.source + ")|@",
|
|
8008
8106
|
"i"
|
|
8009
8107
|
);
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
this.
|
|
8017
|
-
this.
|
|
8018
|
-
this.
|
|
8019
|
-
this.raw = text2;
|
|
8020
|
-
this.text = text2;
|
|
8021
|
-
this.url = text2;
|
|
8022
|
-
}
|
|
8023
|
-
function createMatch(self, shift) {
|
|
8024
|
-
const match2 = new Match(self, shift);
|
|
8025
|
-
self.__compiled__[match2.schema].normalize(match2, self);
|
|
8026
|
-
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;
|
|
8027
8117
|
}
|
|
8028
8118
|
function LinkifyIt(schemas, options) {
|
|
8029
8119
|
if (!(this instanceof LinkifyIt)) {
|
|
@@ -8036,10 +8126,6 @@ function LinkifyIt(schemas, options) {
|
|
|
8036
8126
|
}
|
|
8037
8127
|
}
|
|
8038
8128
|
this.__opts__ = assign2({}, defaultOptions, options);
|
|
8039
|
-
this.__index__ = -1;
|
|
8040
|
-
this.__last_index__ = -1;
|
|
8041
|
-
this.__schema__ = "";
|
|
8042
|
-
this.__text_cache__ = "";
|
|
8043
8129
|
this.__schemas__ = assign2({}, defaultSchemas, schemas);
|
|
8044
8130
|
this.__compiled__ = {};
|
|
8045
8131
|
this.__tlds__ = tlds_default;
|
|
@@ -8057,55 +8143,34 @@ LinkifyIt.prototype.set = function set(options) {
|
|
|
8057
8143
|
return this;
|
|
8058
8144
|
};
|
|
8059
8145
|
LinkifyIt.prototype.test = function test(text2) {
|
|
8060
|
-
this.__text_cache__ = text2;
|
|
8061
|
-
this.__index__ = -1;
|
|
8062
8146
|
if (!text2.length) {
|
|
8063
8147
|
return false;
|
|
8064
8148
|
}
|
|
8065
|
-
let m,
|
|
8149
|
+
let m, re;
|
|
8066
8150
|
if (this.re.schema_test.test(text2)) {
|
|
8067
8151
|
re = this.re.schema_search;
|
|
8068
8152
|
re.lastIndex = 0;
|
|
8069
8153
|
while ((m = re.exec(text2)) !== null) {
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
this.__schema__ = m[2];
|
|
8073
|
-
this.__index__ = m.index + m[1].length;
|
|
8074
|
-
this.__last_index__ = m.index + m[0].length + len;
|
|
8075
|
-
break;
|
|
8154
|
+
if (this.testSchemaAt(text2, m[2], re.lastIndex)) {
|
|
8155
|
+
return true;
|
|
8076
8156
|
}
|
|
8077
8157
|
}
|
|
8078
8158
|
}
|
|
8079
8159
|
if (this.__opts__.fuzzyLink && this.__compiled__["http:"]) {
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
if ((ml = text2.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy)) !== null) {
|
|
8084
|
-
shift = ml.index + ml[1].length;
|
|
8085
|
-
if (this.__index__ < 0 || shift < this.__index__) {
|
|
8086
|
-
this.__schema__ = "";
|
|
8087
|
-
this.__index__ = shift;
|
|
8088
|
-
this.__last_index__ = ml.index + ml[0].length;
|
|
8089
|
-
}
|
|
8090
|
-
}
|
|
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;
|
|
8091
8163
|
}
|
|
8092
8164
|
}
|
|
8093
8165
|
}
|
|
8094
8166
|
if (this.__opts__.fuzzyEmail && this.__compiled__["mailto:"]) {
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
|
|
8098
|
-
shift = me.index + me[1].length;
|
|
8099
|
-
next = me.index + me[0].length;
|
|
8100
|
-
if (this.__index__ < 0 || shift < this.__index__ || shift === this.__index__ && next > this.__last_index__) {
|
|
8101
|
-
this.__schema__ = "mailto:";
|
|
8102
|
-
this.__index__ = shift;
|
|
8103
|
-
this.__last_index__ = next;
|
|
8104
|
-
}
|
|
8167
|
+
if (text2.indexOf("@") >= 0) {
|
|
8168
|
+
if (text2.match(this.re.email_fuzzy) !== null) {
|
|
8169
|
+
return true;
|
|
8105
8170
|
}
|
|
8106
8171
|
}
|
|
8107
8172
|
}
|
|
8108
|
-
return
|
|
8173
|
+
return false;
|
|
8109
8174
|
};
|
|
8110
8175
|
LinkifyIt.prototype.pretest = function pretest(text2) {
|
|
8111
8176
|
return this.re.pretest.test(text2);
|
|
@@ -8118,16 +8183,87 @@ LinkifyIt.prototype.testSchemaAt = function testSchemaAt(text2, schema, pos) {
|
|
|
8118
8183
|
};
|
|
8119
8184
|
LinkifyIt.prototype.match = function match(text2) {
|
|
8120
8185
|
const result = [];
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
|
|
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;
|
|
8204
|
+
}
|
|
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
|
+
}
|
|
8125
8218
|
}
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
|
|
8130
|
-
|
|
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;
|
|
8131
8267
|
}
|
|
8132
8268
|
if (result.length) {
|
|
8133
8269
|
return result;
|
|
@@ -8135,17 +8271,14 @@ LinkifyIt.prototype.match = function match(text2) {
|
|
|
8135
8271
|
return null;
|
|
8136
8272
|
};
|
|
8137
8273
|
LinkifyIt.prototype.matchAtStart = function matchAtStart(text2) {
|
|
8138
|
-
this.__text_cache__ = text2;
|
|
8139
|
-
this.__index__ = -1;
|
|
8140
8274
|
if (!text2.length) return null;
|
|
8141
8275
|
const m = this.re.schema_at_start.exec(text2);
|
|
8142
8276
|
if (!m) return null;
|
|
8143
8277
|
const len = this.testSchemaAt(text2, m[2], m[0].length);
|
|
8144
8278
|
if (!len) return null;
|
|
8145
|
-
|
|
8146
|
-
this.
|
|
8147
|
-
|
|
8148
|
-
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;
|
|
8149
8282
|
};
|
|
8150
8283
|
LinkifyIt.prototype.tlds = function tlds(list2, keepOld) {
|
|
8151
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.
|
|
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.
|
|
44
|
-
"@openai/codex-sdk": "^0.
|
|
45
|
-
"markdown-it": "^14.
|
|
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.
|
|
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.
|
|
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-
|
|
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}`);
|