@langlink/dsh-memoq 0.1.10 → 0.1.11

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
@@ -5010,6 +5010,47 @@ function escapeCsvField(value) {
5010
5010
 
5011
5011
  // packages/l10n-core/src/qa/review-data.ts
5012
5012
  import { unzipSync } from "fflate";
5013
+
5014
+ // packages/l10n-core/package.json
5015
+ var package_default = {
5016
+ name: "@langlink/l10n-core",
5017
+ version: "0.0.0",
5018
+ private: true,
5019
+ type: "module",
5020
+ exports: {
5021
+ ".": "./src/index.ts",
5022
+ "./assets": "./src/assets/index.ts",
5023
+ "./qa": "./src/qa/index.ts",
5024
+ "./aiqa": "./src/qa/aiqa.ts",
5025
+ "./qa-catalog": "./src/qa/catalog.ts",
5026
+ "./qa-review": "./src/qa/review-server.ts",
5027
+ "./agent-review": "./src/qa/agent-review.ts"
5028
+ },
5029
+ dependencies: {
5030
+ exceljs: "^4.4.0",
5031
+ fflate: "^0.8.3",
5032
+ htmlparser2: "^12.0.0",
5033
+ saxes: "^6.0.0"
5034
+ }
5035
+ };
5036
+
5037
+ // packages/l10n-core/src/qa/review-data.ts
5038
+ var DEFAULT_REVIEW_TOOL = {
5039
+ name: package_default.name,
5040
+ version: package_default.version
5041
+ };
5042
+ function sanitizeReviewTool(value) {
5043
+ if (!value || typeof value !== "object") return void 0;
5044
+ const candidate = value;
5045
+ const name2 = typeof candidate.name === "string" ? candidate.name.trim() : "";
5046
+ const version = typeof candidate.version === "string" ? candidate.version.trim() : "";
5047
+ if (!name2 || !version || name2.length > 120 || version.length > 120) return void 0;
5048
+ if (/[\r\n\u0000-\u001f\u007f]/u.test(name2) || /[\r\n\u0000-\u001f\u007f]/u.test(version)) return void 0;
5049
+ return { name: name2, version };
5050
+ }
5051
+ function formatReviewTool(tool) {
5052
+ return tool?.name && tool?.version ? `${tool.name}@${tool.version}` : "";
5053
+ }
5013
5054
  var REVIEW_GROUPS = [
5014
5055
  { label: "\u6807\u70B9\u4E0E\u7A7A\u683C", rules: ["UNPAIRED_BRACKET", "PUNCT_DUP", "WHITESPACE"] },
5015
5056
  { label: "Tag \u4E0E\u53D8\u91CF", rules: ["TAG_MISMATCH", "PLACEHOLDER_MISSING", "PLACEHOLDER_EXTRA"] },
@@ -5256,6 +5297,11 @@ async function writeReviewXlsx(Workbook, rows, { collectSections, aiStatus, aiTy
5256
5297
  const limitMessage = "\u7ED3\u679C\u8D85\u8FC7 Excel \u7684\u884C\u6570\u6216\u5355\u5143\u683C\u957F\u5EA6\u9650\u5236\uFF0C\u8BF7\u7F29\u5C0F\u5BFC\u51FA\u8303\u56F4\u3002";
5257
5298
  if (total > 1048575) throw new Error(limitMessage);
5258
5299
  const workbook = new Workbook();
5300
+ const toolLabel = report?.tool?.name && report?.tool?.version ? `${report.tool.name}@${report.tool.version}` : "";
5301
+ if (toolLabel) {
5302
+ workbook.creator = toolLabel;
5303
+ workbook.description = `Generated by ${toolLabel}`;
5304
+ }
5259
5305
  const sheet = workbook.addWorksheet("QA", { views: [{ state: "frozen", ySplit: 1 }] });
5260
5306
  const headers = ["\u89C4\u5219\u7C7B\u522B", "\u6587\u4EF6", "\u53E5\u6BB5\u7F16\u53F7", "\u539F\u6587", "\u8BD1\u6587", "\u8BC4\u8BBA", "AI QA \u7ED3\u679C", "AI \u8BC4\u8BBA"];
5261
5307
  const widths = [23, 31, 14, 42, 42, 42, 21, 64];
@@ -5280,13 +5326,18 @@ async function writeReviewXlsx(Workbook, rows, { collectSections, aiStatus, aiTy
5280
5326
  }
5281
5327
  sheet.getRow(1).font = { bold: true };
5282
5328
  sheet.autoFilter = { from: { row: 1, column: 1 }, to: { row: Math.max(2, sheet.rowCount), column: headers.length } };
5283
- if (report?.configuration) {
5284
- const { files, aiqa, configuration } = report;
5329
+ if (report?.configuration || toolLabel) {
5330
+ const { files = [], aiqa, configuration } = report ?? {};
5285
5331
  const summary = workbook.addWorksheet("\u68C0\u67E5\u6982\u51B5");
5286
5332
  summary.columns = [{ width: 30 }, { width: 74, style: { alignment: { wrapText: true } } }];
5287
- summary.addRow(["\u68C0\u67E5\u72B6\u6001", aiqa?.pending || aiqa?.unavailable || files.some((file) => file.incomplete) ? "\u68C0\u67E5\u672A\u5B8C\u6574\u5B8C\u6210" : "\u68C0\u67E5\u5B8C\u6210"]);
5288
- summary.addRow(["\u57FA\u7840\u68C0\u67E5", configuration.checks.join("\u3001") || "\u672A\u542F\u7528"]);
5289
- summary.addRow(["AIQA", aiqa ? `\u5DF2\u5224\u5B9A ${aiqa.completedSegments} / ${aiqa.totalSegments} \u6BB5\uFF0C\u65E0\u6CD5\u5224\u5B9A ${aiqa.unavailable} \u6BB5\uFF0C\u672A\u5B8C\u6210 ${aiqa.pending} \u6BB5` : "\u672A\u542F\u7528"]);
5333
+ if (configuration) {
5334
+ summary.addRow(["\u68C0\u67E5\u72B6\u6001", aiqa?.pending || aiqa?.unavailable || files.some((file) => file.incomplete) ? "\u68C0\u67E5\u672A\u5B8C\u6574\u5B8C\u6210" : "\u68C0\u67E5\u5B8C\u6210"]);
5335
+ summary.addRow(["\u57FA\u7840\u68C0\u67E5", configuration.checks.join("\u3001") || "\u672A\u542F\u7528"]);
5336
+ summary.addRow(["AIQA", aiqa ? `\u5DF2\u5224\u5B9A ${aiqa.completedSegments} / ${aiqa.totalSegments} \u6BB5\uFF0C\u65E0\u6CD5\u5224\u5B9A ${aiqa.unavailable} \u6BB5\uFF0C\u672A\u5B8C\u6210 ${aiqa.pending} \u6BB5` : "\u672A\u542F\u7528"]);
5337
+ }
5338
+ if (toolLabel) {
5339
+ summary.addRow(["\u5DE5\u5177\u7248\u672C", toolLabel]);
5340
+ }
5290
5341
  for (const file of files) {
5291
5342
  summary.addRow([file.name, file.incomplete ? file.error ?? "\u90E8\u5206\u89C4\u5219\u672A\u5B8C\u6210" : `\u5DF2\u68C0\u67E5 ${file.segments} \u6BB5`]);
5292
5343
  }
@@ -5295,13 +5346,19 @@ async function writeReviewXlsx(Workbook, rows, { collectSections, aiStatus, aiTy
5295
5346
  }
5296
5347
 
5297
5348
  // packages/l10n-core/src/qa/review-page.ts
5349
+ function escapeHtml(value) {
5350
+ return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;");
5351
+ }
5298
5352
  var styles = `
5299
5353
  :root { color-scheme: light; --paper: #f4f6f9; --ink: #192438; --muted: #4b5a6f;
5300
5354
  --border: #d9e0ea; --blue: #164aa4; --surface: #fff; font: 15px/1.5 system-ui, sans-serif; }
5301
5355
  * { box-sizing: border-box; }
5302
5356
  body { margin: 0; color: var(--ink); background: var(--paper); }
5303
5357
  main { width: min(1480px, 100%); margin: auto; padding: 28px clamp(14px, 3vw, 36px) 44px; }
5358
+ .header-bar { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
5304
5359
  .brand { color: var(--blue); font-weight: 700; letter-spacing: .04em; }
5360
+ .tool-version { font-size: 12px; color: var(--muted); background: #edf2f8; border: 1px solid var(--border);
5361
+ border-radius: 999px; padding: 2px 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
5305
5362
  h1 { font-size: clamp(26px, 4vw, 35px); margin: 4px 0 22px; letter-spacing: -.03em; }
5306
5363
  h2 { font-size: 18px; margin: 0 0 14px; }
5307
5364
  p { margin: 0; } small, .muted { color: var(--muted); }
@@ -5401,6 +5458,7 @@ function reviewClient(presentation, writeXlsx) {
5401
5458
  let report = { rows: [], files: [] };
5402
5459
  let filtered = [];
5403
5460
  let lastScan;
5461
+ let lastChecks = [];
5404
5462
  let aiqaRunning = false;
5405
5463
  const collapsed = /* @__PURE__ */ new Set();
5406
5464
  const pageSize = 50;
@@ -5700,16 +5758,39 @@ function reviewClient(presentation, writeXlsx) {
5700
5758
  const chosen = get("export-scope").value === "all" ? [...report.rows, ...aiqaRows.values()] : filtered;
5701
5759
  let blob;
5702
5760
  if (form) {
5761
+ const totalSegments = report.segments?.length ?? report.files.reduce((sum, item) => sum + item.segments, 0);
5762
+ let autoPass = 0;
5763
+ let humanReview = 0;
5764
+ let unavailable = 0;
5765
+ for (const row of aiqaRows.values()) {
5766
+ if (row.rule === "AIQA_UNAVAILABLE") unavailable += 1;
5767
+ else if (row.message === "AUTO_PASS") autoPass += 1;
5768
+ else humanReview += 1;
5769
+ }
5770
+ const aiqaSummary = aiqaRows.size > 0 ? {
5771
+ totalSegments,
5772
+ completedSegments: autoPass + humanReview,
5773
+ autoPass,
5774
+ humanReview,
5775
+ unavailable,
5776
+ pending: Math.max(0, totalSegments - aiqaRows.size)
5777
+ } : void 0;
5778
+ const exportPayload = {
5779
+ rows: chosen,
5780
+ files: report.files,
5781
+ configuration: { checks: lastChecks, aiqa: aiqaRows.size > 0 },
5782
+ ...aiqaSummary ? { aiqa: aiqaSummary } : {}
5783
+ };
5703
5784
  const response = await requestLocal("/export/" + format, {
5704
5785
  method: "POST",
5705
5786
  headers: { "Content-Type": "application/json" },
5706
- body: JSON.stringify({ rows: chosen, files: report.files })
5787
+ body: JSON.stringify(exportPayload)
5707
5788
  });
5708
5789
  if (!response.ok) throw new Error((await response.json()).error || "\u5BFC\u51FA\u5931\u8D25\u3002");
5709
5790
  blob = await response.blob();
5710
5791
  } else {
5711
5792
  const { ExcelJS: ExcelJS2 } = globalThis;
5712
- const bytes = await writeXlsx(ExcelJS2.Workbook, chosen, presentation);
5793
+ const bytes = await writeXlsx(ExcelJS2.Workbook, chosen, presentation, report);
5713
5794
  blob = new Blob([bytes], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
5714
5795
  }
5715
5796
  const url = URL.createObjectURL(blob);
@@ -5746,7 +5827,9 @@ function reviewClient(presentation, writeXlsx) {
5746
5827
  if (run.disabled) return;
5747
5828
  const body = new FormData();
5748
5829
  for (const upload of get("uploads").files ?? []) body.append("file", upload);
5749
- const rules = Array.from(form.querySelectorAll("input[data-rules]:checked")).flatMap((item) => (item.dataset.rules ?? "").split(","));
5830
+ const checkInputs = Array.from(form.querySelectorAll("input[data-rules]:checked"));
5831
+ const rules = checkInputs.flatMap((item) => (item.dataset.rules ?? "").split(","));
5832
+ const checkedLabels = checkInputs.map((item) => item.closest("label")?.textContent?.trim() ?? "").filter(Boolean);
5750
5833
  const identicalWhitelist = get("whitelist").value.split("\n").map((text) => text.trim()).filter(Boolean);
5751
5834
  const customRules = Array.from(ruleList.querySelectorAll("fieldset")).map((row) => ({
5752
5835
  name: row.querySelector("[data-name]").value.trim(),
@@ -5754,6 +5837,7 @@ function reviewClient(presentation, writeXlsx) {
5754
5837
  kind: row.querySelector("select").value,
5755
5838
  value: row.querySelector("[data-value]").value.trim()
5756
5839
  }));
5840
+ lastChecks = [...checkedLabels, ...customRules.map((rule) => rule.name).filter(Boolean)];
5757
5841
  body.append("options", JSON.stringify({ rules, identicalWhitelist, customRules }));
5758
5842
  run.disabled = true;
5759
5843
  lastScan = void 0;
@@ -5845,8 +5929,11 @@ function excelScript() {
5845
5929
  }
5846
5930
  return excelBrowserScript;
5847
5931
  }
5848
- function renderReviewPage(report, nonce = "", aiqaEnabled = false) {
5932
+ function renderReviewPage(report, nonce = "", aiqaEnabled = false, tool) {
5849
5933
  const offline = report !== void 0;
5934
+ const resolvedTool = report?.tool ?? tool;
5935
+ const toolLabel = formatReviewTool(resolvedTool);
5936
+ const reportPayload = report ? resolvedTool && !report.tool ? { ...report, tool: resolvedTool } : report : void 0;
5850
5937
  const title = offline ? "\u53CC\u8BED QA \u62A5\u544A" : "\u53CC\u8BED\u6587\u4EF6\u68C0\u67E5";
5851
5938
  const settings = offline ? "" : `<form class="panel" id="settings">
5852
5939
  <h2>\u672C\u6B21\u68C0\u67E5</h2>
@@ -5882,11 +5969,13 @@ function renderReviewPage(report, nonce = "", aiqaEnabled = false) {
5882
5969
  <small>\u8FD0\u884C\u65F6\uFF0C\u6240\u9009\u6BB5\u843D\u3001\u76F8\u90BB\u539F\u6587\u548C\u9879\u76EE\u8981\u6C42\u4F1A\u53D1\u9001\u5230\u5DF2\u914D\u7F6E\u7684\u6A21\u578B\u7F51\u5173\u3002</small>
5883
5970
  <p id="aiqa-status" role="status"></p>` : "<small>\u914D\u7F6E\u6A21\u578B\u7F51\u5173\u540E\u53EF\u8FD0\u884C AIQA\u3002</small>"}
5884
5971
  </div>`;
5885
- const data = offline ? `<script type="application/json" id="report-data">${JSON.stringify(report).replaceAll("<", "\\u003c")}</script>` : "";
5972
+ const data = reportPayload ? `<script type="application/json" id="report-data">${JSON.stringify(reportPayload).replaceAll("<", "\\u003c")}</script>` : "";
5886
5973
  const scriptNonce = nonce ? ` nonce="${nonce}"` : "";
5974
+ const generatorMeta = toolLabel ? `<meta name="generator" content="${escapeHtml(toolLabel)}">` : "";
5975
+ const versionBadge = toolLabel ? `<span class="tool-version" id="tool-version">\u5DE5\u5177\u7248\u672C\uFF1A${escapeHtml(toolLabel)}</span>` : "";
5887
5976
  return `<!doctype html><html lang="zh-CN"><head><meta charset="utf-8">
5888
- <meta name="viewport" content="width=device-width, initial-scale=1"><title>${title} \xB7 LangLink</title>
5889
- <style>${styles}</style></head><body><main><p class="brand">LangLink</p><h1>${title}</h1>
5977
+ <meta name="viewport" content="width=device-width, initial-scale=1">${generatorMeta}<title>${title} \xB7 LangLink</title>
5978
+ <style>${styles}</style></head><body><main><div class="header-bar"><p class="brand">LangLink</p>${versionBadge}</div><h1>${title}</h1>
5890
5979
  <div class="layout${offline ? " offline" : ""}">${settings}
5891
5980
  <section class="panel" aria-labelledby="results-title"><h2 id="results-title">\u68C0\u67E5\u7ED3\u679C</h2>
5892
5981
  <p class="muted" id="status" role="status">${offline ? "" : "\u9009\u62E9\u6587\u4EF6\u548C\u68C0\u67E5\u9879\uFF0C\u7136\u540E\u8FD0\u884C\u68C0\u67E5\u3002"}</p>
@@ -5927,18 +6016,28 @@ function validateReviewExportReport(bytes) {
5927
6016
  if (report.aiqa && typeof report.aiqa === "object" && ["totalSegments", "completedSegments", "autoPass", "humanReview", "unavailable", "pending"].every((key) => Number.isSafeInteger(report.aiqa[key]))) {
5928
6017
  optional.aiqa = report.aiqa;
5929
6018
  }
6019
+ const tool = sanitizeReviewTool(report.tool);
6020
+ if (tool) optional.tool = tool;
5930
6021
  return { rows: report.rows, files: report.files, ...optional };
5931
6022
  }
5932
6023
  function csvCell(value) {
5933
6024
  return escapeCsvField(/^[\s\uFEFF]*[=+@-]|^[\t\r\n]/u.test(value) ? "'" + value : value);
5934
6025
  }
5935
6026
  async function buildReviewExportArtifact(format, report) {
6027
+ const toolLabel = formatReviewTool(report.tool);
5936
6028
  if (format === "html") {
5937
- return { contentType: "text/html; charset=utf-8", body: renderReviewPage(report) };
6029
+ return { contentType: "text/html; charset=utf-8", body: renderReviewPage(report, "", false, report.tool) };
5938
6030
  }
5939
- const headers = Object.values(REVIEW_COLUMNS);
6031
+ const headers = toolLabel ? [...Object.values(REVIEW_COLUMNS), "\u5DE5\u5177\u7248\u672C"] : Object.values(REVIEW_COLUMNS);
5940
6032
  if (format === "csv") {
5941
- const lines = [headers.join(","), ...report.rows.map((row) => columnKeys.map((key) => csvCell(row[key])).join(","))];
6033
+ const lines = [
6034
+ headers.join(","),
6035
+ ...report.rows.map((row) => {
6036
+ const cells = columnKeys.map((key) => csvCell(row[key]));
6037
+ if (toolLabel) cells.push(csvCell(toolLabel));
6038
+ return cells.join(",");
6039
+ })
6040
+ ];
5942
6041
  return { contentType: "text/csv; charset=utf-8", body: "\uFEFF" + lines.join("\r\n") + "\r\n" };
5943
6042
  }
5944
6043
  const bytes = await writeReviewXlsx(ExcelJS.Workbook, report.rows, createReviewPresentation(), report);
@@ -6708,17 +6807,26 @@ async function runMemoqAiqa(input) {
6708
6807
  }
6709
6808
 
6710
6809
  // packages/memoq-bridge/src/review-page.ts
6810
+ function escapeHtmlAttr(value) {
6811
+ return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;");
6812
+ }
6711
6813
  function renderReviewWorkbenchHtml(options) {
6814
+ const toolInfo = options.tool?.name && options.tool?.version ? options.tool : void 0;
6815
+ const toolLabel = toolInfo ? `${toolInfo.name}@${toolInfo.version}` : "";
6816
+ const toolShort = toolInfo ? `v${toolInfo.version}` : "";
6817
+ const generatorMeta = toolLabel ? `
6818
+ <meta name="generator" content="${escapeHtmlAttr(toolLabel)}" />` : "";
6712
6819
  const bootJson = JSON.stringify({
6713
6820
  reviewToken: options.reviewToken,
6714
6821
  initialDocumentName: options.initialDocumentName ?? "",
6715
- aiqaLimit: options.aiqaSelectionLimit ?? 20
6822
+ aiqaLimit: options.aiqaSelectionLimit ?? 20,
6823
+ tool: toolInfo ?? null
6716
6824
  }).replace(/</gu, "\\u003c");
6717
6825
  return `<!DOCTYPE html>
6718
6826
  <html lang="zh-CN">
6719
6827
  <head>
6720
6828
  <meta charset="utf-8" />
6721
- <meta name="viewport" content="width=device-width, initial-scale=1" />
6829
+ <meta name="viewport" content="width=device-width, initial-scale=1" />${generatorMeta}
6722
6830
  <title>LangLink memoQ CAT \u53CC\u8BED\u5BA1\u6821\u4E0E QA \u5DE5\u4F5C\u53F0</title>
6723
6831
  <style>
6724
6832
  :root {
@@ -7418,6 +7526,7 @@ function renderReviewWorkbenchHtml(options) {
7418
7526
  <header class="cat-ribbon">
7419
7527
  <div class="ribbon-left">
7420
7528
  <span class="brand-chip"><span class="brand-badge">CAT</span><span id="docTitle" class="doc-title">LangLink memoQ \u5DE5\u4F5C\u53F0</span></span>
7529
+ <span id="toolVersionBadge" class="pill mono${toolShort ? "" : " hidden"}" title="${escapeHtmlAttr(toolLabel)}">${escapeHtmlAttr(toolShort)}</span>
7421
7530
  <select id="docSelector" class="doc-select" aria-label="\u6587\u6863\u5207\u6362"></select>
7422
7531
  <span id="langPair" class="pill">- \u2192 -</span>
7423
7532
  <span id="previewBadge" class="pill">Preview: \u68C0\u6D4B\u4E2D</span>
@@ -7620,6 +7729,7 @@ function renderReviewWorkbenchHtml(options) {
7620
7729
  <span class="pill info" id="pillMqm">MQM: -</span>
7621
7730
  </div>
7622
7731
  <div class="status-group">
7732
+ <span id="toolVersionFooter" class="mono${toolLabel ? "" : " hidden"}" style="color:var(--muted);">${escapeHtmlAttr(toolLabel)}</span>
7623
7733
  <span id="bridgeStatusPill" class="pill ok">\u25CF \u6865\u63A5\u5DF2\u8FDE\u63A5</span>
7624
7734
  </div>
7625
7735
  </footer>
@@ -8102,6 +8212,19 @@ function renderReviewWorkbenchHtml(options) {
8102
8212
 
8103
8213
  const projInput = document.getElementById("inpProjectDir");
8104
8214
  if (!projInput.value && d.projectDir) projInput.value = d.projectDir;
8215
+ const toolMeta = (d.tool && d.tool.name && d.tool.version) ? d.tool : BOOT.tool;
8216
+ const toolText = toolMeta && toolMeta.name && toolMeta.version ? (toolMeta.name + "@" + toolMeta.version) : "";
8217
+ const tvBadge = document.getElementById("toolVersionBadge");
8218
+ if (tvBadge) {
8219
+ tvBadge.textContent = toolText ? ("v" + toolMeta.version) : "";
8220
+ tvBadge.title = toolText;
8221
+ tvBadge.classList.toggle("hidden", !toolText);
8222
+ }
8223
+ const tvFooter = document.getElementById("toolVersionFooter");
8224
+ if (tvFooter) {
8225
+ tvFooter.textContent = toolText;
8226
+ tvFooter.classList.toggle("hidden", !toolText);
8227
+ }
8105
8228
  renderBridgePill();
8106
8229
  }
8107
8230
 
@@ -9165,6 +9288,10 @@ function renderReviewWorkbenchHtml(options) {
9165
9288
  ? catalog.filter((c) => state.selectedRules.has(c.ruleId)).map((c) => c.label)
9166
9289
  : [];
9167
9290
  const aiSummary = state.qaAiqaRows.size > 0 ? computeAiqaSummaryCounts() : undefined;
9291
+ const activeTool = (state.qa && state.qa.tool) || (state.data && state.data.tool) || BOOT.tool;
9292
+ const toolPayload = activeTool && activeTool.name && activeTool.version
9293
+ ? { name: String(activeTool.name), version: String(activeTool.version) }
9294
+ : undefined;
9168
9295
  const payload = {
9169
9296
  rows: cleanRows,
9170
9297
  files,
@@ -9172,7 +9299,8 @@ function renderReviewWorkbenchHtml(options) {
9172
9299
  aiqa: Boolean(state.data && state.data.aiqaAvailable && state.qaAiqaRows.size > 0),
9173
9300
  checks: checkedLabels
9174
9301
  },
9175
- ...(aiSummary ? { aiqa: aiSummary } : {})
9302
+ ...(aiSummary ? { aiqa: aiSummary } : {}),
9303
+ ...(toolPayload ? { tool: toolPayload } : {})
9176
9304
  };
9177
9305
 
9178
9306
  const res = await fetch("/review/api/qa/export/" + format, {
@@ -9774,6 +9902,8 @@ async function createMtGateway(options) {
9774
9902
  const requestedPort = options.port ?? DEFAULT_PORT;
9775
9903
  const productName = options.productName ?? BRIDGE_PRODUCT_NAME;
9776
9904
  const desktopVersion = options.desktopVersion ?? BRIDGE_VERSION;
9905
+ const toolName = options.toolName?.trim() || "@langlink/memoq-bridge";
9906
+ const toolInfo = { name: toolName, version: desktopVersion };
9777
9907
  const controlToken = options.controlToken ?? randomUUID3().replace(/-/gu, "");
9778
9908
  const candidateReviewToken = typeof options.reviewToken === "string" ? options.reviewToken.trim() : "";
9779
9909
  const reviewToken = candidateReviewToken.length >= 24 && candidateReviewToken !== controlToken ? candidateReviewToken : randomBytes(24).toString("hex");
@@ -10143,6 +10273,7 @@ async function createMtGateway(options) {
10143
10273
  sendJson(response, 200, {
10144
10274
  ok: true,
10145
10275
  productName,
10276
+ toolName,
10146
10277
  mode: effectiveMode(),
10147
10278
  contractVersion: CONTRACT_VERSION,
10148
10279
  desktopVersion
@@ -10152,6 +10283,7 @@ async function createMtGateway(options) {
10152
10283
  if (method === "GET" && pathname === ROUTES.desktopVersion) {
10153
10284
  sendJson(response, 200, {
10154
10285
  productName,
10286
+ toolName,
10155
10287
  desktopVersion,
10156
10288
  contractVersion: CONTRACT_VERSION
10157
10289
  });
@@ -10532,6 +10664,7 @@ async function createMtGateway(options) {
10532
10664
  renderReviewWorkbenchHtml({
10533
10665
  nonce,
10534
10666
  reviewToken,
10667
+ tool: toolInfo,
10535
10668
  ...initialDocName ? { initialDocumentName: initialDocName } : {}
10536
10669
  }),
10537
10670
  csp,
@@ -10645,6 +10778,7 @@ async function createMtGateway(options) {
10645
10778
  qaCatalog: MEMOQ_QA_RULE_CATALOG,
10646
10779
  qaRuleGroups: MEMOQ_QA_RULE_GROUPS,
10647
10780
  aiqaAvailable: Boolean(aiqaProvider),
10781
+ tool: toolInfo,
10648
10782
  projectDir: options.getLiveConfig?.().projectDir ?? "",
10649
10783
  maxStaged: DEFAULT_MAX_STAGED
10650
10784
  });
@@ -10705,7 +10839,7 @@ async function createMtGateway(options) {
10705
10839
  }
10706
10840
  if (method === "POST" && pathname === "/review/api/qa") {
10707
10841
  const body = await readJsonBody(request);
10708
- sendJson(response, 200, runQaFromBody(body));
10842
+ sendJson(response, 200, { ...runQaFromBody(body), tool: toolInfo });
10709
10843
  return;
10710
10844
  }
10711
10845
  if (method === "POST" && pathname === "/review/api/qa/aiqa") {
@@ -10784,7 +10918,7 @@ async function createMtGateway(options) {
10784
10918
  } catch (error) {
10785
10919
  throw new BodyError(400, "INVALID_EXPORT_REPORT", error instanceof Error ? error.message : String(error));
10786
10920
  }
10787
- const artifact = await buildReviewExportArtifact(exportFormat, reportPayload);
10921
+ const artifact = await buildReviewExportArtifact(exportFormat, { ...reportPayload, tool: toolInfo });
10788
10922
  response.writeHead(200, {
10789
10923
  "Content-Type": artifact.contentType,
10790
10924
  "Content-Disposition": `attachment; filename="langlink-memoq-qa.${exportFormat}"`,
@@ -10805,10 +10939,13 @@ async function createMtGateway(options) {
10805
10939
  gateway: {
10806
10940
  running: true,
10807
10941
  owner: "langlink-memoq-bridge",
10942
+ toolName,
10943
+ version: desktopVersion,
10808
10944
  mode: effectiveMode(),
10809
10945
  url: `http://${host}:${actualPort}`,
10810
10946
  contractVersion: CONTRACT_VERSION
10811
10947
  },
10948
+ tool: toolInfo,
10812
10949
  reviewUrl: getReviewUrl(),
10813
10950
  preview: options.previewClient?.getStatus() ?? null,
10814
10951
  documents: unified,
@@ -10961,7 +11098,8 @@ async function createMtGateway(options) {
10961
11098
  const body = await readJsonBody(request);
10962
11099
  sendJson(response, 200, {
10963
11100
  ...runQaFromBody(body),
10964
- reviewUrl: getReviewUrl()
11101
+ reviewUrl: getReviewUrl(),
11102
+ tool: toolInfo
10965
11103
  });
10966
11104
  return;
10967
11105
  }
@@ -11097,16 +11235,33 @@ async function createMtGateway(options) {
11097
11235
  }
11098
11236
 
11099
11237
  // packages/memoq-bridge/src/dll-assets.ts
11238
+ import { execFile } from "node:child_process";
11100
11239
  import { createHash as createHash2, randomUUID as randomUUID4 } from "node:crypto";
11101
- import { existsSync as existsSync4, mkdirSync as mkdirSync3, readdirSync, readFileSync as readFileSync5, renameSync as renameSync2, statSync as statSync2, writeFileSync as writeFileSync3 } from "node:fs";
11240
+ import {
11241
+ closeSync,
11242
+ existsSync as existsSync4,
11243
+ mkdirSync as mkdirSync3,
11244
+ openSync,
11245
+ readdirSync,
11246
+ readFileSync as readFileSync5,
11247
+ readSync,
11248
+ renameSync as renameSync2,
11249
+ rmSync as rmSync2,
11250
+ statSync as statSync2,
11251
+ writeFileSync as writeFileSync3
11252
+ } from "node:fs";
11102
11253
  import { homedir as homedir2 } from "node:os";
11103
11254
  import { dirname as dirname4, join as join5, resolve as resolve3 } from "node:path";
11255
+ import { promisify } from "node:util";
11256
+ import { inflateRawSync } from "node:zlib";
11104
11257
  import { unzipSync as unzipSync2 } from "fflate";
11258
+ var execFileAsync = promisify(execFile);
11105
11259
  var DEFAULT_PLUGIN_DLL_MANIFEST = {
11106
11260
  pluginDllName: PLUGIN_DLL_NAME,
11107
11261
  version: "1.0.7.0",
11108
- sha256: "E0C731FFBDD7F613104D372C376F35596C95B46A628B8C574C753EAAF4A20CE1",
11262
+ sha256: "BB8250B5EFB6F742E1F10DA43E40008EB5DC04587B5DBA262AEAB0F7B7F5545E",
11109
11263
  compatibleSha256s: [
11264
+ "BB8250B5EFB6F742E1F10DA43E40008EB5DC04587B5DBA262AEAB0F7B7F5545E",
11110
11265
  "E0C731FFBDD7F613104D372C376F35596C95B46A628B8C574C753EAAF4A20CE1",
11111
11266
  "385F22C08DBBBB98A962A2119DA10675ADF996ECD16F397B50CE627AFBAFA4F9"
11112
11267
  ],
@@ -11115,8 +11270,23 @@ var DEFAULT_PLUGIN_DLL_MANIFEST = {
11115
11270
  };
11116
11271
  var MAX_DISCOVERY_DIR_ENTRIES = 200;
11117
11272
  var MAX_ZIP_INSPECT_BYTES = 200 * 1024 * 1024;
11118
- var MAX_FAST_ZIP_HASH_BYTES = 25 * 1024 * 1024;
11273
+ var MAX_DLL_BYTES = 50 * 1024 * 1024;
11274
+ var MAX_REDIRECTS = 5;
11275
+ var DEFAULT_DOWNLOAD_TIMEOUT_MS = 25e3;
11119
11276
  var ZIP_CANDIDATE_NAME_RE = /memoq.*(?:ai[-_]?hub|plugin)|memoq\.ai\.hub\.plugin/iu;
11277
+ var PluginAssetIntegrityError = class extends Error {
11278
+ };
11279
+ var PluginAssetPolicyError = class extends Error {
11280
+ };
11281
+ function isLoopbackHost(hostname) {
11282
+ const host = hostname.replace(/^\[/u, "").replace(/\]$/u, "").toLowerCase();
11283
+ return host === "127.0.0.1" || host === "localhost" || host === "::1";
11284
+ }
11285
+ function isPluginDllZipEntry(name2) {
11286
+ const normalized = name2.replace(/\\/gu, "/").toLowerCase();
11287
+ const target = PLUGIN_DLL_NAME.toLowerCase();
11288
+ return normalized === target || normalized.endsWith(`/${target}`);
11289
+ }
11120
11290
  function acceptedPluginSha256s(explicitExpectedSha256) {
11121
11291
  const override = (explicitExpectedSha256?.trim() || process.env.MEMOQ_PLUGIN_DLL_SHA256?.trim() || "").toUpperCase();
11122
11292
  if (override) {
@@ -11136,26 +11306,101 @@ function computeBufferSha256(bytes) {
11136
11306
  function computeFileSha256(filePath) {
11137
11307
  return computeBufferSha256(readFileSync5(filePath));
11138
11308
  }
11139
- function parseAllowedAssetUrl(raw) {
11309
+ function parseAllowedAssetUrl(raw, options) {
11140
11310
  let url;
11141
11311
  try {
11142
11312
  url = new URL(raw);
11143
11313
  } catch {
11144
- throw new Error("Plugin DLL download URL is not a valid URL.");
11314
+ throw new PluginAssetPolicyError("Plugin DLL download URL is not a valid URL.");
11145
11315
  }
11146
11316
  if (url.protocol !== "https:" && url.protocol !== "http:") {
11147
- throw new Error("Plugin DLL download URL must use https or loopback http.");
11317
+ throw new PluginAssetPolicyError("Plugin DLL download URL must use https or loopback http.");
11318
+ }
11319
+ const isLoopback = isLoopbackHost(url.hostname);
11320
+ if (options?.allowLoopback === false && isLoopback) {
11321
+ throw new PluginAssetPolicyError("External plugin DLL download URL must not redirect to loopback.");
11148
11322
  }
11149
- const host = url.hostname.replace(/^\[/u, "").replace(/\]$/u, "").toLowerCase();
11150
- const isLoopback = host === "127.0.0.1" || host === "localhost" || host === "::1";
11151
11323
  if (url.protocol === "http:" && !isLoopback) {
11152
- throw new Error("Plugin DLL download URL must use https unless it points at loopback.");
11324
+ throw new PluginAssetPolicyError("Plugin DLL download URL must use https unless it points at loopback.");
11153
11325
  }
11154
11326
  if (url.username !== "" || url.password !== "") {
11155
- throw new Error("Plugin DLL download URL must not embed credentials.");
11327
+ throw new PluginAssetPolicyError("Plugin DLL download URL must not embed credentials.");
11156
11328
  }
11157
11329
  return url;
11158
11330
  }
11331
+ async function fetchFollowingValidatedRedirects(initialUrl, init, fetchFn, timeoutMs) {
11332
+ const allowLoopback = isLoopbackHost(initialUrl.hostname);
11333
+ let currentUrl = initialUrl;
11334
+ for (let hop = 0; hop <= MAX_REDIRECTS; hop += 1) {
11335
+ const response = await fetchFn(currentUrl, {
11336
+ ...init,
11337
+ redirect: "manual",
11338
+ signal: AbortSignal.timeout(timeoutMs)
11339
+ });
11340
+ if ([301, 302, 303, 307, 308].includes(response.status)) {
11341
+ const location = response.headers.get("location");
11342
+ await response.body?.cancel?.().catch(() => {
11343
+ });
11344
+ if (hop >= MAX_REDIRECTS) {
11345
+ throw new Error(`Exceeded maximum redirect limit (${MAX_REDIRECTS}).`);
11346
+ }
11347
+ if (!location) {
11348
+ throw new Error(`Redirect response (${response.status}) missing Location header.`);
11349
+ }
11350
+ currentUrl = parseAllowedAssetUrl(new URL(location, currentUrl).href, { allowLoopback });
11351
+ continue;
11352
+ }
11353
+ if (response.url) {
11354
+ parseAllowedAssetUrl(response.url, { allowLoopback });
11355
+ }
11356
+ return { response, finalUrl: currentUrl };
11357
+ }
11358
+ throw new Error(`Exceeded maximum redirect limit (${MAX_REDIRECTS}).`);
11359
+ }
11360
+ async function readResponseBytesBounded(response, maxBytes) {
11361
+ const contentLengthHeader = response.headers?.get?.("content-length");
11362
+ if (contentLengthHeader) {
11363
+ const declared = Number.parseInt(contentLengthHeader, 10);
11364
+ if (Number.isFinite(declared) && declared > maxBytes) {
11365
+ await response.body?.cancel?.().catch(() => {
11366
+ });
11367
+ throw new PluginAssetIntegrityError(`Downloaded plugin artifact exceeds maximum size limit (${maxBytes} bytes).`);
11368
+ }
11369
+ }
11370
+ if (response.body && typeof response.body.getReader === "function") {
11371
+ const reader = response.body.getReader();
11372
+ const chunks = [];
11373
+ let total = 0;
11374
+ try {
11375
+ while (true) {
11376
+ const { done, value } = await reader.read();
11377
+ if (done) break;
11378
+ if (!value) continue;
11379
+ total += value.byteLength;
11380
+ if (total > maxBytes) {
11381
+ await reader.cancel().catch(() => {
11382
+ });
11383
+ throw new PluginAssetIntegrityError(`Downloaded plugin artifact exceeds maximum size limit (${maxBytes} bytes).`);
11384
+ }
11385
+ chunks.push(value);
11386
+ }
11387
+ } finally {
11388
+ reader.releaseLock?.();
11389
+ }
11390
+ const combined = new Uint8Array(total);
11391
+ let offset = 0;
11392
+ for (const chunk of chunks) {
11393
+ combined.set(chunk, offset);
11394
+ offset += chunk.byteLength;
11395
+ }
11396
+ return combined;
11397
+ }
11398
+ const rawBytes = new Uint8Array(await response.arrayBuffer());
11399
+ if (rawBytes.byteLength > maxBytes) {
11400
+ throw new PluginAssetIntegrityError(`Downloaded plugin artifact exceeds maximum size limit (${maxBytes} bytes).`);
11401
+ }
11402
+ return rawBytes;
11403
+ }
11159
11404
  function normalizeExpectedShaList(expectedSha256) {
11160
11405
  if (Array.isArray(expectedSha256)) {
11161
11406
  return Array.from(new Set(expectedSha256.map((s) => s.trim().toUpperCase()).filter(Boolean)));
@@ -11167,38 +11412,361 @@ function normalizeExpectedShaList(expectedSha256) {
11167
11412
  }
11168
11413
  function extractPluginDllFromBytes(bytes, expectedSha256) {
11169
11414
  if (bytes.length < 2) {
11170
- throw new Error("Downloaded plugin artifact is empty.");
11415
+ throw new PluginAssetIntegrityError("Downloaded plugin artifact is empty.");
11416
+ }
11417
+ if (bytes.byteLength > MAX_ZIP_INSPECT_BYTES) {
11418
+ throw new PluginAssetIntegrityError(`Plugin artifact exceeds maximum size limit (${MAX_ZIP_INSPECT_BYTES} bytes).`);
11171
11419
  }
11172
11420
  let dllBytes;
11173
11421
  const isZip = bytes[0] === 80 && bytes[1] === 75;
11174
11422
  if (isZip) {
11175
- const entries = unzipSync2(bytes);
11423
+ const entries = unzipSync2(bytes, {
11424
+ filter: (file) => isPluginDllZipEntry(file.name) && (file.originalSize === void 0 || file.originalSize <= MAX_DLL_BYTES)
11425
+ });
11176
11426
  for (const [name2, content] of Object.entries(entries)) {
11177
- const normalized = name2.replace(/\\/gu, "/").toLowerCase();
11178
- if (normalized === PLUGIN_DLL_NAME.toLowerCase() || normalized.endsWith(`/${PLUGIN_DLL_NAME.toLowerCase()}`)) {
11427
+ if (isPluginDllZipEntry(name2)) {
11179
11428
  dllBytes = content;
11180
11429
  break;
11181
11430
  }
11182
11431
  }
11183
11432
  if (!dllBytes) {
11184
- throw new Error(`Archive did not contain ${PLUGIN_DLL_NAME}.`);
11433
+ throw new PluginAssetIntegrityError(`Archive did not contain ${PLUGIN_DLL_NAME}.`);
11185
11434
  }
11186
11435
  } else {
11187
- const isPe = bytes[0] === 77 && bytes[1] === 90;
11188
- if (!isPe) {
11189
- throw new Error(`Artifact is neither a PE DLL nor a ZIP archive containing ${PLUGIN_DLL_NAME}.`);
11190
- }
11191
11436
  dllBytes = bytes;
11192
11437
  }
11438
+ return verifyExtractedDllBytes(dllBytes, expectedSha256);
11439
+ }
11440
+ function verifyExtractedDllBytes(dllBytes, expectedSha256) {
11441
+ if (dllBytes.length < 2 || dllBytes[0] !== 77 || dllBytes[1] !== 90) {
11442
+ throw new PluginAssetIntegrityError(`Artifact is not a valid PE DLL (${PLUGIN_DLL_NAME}).`);
11443
+ }
11193
11444
  const actualSha256 = computeBufferSha256(dllBytes);
11194
11445
  const expectedList = normalizeExpectedShaList(expectedSha256);
11195
11446
  if (expectedList.length > 0 && !expectedList.includes(actualSha256)) {
11196
- throw new Error(
11447
+ throw new PluginAssetIntegrityError(
11197
11448
  `Plugin DLL SHA-256 mismatch. Expected ${expectedList.join(" or ")}, actual ${actualSha256}.`
11198
11449
  );
11199
11450
  }
11200
11451
  return { dllBytes, sha256: actualSha256 };
11201
11452
  }
11453
+ function matchSig4(bytes, pos, b0, b1, b2, b3) {
11454
+ return pos >= 0 && pos + 3 < bytes.length && bytes[pos] === b0 && bytes[pos + 1] === b1 && bytes[pos + 2] === b2 && bytes[pos + 3] === b3;
11455
+ }
11456
+ function parseEocdTail(tail, totalLength) {
11457
+ const minIdx = Math.max(0, tail.length - 65560);
11458
+ let eocdPos = -1;
11459
+ for (let i = tail.length - 4; i >= minIdx; i -= 1) {
11460
+ if (matchSig4(tail, i, 80, 75, 5, 6)) {
11461
+ eocdPos = i;
11462
+ break;
11463
+ }
11464
+ }
11465
+ if (eocdPos < 0 || eocdPos + 22 > tail.length) {
11466
+ return null;
11467
+ }
11468
+ const dv = new DataView(tail.buffer, tail.byteOffset, tail.byteLength);
11469
+ const cdSize = dv.getUint32(eocdPos + 12, true);
11470
+ const cdOffset = dv.getUint32(eocdPos + 16, true);
11471
+ if (cdSize !== 4294967295 && cdOffset !== 4294967295) {
11472
+ return { cdSize, cdOffset };
11473
+ }
11474
+ const locPos = eocdPos - 20;
11475
+ if (locPos < 0 || !matchSig4(tail, locPos, 80, 75, 6, 7)) {
11476
+ return null;
11477
+ }
11478
+ const eocd64Offset = Number(dv.getBigUint64(locPos + 8, true));
11479
+ if (!Number.isSafeInteger(eocd64Offset) || eocd64Offset < 0 || eocd64Offset + 56 > totalLength) {
11480
+ return null;
11481
+ }
11482
+ return { cdSize, cdOffset, eocd64Offset };
11483
+ }
11484
+ function parseEocd64Header(buf) {
11485
+ if (buf.length < 56 || !matchSig4(buf, 0, 80, 75, 6, 6)) {
11486
+ return null;
11487
+ }
11488
+ const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
11489
+ const cdSize = Number(dv.getBigUint64(40, true));
11490
+ const cdOffset = Number(dv.getBigUint64(48, true));
11491
+ if (!Number.isSafeInteger(cdSize) || !Number.isSafeInteger(cdOffset)) {
11492
+ return null;
11493
+ }
11494
+ return { cdSize, cdOffset };
11495
+ }
11496
+ function findPluginEntryInCd(cd) {
11497
+ const dv = new DataView(cd.buffer, cd.byteOffset, cd.byteLength);
11498
+ let pos = 0;
11499
+ while (pos + 46 <= cd.length) {
11500
+ if (!matchSig4(cd, pos, 80, 75, 1, 2)) {
11501
+ break;
11502
+ }
11503
+ const compMethod = dv.getUint16(pos + 10, true);
11504
+ let compSize = dv.getUint32(pos + 20, true);
11505
+ let uncompSize = dv.getUint32(pos + 24, true);
11506
+ const fileNameLength = dv.getUint16(pos + 28, true);
11507
+ const extraLength = dv.getUint16(pos + 30, true);
11508
+ const commentLength = dv.getUint16(pos + 32, true);
11509
+ let localHeaderOffset = dv.getUint32(pos + 42, true);
11510
+ const entryEnd = pos + 46 + fileNameLength + extraLength + commentLength;
11511
+ if (entryEnd > cd.length) {
11512
+ break;
11513
+ }
11514
+ const name2 = Buffer.from(cd.buffer, cd.byteOffset + pos + 46, fileNameLength).toString("utf8");
11515
+ if (isPluginDllZipEntry(name2)) {
11516
+ if (uncompSize === 4294967295 || compSize === 4294967295 || localHeaderOffset === 4294967295) {
11517
+ let extraPos = pos + 46 + fileNameLength;
11518
+ const extraEnd = extraPos + extraLength;
11519
+ while (extraPos + 4 <= extraEnd) {
11520
+ const headerId = dv.getUint16(extraPos, true);
11521
+ const fieldSize = dv.getUint16(extraPos + 2, true);
11522
+ const fieldData = extraPos + 4;
11523
+ if (fieldData + fieldSize > extraEnd) break;
11524
+ if (headerId === 1) {
11525
+ let cursor = fieldData;
11526
+ if (uncompSize === 4294967295 && cursor + 8 <= fieldData + fieldSize) {
11527
+ uncompSize = Number(dv.getBigUint64(cursor, true));
11528
+ cursor += 8;
11529
+ }
11530
+ if (compSize === 4294967295 && cursor + 8 <= fieldData + fieldSize) {
11531
+ compSize = Number(dv.getBigUint64(cursor, true));
11532
+ cursor += 8;
11533
+ }
11534
+ if (localHeaderOffset === 4294967295 && cursor + 8 <= fieldData + fieldSize) {
11535
+ localHeaderOffset = Number(dv.getBigUint64(cursor, true));
11536
+ }
11537
+ break;
11538
+ }
11539
+ extraPos = fieldData + fieldSize;
11540
+ }
11541
+ }
11542
+ return { compMethod, compSize, uncompSize, fileNameLength, localHeaderOffset };
11543
+ }
11544
+ pos = entryEnd;
11545
+ }
11546
+ return null;
11547
+ }
11548
+ function decodePluginLocalEntry(localChunk, entry) {
11549
+ if (entry.compSize < 0 || entry.compSize > MAX_DLL_BYTES || entry.uncompSize > MAX_DLL_BYTES) {
11550
+ throw new PluginAssetIntegrityError(`ZIP entry size exceeds allowed limit (${MAX_DLL_BYTES} bytes).`);
11551
+ }
11552
+ if (localChunk.length < 30 || !matchSig4(localChunk, 0, 80, 75, 3, 4)) {
11553
+ throw new PluginAssetIntegrityError("Invalid ZIP local file header.");
11554
+ }
11555
+ const dv = new DataView(localChunk.buffer, localChunk.byteOffset, localChunk.byteLength);
11556
+ const lhNameLen = dv.getUint16(26, true);
11557
+ const lhExtraLen = dv.getUint16(28, true);
11558
+ const dataOffset = 30 + lhNameLen + lhExtraLen;
11559
+ const neededLength = dataOffset + entry.compSize;
11560
+ if (neededLength > localChunk.length) {
11561
+ return { ok: false, neededLength };
11562
+ }
11563
+ const payload = localChunk.subarray(dataOffset, neededLength);
11564
+ if (entry.compMethod === 0) {
11565
+ return { ok: true, dllBytes: Uint8Array.from(payload) };
11566
+ }
11567
+ if (entry.compMethod === 8) {
11568
+ return { ok: true, dllBytes: new Uint8Array(inflateRawSync(payload, { maxOutputLength: MAX_DLL_BYTES })) };
11569
+ }
11570
+ throw new PluginAssetIntegrityError(`Unsupported ZIP compression method: ${entry.compMethod}.`);
11571
+ }
11572
+ function readFdSlice(fd, start, endInclusive) {
11573
+ const length = Math.max(0, endInclusive - start + 1);
11574
+ const buf = Buffer.allocUnsafe(length);
11575
+ let totalRead = 0;
11576
+ while (totalRead < length) {
11577
+ const n = readSync(fd, buf, totalRead, length - totalRead, start + totalRead);
11578
+ if (n <= 0) break;
11579
+ totalRead += n;
11580
+ }
11581
+ return totalRead === length ? new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength) : new Uint8Array(buf.subarray(0, totalRead));
11582
+ }
11583
+ function tryExtractPluginFromLocalZipFast(filePath, expectedSha256) {
11584
+ const stats = statSync2(filePath);
11585
+ if (stats.size <= 22 || stats.size > MAX_ZIP_INSPECT_BYTES) {
11586
+ return null;
11587
+ }
11588
+ const fd = openSync(filePath, "r");
11589
+ try {
11590
+ const tailSize = Math.min(65536, stats.size);
11591
+ const tailStart = stats.size - tailSize;
11592
+ const tail = readFdSlice(fd, tailStart, stats.size - 1);
11593
+ const eocd = parseEocdTail(tail, stats.size);
11594
+ if (!eocd) return null;
11595
+ let cdSize = eocd.cdSize;
11596
+ let cdOffset = eocd.cdOffset;
11597
+ if (eocd.eocd64Offset !== void 0) {
11598
+ const eocd64 = parseEocd64Header(readFdSlice(fd, eocd.eocd64Offset, eocd.eocd64Offset + 55));
11599
+ if (!eocd64) return null;
11600
+ cdSize = eocd64.cdSize;
11601
+ cdOffset = eocd64.cdOffset;
11602
+ }
11603
+ if (cdSize <= 0 || cdSize > 32 * 1024 * 1024 || cdOffset < 0 || cdOffset + cdSize > stats.size) {
11604
+ return null;
11605
+ }
11606
+ const cd = cdOffset >= tailStart && cdOffset + cdSize <= stats.size ? tail.subarray(cdOffset - tailStart, cdOffset - tailStart + cdSize) : readFdSlice(fd, cdOffset, cdOffset + cdSize - 1);
11607
+ const entry = findPluginEntryInCd(cd);
11608
+ if (!entry) {
11609
+ throw new PluginAssetIntegrityError(`Archive did not contain ${PLUGIN_DLL_NAME}.`);
11610
+ }
11611
+ if (entry.compSize <= 0 || entry.compSize > 50 * 1024 * 1024) {
11612
+ return null;
11613
+ }
11614
+ const probeEnd = Math.min(stats.size - 1, entry.localHeaderOffset + 30 + entry.fileNameLength + 1024 + entry.compSize - 1);
11615
+ let localChunk = readFdSlice(fd, entry.localHeaderOffset, probeEnd);
11616
+ let decoded = decodePluginLocalEntry(localChunk, entry);
11617
+ if (!decoded.ok) {
11618
+ const exactEnd = entry.localHeaderOffset + decoded.neededLength - 1;
11619
+ if (exactEnd >= stats.size) return null;
11620
+ localChunk = readFdSlice(fd, entry.localHeaderOffset, exactEnd);
11621
+ decoded = decodePluginLocalEntry(localChunk, entry);
11622
+ if (!decoded.ok) return null;
11623
+ }
11624
+ return verifyExtractedDllBytes(decoded.dllBytes, expectedSha256);
11625
+ } finally {
11626
+ closeSync(fd);
11627
+ }
11628
+ }
11629
+ async function downloadPluginDllViaHttpRange(parsedUrl, acceptedShas, fetchFn, timeoutMs) {
11630
+ const { response: headRes, finalUrl } = await fetchFollowingValidatedRedirects(
11631
+ parsedUrl,
11632
+ { method: "HEAD" },
11633
+ fetchFn,
11634
+ timeoutMs
11635
+ );
11636
+ await headRes.body?.cancel?.().catch(() => {
11637
+ });
11638
+ if (!headRes.ok) {
11639
+ return null;
11640
+ }
11641
+ const contentLength = Number.parseInt(headRes.headers.get("content-length") ?? "", 10);
11642
+ const acceptRanges = headRes.headers.get("accept-ranges") ?? "";
11643
+ if (!Number.isFinite(contentLength) || contentLength <= 22 || !/\bbytes\b/iu.test(acceptRanges)) {
11644
+ return null;
11645
+ }
11646
+ const fetchRange = async (start, endInclusive) => {
11647
+ const { response: res } = await fetchFollowingValidatedRedirects(
11648
+ finalUrl,
11649
+ {
11650
+ method: "GET",
11651
+ headers: {
11652
+ Range: `bytes=${start}-${endInclusive}`,
11653
+ "Accept-Encoding": "identity"
11654
+ }
11655
+ },
11656
+ fetchFn,
11657
+ timeoutMs
11658
+ );
11659
+ if (res.status !== 206) {
11660
+ await res.body?.cancel?.().catch(() => {
11661
+ });
11662
+ return null;
11663
+ }
11664
+ return readResponseBytesBounded(res, Math.min(MAX_ZIP_INSPECT_BYTES, endInclusive - start + 1 + 1024));
11665
+ };
11666
+ const tailSize = Math.min(65536, contentLength);
11667
+ const tailStart = contentLength - tailSize;
11668
+ const tail = await fetchRange(tailStart, contentLength - 1);
11669
+ if (!tail) return null;
11670
+ const eocd = parseEocdTail(tail, contentLength);
11671
+ if (!eocd) return null;
11672
+ let cdSize = eocd.cdSize;
11673
+ let cdOffset = eocd.cdOffset;
11674
+ if (eocd.eocd64Offset !== void 0) {
11675
+ const eocd64Slice = await fetchRange(eocd.eocd64Offset, Math.min(contentLength - 1, eocd.eocd64Offset + 55));
11676
+ if (!eocd64Slice) return null;
11677
+ const eocd64 = parseEocd64Header(eocd64Slice);
11678
+ if (!eocd64) return null;
11679
+ cdSize = eocd64.cdSize;
11680
+ cdOffset = eocd64.cdOffset;
11681
+ }
11682
+ if (cdSize <= 0 || cdSize > 32 * 1024 * 1024 || cdOffset < 0 || cdOffset + cdSize > contentLength) {
11683
+ return null;
11684
+ }
11685
+ const cd = cdOffset >= tailStart && cdOffset + cdSize <= contentLength ? tail.subarray(cdOffset - tailStart, cdOffset - tailStart + cdSize) : await fetchRange(cdOffset, cdOffset + cdSize - 1);
11686
+ if (!cd) return null;
11687
+ const entry = findPluginEntryInCd(cd);
11688
+ if (!entry) {
11689
+ throw new PluginAssetIntegrityError(`Archive did not contain ${PLUGIN_DLL_NAME}.`);
11690
+ }
11691
+ if (entry.compSize <= 0 || entry.compSize > 50 * 1024 * 1024) {
11692
+ return null;
11693
+ }
11694
+ const probeEnd = Math.min(
11695
+ contentLength - 1,
11696
+ entry.localHeaderOffset + 30 + entry.fileNameLength + 1024 + entry.compSize - 1
11697
+ );
11698
+ let localChunk = await fetchRange(entry.localHeaderOffset, probeEnd);
11699
+ if (!localChunk) return null;
11700
+ let decoded = decodePluginLocalEntry(localChunk, entry);
11701
+ if (!decoded.ok) {
11702
+ const exactEnd = entry.localHeaderOffset + decoded.neededLength - 1;
11703
+ if (exactEnd >= contentLength) return null;
11704
+ localChunk = await fetchRange(entry.localHeaderOffset, exactEnd);
11705
+ if (!localChunk) return null;
11706
+ decoded = decodePluginLocalEntry(localChunk, entry);
11707
+ if (!decoded.ok) return null;
11708
+ }
11709
+ return verifyExtractedDllBytes(decoded.dllBytes, acceptedShas);
11710
+ }
11711
+ async function tryDownloadViaWindowsHelper(options) {
11712
+ if (process.platform !== "win32") {
11713
+ return null;
11714
+ }
11715
+ let helperPath = options.helperExecutablePath ?? null;
11716
+ if (!helperPath) {
11717
+ try {
11718
+ helperPath = ensureRunnableHelperBinary({
11719
+ dataDir: options.dataDir,
11720
+ ...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot }
11721
+ });
11722
+ } catch {
11723
+ helperPath = null;
11724
+ }
11725
+ }
11726
+ if (!helperPath || !existsSync4(helperPath)) {
11727
+ return null;
11728
+ }
11729
+ const tmpDir = join5(options.dataDir, "tmp");
11730
+ mkdirSync3(tmpDir, { recursive: true });
11731
+ const tempOut = join5(tmpDir, `fetch-dll-${randomUUID4()}.dll`);
11732
+ try {
11733
+ const { stdout } = await execFileAsync(
11734
+ helperPath,
11735
+ [
11736
+ "--fetch-plugin-dll",
11737
+ "--url",
11738
+ options.url,
11739
+ "--out",
11740
+ tempOut,
11741
+ ...options.acceptedShas.length > 0 ? ["--sha256", options.acceptedShas.join(",")] : []
11742
+ ],
11743
+ {
11744
+ encoding: "utf8",
11745
+ windowsHide: true,
11746
+ timeout: Math.max(options.timeoutMs, 45e3)
11747
+ }
11748
+ );
11749
+ const line = stdout.trim().split(/\r?\n/u).pop() ?? "";
11750
+ if (line.startsWith("{")) {
11751
+ const parsed = JSON.parse(line);
11752
+ if (parsed.ok === false) {
11753
+ if (parsed.error && /SHA-256 mismatch|Archive did not contain|not a valid/iu.test(parsed.error)) {
11754
+ throw new PluginAssetIntegrityError(parsed.error);
11755
+ }
11756
+ throw new Error(parsed.error || "Windows helper asset fetch failed.");
11757
+ }
11758
+ }
11759
+ if (!existsSync4(tempOut)) {
11760
+ throw new Error("Windows helper fetch completed without output file.");
11761
+ }
11762
+ const dllBytes = new Uint8Array(readFileSync5(tempOut));
11763
+ return verifyExtractedDllBytes(dllBytes, options.acceptedShas);
11764
+ } finally {
11765
+ if (existsSync4(tempOut)) {
11766
+ rmSync2(tempOut, { force: true });
11767
+ }
11768
+ }
11769
+ }
11202
11770
  function defaultDiscoveryCandidates() {
11203
11771
  const results = [];
11204
11772
  if (process.env.LOCALAPPDATA) {
@@ -11223,35 +11791,41 @@ function getPluginAssetCachePath(dataDir, version = DEFAULT_PLUGIN_DLL_MANIFEST.
11223
11791
  function writeAtomicCacheDll(cachePath, dllBytes) {
11224
11792
  mkdirSync3(dirname4(cachePath), { recursive: true });
11225
11793
  const temp = `${cachePath}.${randomUUID4()}.tmp`;
11226
- writeFileSync3(temp, dllBytes);
11227
- renameSync2(temp, cachePath);
11794
+ try {
11795
+ writeFileSync3(temp, dllBytes);
11796
+ renameSync2(temp, cachePath);
11797
+ } catch (error) {
11798
+ rmSync2(temp, { force: true });
11799
+ throw error;
11800
+ }
11801
+ }
11802
+ function readHeadTwoBytes(filePath) {
11803
+ const fd = openSync(filePath, "r");
11804
+ try {
11805
+ const buf = Buffer.allocUnsafe(2);
11806
+ const n = readSync(fd, buf, 0, 2, 0);
11807
+ if (n < 2) return null;
11808
+ return [buf[0] ?? 0, buf[1] ?? 0];
11809
+ } finally {
11810
+ closeSync(fd);
11811
+ }
11228
11812
  }
11229
- function inspectCandidateFile(filePath, source, acceptedShas, maxZipHashBytes) {
11813
+ function extractFromLocalZip(filePath, expectedSha256) {
11814
+ const fast = tryExtractPluginFromLocalZipFast(filePath, expectedSha256);
11815
+ if (fast) return fast;
11816
+ return extractPluginDllFromBytes(readFileSync5(filePath), expectedSha256);
11817
+ }
11818
+ function inspectCandidateFile(filePath, source, acceptedShas) {
11230
11819
  try {
11231
11820
  const resolved = resolve3(filePath);
11232
11821
  if (!existsSync4(resolved)) return null;
11233
11822
  const stats = statSync2(resolved);
11234
- if (!stats.isFile()) return null;
11235
- const lower = resolved.toLowerCase();
11236
- let isZip = lower.endsWith(".zip");
11237
- if (!isZip && stats.size >= 2) {
11238
- const head = readFileSync5(resolved).subarray(0, 2);
11239
- isZip = head[0] === 80 && head[1] === 75;
11240
- }
11823
+ if (!stats.isFile() || stats.size < 2) return null;
11824
+ const head = readHeadTwoBytes(resolved);
11825
+ const isZip = resolved.toLowerCase().endsWith(".zip") || head !== null && head[0] === 80 && head[1] === 75;
11241
11826
  if (isZip) {
11242
11827
  if (stats.size > MAX_ZIP_INSPECT_BYTES) return null;
11243
- if (stats.size > maxZipHashBytes) {
11244
- return {
11245
- path: resolved,
11246
- kind: "zip",
11247
- source,
11248
- sha256: "",
11249
- sha256MatchesExpected: false,
11250
- sizeBytes: stats.size
11251
- };
11252
- }
11253
- const bytes2 = readFileSync5(resolved);
11254
- const { sha256: sha2562 } = extractPluginDllFromBytes(bytes2);
11828
+ const { sha256: sha2562 } = extractFromLocalZip(resolved);
11255
11829
  return {
11256
11830
  path: resolved,
11257
11831
  kind: "zip",
@@ -11261,10 +11835,10 @@ function inspectCandidateFile(filePath, source, acceptedShas, maxZipHashBytes) {
11261
11835
  sizeBytes: stats.size
11262
11836
  };
11263
11837
  }
11264
- const bytes = readFileSync5(resolved);
11265
- if (bytes.length < 2 || bytes[0] !== 77 || bytes[1] !== 90) {
11838
+ if (head === null || head[0] !== 77 || head[1] !== 90) {
11266
11839
  return null;
11267
11840
  }
11841
+ const bytes = readFileSync5(resolved);
11268
11842
  const sha256 = computeBufferSha256(bytes);
11269
11843
  return {
11270
11844
  path: resolved,
@@ -11293,16 +11867,16 @@ function discoverLocalPluginDllCandidates(options = {}) {
11293
11867
  };
11294
11868
  const explicitPath = (options.dllPath ?? process.env.MEMOQ_PLUGIN_DLL_PATH ?? "").trim();
11295
11869
  if (explicitPath) {
11296
- pushCandidate(inspectCandidateFile(explicitPath, "explicit", acceptedShas, MAX_ZIP_INSPECT_BYTES));
11870
+ pushCandidate(inspectCandidateFile(explicitPath, "explicit", acceptedShas));
11297
11871
  }
11298
11872
  const cachePath = getPluginAssetCachePath(dataDir, version);
11299
- pushCandidate(inspectCandidateFile(cachePath, "cache", acceptedShas, MAX_FAST_ZIP_HASH_BYTES));
11873
+ pushCandidate(inspectCandidateFile(cachePath, "cache", acceptedShas));
11300
11874
  for (const hubCandidate of defaultDiscoveryCandidates()) {
11301
- pushCandidate(inspectCandidateFile(hubCandidate, "memoq-ai-hub", acceptedShas, MAX_FAST_ZIP_HASH_BYTES));
11875
+ pushCandidate(inspectCandidateFile(hubCandidate, "memoq-ai-hub", acceptedShas));
11302
11876
  }
11303
11877
  for (const extra of options.extraFilePaths ?? []) {
11304
11878
  if (!extra?.trim()) continue;
11305
- pushCandidate(inspectCandidateFile(extra, "memoq-addins", acceptedShas, MAX_FAST_ZIP_HASH_BYTES));
11879
+ pushCandidate(inspectCandidateFile(extra, "memoq-addins", acceptedShas));
11306
11880
  }
11307
11881
  const rawDirs = [...options.searchDirs ?? []];
11308
11882
  if (options.includeDefaultUserDirs !== false) {
@@ -11325,16 +11899,24 @@ function discoverLocalPluginDllCandidates(options = {}) {
11325
11899
  try {
11326
11900
  const entries = readdirSync(resolvedDir, { withFileTypes: true }).slice(0, MAX_DISCOVERY_DIR_ENTRIES);
11327
11901
  for (const entry of entries) {
11328
- if (!entry.isFile()) continue;
11329
- const lowerName = entry.name.toLowerCase();
11330
- if (lowerName === PLUGIN_DLL_NAME.toLowerCase()) {
11331
- pushCandidate(
11332
- inspectCandidateFile(join5(resolvedDir, entry.name), "local-folder", acceptedShas, MAX_FAST_ZIP_HASH_BYTES)
11333
- );
11334
- } else if (lowerName.endsWith(".zip") && ZIP_CANDIDATE_NAME_RE.test(entry.name)) {
11335
- pushCandidate(
11336
- inspectCandidateFile(join5(resolvedDir, entry.name), "local-folder", acceptedShas, MAX_FAST_ZIP_HASH_BYTES)
11337
- );
11902
+ if (entry.isFile()) {
11903
+ const lowerName = entry.name.toLowerCase();
11904
+ if (lowerName === PLUGIN_DLL_NAME.toLowerCase()) {
11905
+ pushCandidate(inspectCandidateFile(join5(resolvedDir, entry.name), "local-folder", acceptedShas));
11906
+ } else if (lowerName.endsWith(".zip") && ZIP_CANDIDATE_NAME_RE.test(entry.name)) {
11907
+ pushCandidate(inspectCandidateFile(join5(resolvedDir, entry.name), "local-folder", acceptedShas));
11908
+ }
11909
+ continue;
11910
+ }
11911
+ if (entry.isDirectory() && /memoq/iu.test(entry.name)) {
11912
+ const subDir = join5(resolvedDir, entry.name);
11913
+ for (const rel of [
11914
+ PLUGIN_DLL_NAME,
11915
+ join5("resources", PLUGIN_DLL_NAME),
11916
+ join5("resources", "memoq-integration", PLUGIN_DLL_NAME)
11917
+ ]) {
11918
+ pushCandidate(inspectCandidateFile(join5(subDir, rel), "local-folder", acceptedShas));
11919
+ }
11338
11920
  }
11339
11921
  }
11340
11922
  } catch {
@@ -11358,81 +11940,83 @@ async function resolvePluginDllAsset(options = {}) {
11358
11940
  if (!existsSync4(resolved)) {
11359
11941
  throw new Error(`Configured MEMOQ_PLUGIN_DLL_PATH does not exist: ${resolved}`);
11360
11942
  }
11361
- const rawBytes2 = readFileSync5(resolved);
11362
- const isZip = rawBytes2.length >= 2 && rawBytes2[0] === 80 && rawBytes2[1] === 75;
11943
+ const head = readHeadTwoBytes(resolved);
11944
+ const isZip = resolved.toLowerCase().endsWith(".zip") || head !== null && head[0] === 80 && head[1] === 75;
11363
11945
  if (isZip) {
11364
- const extracted = extractPluginDllFromBytes(
11365
- rawBytes2,
11946
+ const extracted2 = extractFromLocalZip(
11947
+ resolved,
11366
11948
  options.allowUnverifiedLocalDev ? void 0 : acceptedShas
11367
11949
  );
11368
- writeAtomicCacheDll(cachePath, extracted.dllBytes);
11950
+ writeAtomicCacheDll(cachePath, extracted2.dllBytes);
11369
11951
  return {
11370
11952
  path: cachePath,
11371
- sha256: extracted.sha256,
11953
+ sha256: extracted2.sha256,
11372
11954
  version,
11373
11955
  source: "explicit",
11374
- verified: acceptedShas.includes(extracted.sha256)
11956
+ verified: acceptedShas.includes(extracted2.sha256)
11375
11957
  };
11376
11958
  }
11377
- const isPe = rawBytes2.length >= 2 && rawBytes2[0] === 77 && rawBytes2[1] === 90;
11378
- if (!isPe) {
11959
+ if (head === null || head[0] !== 77 || head[1] !== 90) {
11379
11960
  throw new Error(`File is neither a PE DLL nor a ZIP archive containing ${PLUGIN_DLL_NAME}: ${resolved}`);
11380
11961
  }
11381
- const sha2562 = computeBufferSha256(rawBytes2);
11382
- const verified = acceptedShas.includes(sha2562);
11962
+ const rawBytes = readFileSync5(resolved);
11963
+ const sha256 = computeBufferSha256(rawBytes);
11964
+ const verified = acceptedShas.includes(sha256);
11383
11965
  if (!options.allowUnverifiedLocalDev && acceptedShas.length > 0 && !verified) {
11384
- throw new Error(`Plugin DLL SHA-256 mismatch at ${resolved}. Expected ${expectedDisplay}, actual ${sha2562}.`);
11966
+ throw new Error(`Plugin DLL SHA-256 mismatch at ${resolved}. Expected ${expectedDisplay}, actual ${sha256}.`);
11385
11967
  }
11386
11968
  return {
11387
11969
  path: resolved,
11388
- sha256: sha2562,
11970
+ sha256,
11389
11971
  version,
11390
11972
  source: "explicit",
11391
11973
  verified
11392
11974
  };
11393
11975
  }
11394
11976
  if (existsSync4(cachePath)) {
11395
- const sha2562 = computeFileSha256(cachePath);
11396
- if (acceptedShas.length === 0 || acceptedShas.includes(sha2562)) {
11977
+ const sha256 = computeFileSha256(cachePath);
11978
+ if (acceptedShas.length === 0 || acceptedShas.includes(sha256)) {
11397
11979
  return {
11398
11980
  path: cachePath,
11399
- sha256: sha2562,
11981
+ sha256,
11400
11982
  version,
11401
11983
  source: "cache",
11402
- verified: acceptedShas.includes(sha2562)
11984
+ verified: acceptedShas.includes(sha256)
11403
11985
  };
11404
11986
  }
11405
11987
  }
11406
11988
  const discoveryPaths = [...options.searchPaths ?? [], ...defaultDiscoveryCandidates()];
11407
11989
  for (const candidate of discoveryPaths) {
11408
11990
  if (!candidate || !existsSync4(candidate)) continue;
11409
- const rawBytes2 = readFileSync5(candidate);
11410
- const isZip = rawBytes2.length >= 2 && rawBytes2[0] === 80 && rawBytes2[1] === 75;
11411
- if (isZip) {
11412
- try {
11413
- const extracted = extractPluginDllFromBytes(rawBytes2, acceptedShas);
11414
- writeAtomicCacheDll(cachePath, extracted.dllBytes);
11991
+ try {
11992
+ const head = readHeadTwoBytes(candidate);
11993
+ const isZip = candidate.toLowerCase().endsWith(".zip") || head !== null && head[0] === 80 && head[1] === 75;
11994
+ if (isZip) {
11995
+ const extracted2 = extractFromLocalZip(candidate, acceptedShas);
11996
+ writeAtomicCacheDll(cachePath, extracted2.dllBytes);
11415
11997
  return {
11416
11998
  path: cachePath,
11417
- sha256: extracted.sha256,
11999
+ sha256: extracted2.sha256,
11418
12000
  version,
11419
12001
  source: "local-discovery",
11420
12002
  verified: true
11421
12003
  };
11422
- } catch {
11423
- continue;
11424
12004
  }
12005
+ if (head === null || head[0] !== 77 || head[1] !== 90) continue;
12006
+ const rawBytes = readFileSync5(candidate);
12007
+ const sha256 = computeBufferSha256(rawBytes);
12008
+ if (acceptedShas.length > 0 && !acceptedShas.includes(sha256)) continue;
12009
+ writeAtomicCacheDll(cachePath, rawBytes);
12010
+ return {
12011
+ path: cachePath,
12012
+ sha256,
12013
+ version,
12014
+ source: "local-discovery",
12015
+ verified: true
12016
+ };
12017
+ } catch {
12018
+ continue;
11425
12019
  }
11426
- const sha2562 = computeBufferSha256(rawBytes2);
11427
- if (acceptedShas.length > 0 && !acceptedShas.includes(sha2562)) continue;
11428
- writeAtomicCacheDll(cachePath, rawBytes2);
11429
- return {
11430
- path: cachePath,
11431
- sha256: sha2562,
11432
- version,
11433
- source: "local-discovery",
11434
- verified: true
11435
- };
11436
12020
  }
11437
12021
  if (options.searchDirs && options.searchDirs.length > 0 || options.includeDefaultUserDirs === true) {
11438
12022
  const folderCandidates = discoverLocalPluginDllCandidates({
@@ -11444,24 +12028,24 @@ async function resolvePluginDllAsset(options = {}) {
11444
12028
  });
11445
12029
  for (const candidate of folderCandidates) {
11446
12030
  try {
11447
- const rawBytes2 = readFileSync5(candidate.path);
11448
12031
  if (candidate.kind === "zip") {
11449
- const extracted = extractPluginDllFromBytes(rawBytes2, acceptedShas);
11450
- writeAtomicCacheDll(cachePath, extracted.dllBytes);
12032
+ const extracted2 = extractFromLocalZip(candidate.path, acceptedShas);
12033
+ writeAtomicCacheDll(cachePath, extracted2.dllBytes);
11451
12034
  return {
11452
12035
  path: cachePath,
11453
- sha256: extracted.sha256,
12036
+ sha256: extracted2.sha256,
11454
12037
  version,
11455
12038
  source: "local-discovery",
11456
12039
  verified: true
11457
12040
  };
11458
12041
  }
11459
- const sha2562 = computeBufferSha256(rawBytes2);
11460
- if (acceptedShas.length > 0 && !acceptedShas.includes(sha2562)) continue;
11461
- writeAtomicCacheDll(cachePath, rawBytes2);
12042
+ const rawBytes = readFileSync5(candidate.path);
12043
+ const sha256 = computeBufferSha256(rawBytes);
12044
+ if (acceptedShas.length > 0 && !acceptedShas.includes(sha256)) continue;
12045
+ writeAtomicCacheDll(cachePath, rawBytes);
11462
12046
  return {
11463
12047
  path: cachePath,
11464
- sha256: sha2562,
12048
+ sha256,
11465
12049
  version,
11466
12050
  source: "local-discovery",
11467
12051
  verified: true
@@ -11479,30 +12063,78 @@ async function resolvePluginDllAsset(options = {}) {
11479
12063
  const rawUrl = (options.downloadUrl ?? process.env.MEMOQ_PLUGIN_DLL_URL ?? DEFAULT_PLUGIN_DLL_MANIFEST.downloadUrl).trim();
11480
12064
  const parsedUrl = parseAllowedAssetUrl(rawUrl);
11481
12065
  const fetchFn = options.fetchImpl ?? fetch;
11482
- const response = await fetchFn(parsedUrl, { redirect: "follow" });
11483
- if (!response.ok) {
11484
- throw new Error(`Failed to download ${PLUGIN_DLL_NAME} (${response.status} ${response.statusText}).`);
12066
+ const timeoutMs = options.timeoutMs ?? DEFAULT_DOWNLOAD_TIMEOUT_MS;
12067
+ let extracted = null;
12068
+ let primaryError = null;
12069
+ try {
12070
+ extracted = await downloadPluginDllViaHttpRange(parsedUrl, acceptedShas, fetchFn, timeoutMs);
12071
+ if (!extracted) {
12072
+ const { response } = await fetchFollowingValidatedRedirects(parsedUrl, { method: "GET" }, fetchFn, timeoutMs);
12073
+ if (!response.ok) {
12074
+ await response.body?.cancel?.().catch(() => {
12075
+ });
12076
+ throw new Error(`Failed to download ${PLUGIN_DLL_NAME} (${response.status} ${response.statusText}).`);
12077
+ }
12078
+ const rawBytes = await readResponseBytesBounded(response, MAX_ZIP_INSPECT_BYTES);
12079
+ extracted = extractPluginDllFromBytes(rawBytes, acceptedShas);
12080
+ }
12081
+ } catch (error) {
12082
+ if (error instanceof PluginAssetIntegrityError || error instanceof PluginAssetPolicyError) {
12083
+ throw error;
12084
+ }
12085
+ primaryError = error instanceof Error ? error : new Error(String(error));
11485
12086
  }
11486
- const rawBytes = new Uint8Array(await response.arrayBuffer());
11487
- const { dllBytes, sha256 } = extractPluginDllFromBytes(rawBytes, acceptedShas);
11488
- writeAtomicCacheDll(cachePath, dllBytes);
12087
+ if (!extracted && options.fetchImpl === void 0 && process.platform === "win32") {
12088
+ try {
12089
+ extracted = await tryDownloadViaWindowsHelper({
12090
+ url: parsedUrl.href,
12091
+ acceptedShas,
12092
+ dataDir,
12093
+ ...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
12094
+ ...options.helperExecutablePath === void 0 ? {} : { helperExecutablePath: options.helperExecutablePath },
12095
+ timeoutMs
12096
+ });
12097
+ } catch (helperError) {
12098
+ if (helperError instanceof PluginAssetIntegrityError || helperError instanceof PluginAssetPolicyError) {
12099
+ throw helperError;
12100
+ }
12101
+ const helperMsg = helperError instanceof Error ? helperError.message : String(helperError);
12102
+ const primaryMsg = primaryError?.message ?? "unknown fetch failure";
12103
+ throw new Error(
12104
+ `Unable to download ${PLUGIN_DLL_NAME} from ${parsedUrl.href}. Node fetch error: ${primaryMsg}. Windows system-proxy helper error: ${helperMsg}. Please check network/proxy access or pass a local dllPath / MEMOQ_PLUGIN_DLL_PATH.`
12105
+ );
12106
+ }
12107
+ }
12108
+ if (!extracted) {
12109
+ const primaryMsg = primaryError?.message ?? "unknown fetch failure";
12110
+ throw new Error(
12111
+ `Unable to download ${PLUGIN_DLL_NAME} from ${parsedUrl.href}: ${primaryMsg}. Please check network/proxy access or pass a local dllPath / MEMOQ_PLUGIN_DLL_PATH.`
12112
+ );
12113
+ }
12114
+ writeAtomicCacheDll(cachePath, extracted.dllBytes);
11489
12115
  return {
11490
12116
  path: cachePath,
11491
- sha256,
12117
+ sha256: extracted.sha256,
11492
12118
  version,
11493
12119
  source: "downloaded",
11494
- verified: acceptedShas.includes(sha256)
12120
+ verified: acceptedShas.includes(extracted.sha256)
11495
12121
  };
11496
12122
  }
11497
12123
 
11498
12124
  // packages/memoq-bridge/src/dll-installer.ts
11499
- import { execFile, execFileSync } from "node:child_process";
12125
+ import { execFile as execFile2, execFileSync } from "node:child_process";
11500
12126
  import { randomUUID as randomUUID5 } from "node:crypto";
11501
- import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync6, rmSync as rmSync2 } from "node:fs";
12127
+ import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync6, rmSync as rmSync3 } from "node:fs";
11502
12128
  import { basename, join as join6, resolve as resolve4, win32 } from "node:path";
11503
- import { promisify } from "node:util";
11504
- var execFileAsync = promisify(execFile);
12129
+ import { promisify as promisify2 } from "node:util";
12130
+ var execFileAsync2 = promisify2(execFile2);
11505
12131
  var SUPPORTED_VERSIONS = ["12", "11", "10"];
12132
+ var MEMOQ_FIRST_TIME_RESOURCE_STEPS = [
12133
+ "\u5B8C\u5168\u5173\u95ED\u5E76\u91CD\u65B0\u542F\u52A8 memoQ\uFF08memoQ \u4EC5\u5728\u542F\u52A8\u65F6\u626B\u63CF Addins \u76EE\u5F55\u52A0\u8F7D\u65B0\u63D2\u4EF6\uFF09\u3002",
12134
+ "\u9996\u6B21\u4F7F\u7528\u9700\u5728 memoQ \u4E2D\u65B0\u5EFA MT \u8D44\u6E90\uFF1A\u6253\u5F00 Resource Console\uFF08\u8D44\u6E90\u63A7\u5236\u53F0\uFF09\u2192 MT settings \u2192 Create new\uFF08\u9009\u62E9 My Computer\uFF0C\u586B\u5199\u540D\u79F0\u5982 memoQ AI Hub / LangLink\uFF09\u3002",
12135
+ "\u7F16\u8F91\u65B0\u5EFA\u7684 MT \u8D44\u6E90\uFF1A\u52FE\u9009\u542F\u7528 memoQ AI Hub \u5E76\u70B9\u5F00\u8BBE\u7F6E\uFF08Options\uFF09\uFF0C\u786E\u8BA4 Gateway Base URL \u4E3A http://127.0.0.1:5271\u3001\u5DF2\u52FE\u9009 Enable Gateway\u3001Formatting Mode \u4FDD\u6301 BothFormattingAndTags\uFF1B\u540C\u65F6\u5728 MT \u8D44\u6E90\u9009\u9879\u4E2D\u542F\u7528 Pre-translation\u3001Match and Patch\u3001Send best fuzzy TM match \u4E0E Self-learning MT \u5E76\u4FDD\u5B58\u3002",
12136
+ "\u8BBE\u4E3A\u9ED8\u8BA4\u5E76\u542F\u7528\u5230\u5F53\u524D\u9879\u76EE\uFF1A\u5728 Options \u2192 Default resources \u2192 MT settings \u4E2D\u52FE\u9009\u8BE5\u8D44\u6E90\uFF08\u4F9B\u65B0\u9879\u76EE\u9ED8\u8BA4\u751F\u6548\uFF09\uFF1B\u5BF9\u4E8E\u5DF2\u7ECF\u521B\u5EFA\u7684\u9879\u76EE\uFF0C\u8FD8\u5FC5\u987B\u5728 Project home \u2192 Settings \u2192 MT settings \u4E2D\u52FE\u9009\u542F\u7528\u8BE5\u8D44\u6E90\uFF0C\u968F\u540E\u5373\u53EF\u5728 WorkBuddy \u653E\u884C\u8BD1\u6587\u540E\u901A\u8FC7 memoQ \u7684 Pre-translate \u5199\u5165\u3002"
12137
+ ];
11506
12138
  function defaultMemoQRooDirs() {
11507
12139
  return SUPPORTED_VERSIONS.map((version) => ({
11508
12140
  version,
@@ -11692,7 +12324,7 @@ function getIntegrationStatus(options = {}) {
11692
12324
  }
11693
12325
  async function runHelperCommand(helperPath, args, resultFile) {
11694
12326
  try {
11695
- const { stdout } = await execFileAsync(helperPath, args, {
12327
+ const { stdout } = await execFileAsync2(helperPath, args, {
11696
12328
  windowsHide: true,
11697
12329
  encoding: "utf8",
11698
12330
  timeout: 6e4
@@ -11723,7 +12355,7 @@ async function runHelperCommand(helperPath, args, resultFile) {
11723
12355
  throw new Error(err.stderr?.trim() || err.message || "Helper execution failed.");
11724
12356
  } finally {
11725
12357
  if (existsSync5(resultFile)) {
11726
- rmSync2(resultFile, { force: true });
12358
+ rmSync3(resultFile, { force: true });
11727
12359
  }
11728
12360
  }
11729
12361
  }
@@ -11873,6 +12505,7 @@ function buildPluginInstallPlan(options = {}) {
11873
12505
  selectedDllCandidate,
11874
12506
  willDownloadFromRelease,
11875
12507
  downloadUrl: DEFAULT_PLUGIN_DLL_MANIFEST.downloadUrl,
12508
+ firstTimeResourceSteps: [...MEMOQ_FIRST_TIME_RESOURCE_STEPS],
11876
12509
  plannedChanges: {
11877
12510
  sourceDllPath: selectedDllCandidate?.path ?? null,
11878
12511
  sourceKind: selectedDllCandidate ? selectedDllCandidate.kind : "release-download",
@@ -11917,6 +12550,8 @@ async function executeConfirmedPluginInstall(options = {}) {
11917
12550
  const siblingDllPaths = integrationBefore.installations.filter((item) => item.pluginInstalled).map((item) => item.pluginTarget);
11918
12551
  const sourceAsset = await resolvePluginDllAsset({
11919
12552
  ...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
12553
+ ...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
12554
+ ...options.helperExecutablePath === void 0 ? {} : { helperExecutablePath: options.helperExecutablePath },
11920
12555
  ...options.dllPath === void 0 ? {} : { dllPath: options.dllPath },
11921
12556
  ...options.downloadUrl === void 0 ? {} : { downloadUrl: options.downloadUrl },
11922
12557
  ...options.expectedSha256 === void 0 ? {} : { expectedSha256: options.expectedSha256 },
@@ -11965,10 +12600,7 @@ async function executeConfirmedPluginInstall(options = {}) {
11965
12600
  sourceAsset,
11966
12601
  result,
11967
12602
  integration: integrationAfter,
11968
- nextSteps: [
11969
- "\u5B8C\u5168\u5173\u95ED\u5E76\u91CD\u65B0\u542F\u52A8 memoQ\uFF08memoQ \u4EC5\u5728\u542F\u52A8\u65F6\u626B\u63CF Addins \u76EE\u5F55\uFF09\u3002",
11970
- "\u5728 memoQ \u4E2D\u6253\u5F00 Options \u2192 Default resources \u2192 MT settings\uFF0C\u52FE\u9009\u542F\u7528 memoQ AI Hub\uFF08\u7AEF\u53E3\u4FDD\u6301 5271\uFF09\u3002"
11971
- ]
12603
+ nextSteps: [...MEMOQ_FIRST_TIME_RESOURCE_STEPS]
11972
12604
  };
11973
12605
  }
11974
12606
  async function executeConfirmedPluginUninstall(options = {}) {
@@ -12029,7 +12661,7 @@ import { dirname as dirname5 } from "node:path";
12029
12661
 
12030
12662
  // packages/memoq-bridge/src/daemon.ts
12031
12663
  import { randomBytes as randomBytes2 } from "node:crypto";
12032
- import { chmodSync, existsSync as existsSync6, readFileSync as readFileSync7, rmSync as rmSync3 } from "node:fs";
12664
+ import { chmodSync, existsSync as existsSync6, readFileSync as readFileSync7, rmSync as rmSync4 } from "node:fs";
12033
12665
  import { join as join7 } from "node:path";
12034
12666
  async function probeGatewayPort(port = DEFAULT_PORT, host = DEFAULT_HOST, timeoutMs = 1500) {
12035
12667
  const url = `http://${host}:${port}`;
@@ -12127,7 +12759,7 @@ function removeDaemonRecord(expectedToken, dataDir = defaultBridgeDataDir()) {
12127
12759
  const current = readDaemonRecord(dataDir);
12128
12760
  if (current && current.controlToken !== expectedToken) return;
12129
12761
  }
12130
- rmSync3(path, { force: true });
12762
+ rmSync4(path, { force: true });
12131
12763
  }
12132
12764
  var BridgeHttpClient = class {
12133
12765
  baseUrl;
@@ -12290,6 +12922,7 @@ async function startBridgeRuntime(options = {}) {
12290
12922
  host,
12291
12923
  port: bindPort,
12292
12924
  mode: options.mode ?? "staging",
12925
+ ...options.toolName === void 0 ? {} : { toolName: options.toolName },
12293
12926
  ...options.version === void 0 ? {} : { desktopVersion: options.version },
12294
12927
  ...persistedReviewToken ? { reviewToken: persistedReviewToken } : {},
12295
12928
  stagingStore,
@@ -12369,16 +13002,19 @@ async function readJson(request) {
12369
13002
  if (!text) return {};
12370
13003
  return JSON.parse(text);
12371
13004
  }
12372
- function escapeHtml(text) {
13005
+ function escapeHtml2(text) {
12373
13006
  return text.replace(/&/gu, "&amp;").replace(/</gu, "&lt;").replace(/>/gu, "&gt;").replace(/"/gu, "&quot;");
12374
13007
  }
12375
- function renderSetupHtml(nonce, token, initialStatus) {
13008
+ function renderSetupHtml(nonce, token, initialStatus, toolLabel) {
12376
13009
  const payloadJson = JSON.stringify({ token, initialStatus }).replace(/</gu, "\\u003c");
13010
+ const generatorMeta = toolLabel ? `
13011
+ <meta name="generator" content="${escapeHtml2(toolLabel)}" />` : "";
13012
+ const toolBadge = toolLabel ? `<span id="setup-tool-version" style="margin-left:8px;font-family:ui-monospace,Consolas,monospace;font-size:12px;">\u5DE5\u5177\u7248\u672C\uFF1A${escapeHtml2(toolLabel)}</span>` : "";
12377
13013
  return `<!DOCTYPE html>
12378
13014
  <html lang="zh-CN">
12379
13015
  <head>
12380
13016
  <meta charset="utf-8" />
12381
- <meta name="viewport" content="width=device-width, initial-scale=1" />
13017
+ <meta name="viewport" content="width=device-width, initial-scale=1" />${generatorMeta}
12382
13018
  <title>LangLink memoQ \u8FDE\u63A5\u5668\u8BBE\u7F6E\u4E0E\u8BCA\u65AD</title>
12383
13019
  <style>
12384
13020
  :root { color-scheme: light dark; --bg: #f6f7f9; --card: #ffffff; --text: #111827; --muted: #4b5563; --border: #d1d5db; --accent: #1d4ed8; --ok: #15803d; --warn: #b45309; --err: #b91c1c; }
@@ -12413,7 +13049,7 @@ function renderSetupHtml(nonce, token, initialStatus) {
12413
13049
  <body>
12414
13050
  <main>
12415
13051
  <h1>LangLink memoQ \u8FDE\u63A5\u5668 \u2014 \u5B89\u88C5\u4E0E\u8BCA\u65AD\u5411\u5BFC</h1>
12416
- <p class="sub">\u900F\u660E\u5B89\u88C5 \xB7 \u96F6\u811A\u672C\u9ED1\u6846 \xB7 \u4EC5\u5728\u60A8\u70B9\u51FB\u6309\u94AE\u5E76\u786E\u8BA4\u7CFB\u7EDF UAC \u540E\u5199\u5165\u4E0B\u9762\u5217\u51FA\u7684\u4E24\u4E2A\u4F4D\u7F6E\u3002</p>
13052
+ <p class="sub">\u900F\u660E\u5B89\u88C5 \xB7 \u96F6\u811A\u672C\u9ED1\u6846 \xB7 \u4EC5\u5728\u60A8\u70B9\u51FB\u6309\u94AE\u5E76\u786E\u8BA4\u7CFB\u7EDF UAC \u540E\u5199\u5165\u4E0B\u9762\u5217\u51FA\u7684\u4E24\u4E2A\u4F4D\u7F6E\u3002${toolBadge}</p>
12417
13053
 
12418
13054
  <section class="card">
12419
13055
  <h2>1. \u5F53\u524D\u672C\u673A\u72B6\u6001</h2>
@@ -12441,11 +13077,11 @@ function renderSetupHtml(nonce, token, initialStatus) {
12441
13077
  <section class="card">
12442
13078
  <h2>3. \u900F\u660E\u53D8\u66F4\u6E05\u5355\uFF08\u70B9\u51FB\u5B89\u88C5\u524D\u8BF7\u786E\u8BA4\uFF09</h2>
12443
13079
  <ol>
12444
- <li>\u63D2\u4EF6\u6587\u4EF6\uFF1A<code>&lt;\u6240\u9009 memoQ \u6839\u76EE\u5F55&gt;\\Addins\\${escapeHtml(PLUGIN_DLL_NAME)}</code></li>
12445
- <li>\u5F00\u53D1\u914D\u7F6E\uFF1A<code>${escapeHtml(initialStatus.integration.clientDevConfig.path || "C:\\ProgramData\\MemoQ\\ClientDevConfig.xml")}</code>\uFF08\u82E5\u5DF2\u5B58\u5728\u5219\u5148\u5907\u4EFD <code>.bak</code> \u518D\u589E\u91CF\u5408\u5E76 <code>&lt;LoadUnsignedPlugins&gt;true&lt;/LoadUnsignedPlugins&gt;</code>\uFF09</li>
13080
+ <li>\u63D2\u4EF6\u6587\u4EF6\uFF1A<code>&lt;\u6240\u9009 memoQ \u6839\u76EE\u5F55&gt;\\Addins\\${escapeHtml2(PLUGIN_DLL_NAME)}</code></li>
13081
+ <li>\u5F00\u53D1\u914D\u7F6E\uFF1A<code>${escapeHtml2(initialStatus.integration.clientDevConfig.path || "C:\\ProgramData\\MemoQ\\ClientDevConfig.xml")}</code>\uFF08\u82E5\u5DF2\u5B58\u5728\u5219\u5148\u5907\u4EFD <code>.bak</code> \u518D\u589E\u91CF\u5408\u5E76 <code>&lt;LoadUnsignedPlugins&gt;true&lt;/LoadUnsignedPlugins&gt;</code>\uFF09</li>
12446
13082
  </ol>
12447
13083
  <div class="notice">
12448
- <div><strong>\u671F\u671B DLL \u7248\u672C\u4E0E\u6821\u9A8C\u503C\uFF1A</strong>v${escapeHtml(initialStatus.integration.expectedPluginVersion)} \xB7 SHA-256 <code>${escapeHtml(initialStatus.integration.expectedPluginSha256)}</code></div>
13084
+ <div><strong>\u671F\u671B DLL \u7248\u672C\u4E0E\u6821\u9A8C\u503C\uFF1A</strong>v${escapeHtml2(initialStatus.integration.expectedPluginVersion)} \xB7 SHA-256 <code>${escapeHtml2(initialStatus.integration.expectedPluginSha256)}</code></div>
12449
13085
  <div style="margin-top: 4px;"><strong>\u5B89\u5168\u627F\u8BFA\uFF1A</strong>\u4E0D\u4FEE\u6539 Windows \u6CE8\u518C\u8868 \xB7 \u4E0D\u6CE8\u518C\u5F00\u673A\u81EA\u542F\u670D\u52A1 \xB7 \u4E0D\u8BFB\u53D6\u60A8\u7684\u6A21\u578B\u5BC6\u94A5\u3002\u4F7F\u7528\u7EAF .NET \u539F\u751F\u62F7\u8D1D\u5E76\u81EA\u52A8\u6E05\u9664\u6587\u4EF6\u9501\u5B9A\u6807\u8BB0\uFF08MOTW\uFF09\u3002</div>
12450
13086
  </div>
12451
13087
  <div class="row">
@@ -12456,28 +13092,34 @@ function renderSetupHtml(nonce, token, initialStatus) {
12456
13092
  </section>
12457
13093
 
12458
13094
  <section class="card">
12459
- <h2>4. \u5B89\u88C5\u540E 2 \u6B65\u5B8C\u6210\u542F\u7528</h2>
13095
+ <h2>4. \u5B89\u88C5\u540E\u9996\u6B21\u914D\u7F6E\uFF08\u5728 memoQ \u4E2D\u6DFB\u52A0\u5E76\u542F\u7528 MT \u8D44\u6E90\uFF09</h2>
12460
13096
  <ol>
12461
- <li>\u5B8C\u5168\u5173\u95ED\u5E76\u91CD\u65B0\u542F\u52A8 <strong>memoQ</strong>\uFF08memoQ \u53EA\u5728\u542F\u52A8\u65F6\u626B\u63CF Addins \u76EE\u5F55\uFF09\u3002</li>
12462
- <li>\u5728 memoQ \u4E2D\u6253\u5F00 <strong>Options \u2192 Default resources \u2192 MT settings</strong>\uFF0C\u52FE\u9009\u542F\u7528 <strong>memoQ AI Hub</strong>\uFF08\u7AEF\u53E3\u4FDD\u6301\u9ED8\u8BA4 <code>5271</code>\uFF09\u3002</li>
13097
+ <li>\u5B8C\u5168\u5173\u95ED\u5E76\u91CD\u65B0\u542F\u52A8 <strong>memoQ</strong>\uFF08memoQ \u53EA\u5728\u542F\u52A8\u65F6\u626B\u63CF <code>Addins</code> \u76EE\u5F55\u52A0\u8F7D\u65B0\u63D2\u4EF6\uFF09\u3002</li>
13098
+ <li>\u9996\u6B21\u4F7F\u7528\u9700\u65B0\u5EFA MT \u8D44\u6E90\uFF1A\u6253\u5F00 <strong>Resource Console \u2192 MT settings \u2192 Create new</strong>\uFF08\u9009\u62E9 <strong>My Computer</strong>\uFF0C\u586B\u5199\u8D44\u6E90\u540D\u79F0\u5982 <code>memoQ AI Hub</code>\uFF09\uFF0C\u52FE\u9009\u542F\u7528 <strong>memoQ AI Hub</strong>\u3002</li>
13099
+ <li>\u70B9\u51FB\u8BE5\u8D44\u6E90\u8BBE\u7F6E\uFF08<strong>Options</strong>\uFF09\uFF0C\u786E\u8BA4 <strong>Gateway Base URL</strong> \u4E3A <code>http://127.0.0.1:5271</code>\u3001\u52FE\u9009 <strong>Enable Gateway</strong>\u3001<strong>Formatting Mode</strong> \u4E3A <code>BothFormattingAndTags</code>\uFF1B\u5E76\u5728\u8D44\u6E90\u529F\u80FD\u4E2D\u542F\u7528 <strong>Pre-translation</strong>\u3001<strong>Match and Patch</strong>\u3001<strong>Send best fuzzy TM match</strong> \u4E0E <strong>Self-learning MT</strong>\u3002</li>
13100
+ <li>\u5728 <strong>Options \u2192 Default resources \u2192 MT settings</strong> \u4E2D\u8BBE\u4E3A\u9ED8\u8BA4\uFF1B<strong>\u5BF9\u4E8E\u5DF2\u6709\u9879\u76EE</strong>\uFF0C\u8FD8\u5FC5\u987B\u6253\u5F00 <strong>Project home \u2192 Settings \u2192 MT settings</strong> \u52FE\u9009\u542F\u7528\u8BE5\u8D44\u6E90\uFF0C\u624D\u80FD\u4F7F\u7528 Pre-translate \u5199\u5165\u8BD1\u6587\u3002</li>
12463
13101
  </ol>
12464
13102
  <details style="margin-top: 12px;">
12465
13103
  <summary>\u4F01\u4E1A\u9650\u5236\u65E0\u6CD5 UAC \u63D0\u6743\uFF1F\u67E5\u770B\u624B\u52A8\u5B89\u88C5 3 \u6B65\u65B9\u6848</summary>
12466
13104
  <ol>
12467
- <li>\u70B9\u51FB\u4E0A\u65B9\u300C\u6253\u5F00\u672C\u5730\u63D2\u4EF6\u7F13\u5B58\u76EE\u5F55\u300D\uFF0C\u5982\u5C1A\u672A\u4E0B\u8F7D\u53EF\u5148\u4ECE GitHub Release \u4E0B\u8F7D <code>${escapeHtml(PLUGIN_DLL_NAME)}</code>\u3002</li>
13105
+ <li>\u70B9\u51FB\u4E0A\u65B9\u300C\u6253\u5F00\u672C\u5730\u63D2\u4EF6\u7F13\u5B58\u76EE\u5F55\u300D\uFF0C\u5982\u5C1A\u672A\u4E0B\u8F7D\u53EF\u5148\u4ECE GitHub Release \u4E0B\u8F7D <code>${escapeHtml2(PLUGIN_DLL_NAME)}</code>\u3002</li>
12468
13106
  <li>\u53F3\u952E DLL \u5C5E\u6027\u52FE\u9009\u300C\u89E3\u9664\u9501\u5B9A\u300D\uFF0C\u590D\u5236\u5230 memoQ \u5B89\u88C5\u76EE\u5F55\u4E0B\u7684 <code>Addins</code> \u6587\u4EF6\u5939\u3002</li>
12469
- <li>\u5728 <code>C:\\ProgramData\\MemoQ\\ClientDevConfig.xml</code> \u4E2D\u786E\u4FDD\u5305\u542B <code>&lt;ClientDevConfig&gt;&lt;LoadUnsignedPlugins&gt;true&lt;/LoadUnsignedPlugins&gt;&lt;/ClientDevConfig&gt;</code>\uFF0C\u7136\u540E\u91CD\u542F memoQ\u3002</li>
13107
+ <li>\u5728 <code>C:\\ProgramData\\MemoQ\\ClientDevConfig.xml</code> \u4E2D\u786E\u4FDD\u5305\u542B <code>&lt;ClientDevConfig&gt;&lt;LoadUnsignedPlugins&gt;true&lt;/LoadUnsignedPlugins&gt;&lt;/ClientDevConfig&gt;</code>\uFF0C\u91CD\u542F memoQ \u5E76\u6309\u4E0A\u65B9\u7B2C 2\u20134 \u6B65\u6DFB\u52A0 MT \u8D44\u6E90\u3002</li>
12470
13108
  </ol>
12471
13109
  </details>
12472
13110
  </section>
12473
13111
  </main>
12474
13112
 
12475
- <script nonce="${escapeHtml(nonce)}">
13113
+ <script nonce="${escapeHtml2(nonce)}">
12476
13114
  const BOOT = ${payloadJson};
12477
13115
  const token = BOOT.token;
12478
13116
  let currentState = BOOT.initialStatus;
12479
13117
  let selectedRoot = (currentState.integration.installations[0] && currentState.integration.installations[0].rootDir) || "";
12480
13118
 
13119
+ function esc(s) {
13120
+ return String(s).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
13121
+ }
13122
+
12481
13123
  function render(state) {
12482
13124
  currentState = state;
12483
13125
  const grid = document.getElementById("status-grid");
@@ -12517,8 +13159,8 @@ function renderSetupHtml(nonce, token, initialStatus) {
12517
13159
  const checked = item.rootDir === selectedRoot ? "checked" : "";
12518
13160
  const badge = item.status === "installed" ? "\u2705 \u5DF2\u5B89\u88C5" : item.status === "needs_repair" ? "\u26A0\uFE0F \u9700\u4FEE\u590D" : "\u672A\u5B89\u88C5";
12519
13161
  return '<label style="display:block;padding:8px 10px;border:1px solid var(--border);border-radius:6px;margin-bottom:8px;cursor:pointer;">'
12520
- + '<input type="radio" name="memoqRoot" value="' + item.rootDir.replace(/"/g, "&quot;") + '" ' + checked + ' data-idx="' + idx + '" /> '
12521
- + '<strong>' + item.label + '</strong> \u2014 <code>' + item.rootDir + '</code> (' + badge + ')'
13162
+ + '<input type="radio" name="memoqRoot" value="' + esc(item.rootDir) + '" ' + checked + ' data-idx="' + idx + '" /> '
13163
+ + '<strong>' + esc(item.label) + '</strong> \u2014 <code>' + esc(item.rootDir) + '</code> (' + badge + ')'
12522
13164
  + '</label>';
12523
13165
  }).join("");
12524
13166
  targetsEl.querySelectorAll('input[name="memoqRoot"]').forEach(function (el) {
@@ -12530,11 +13172,11 @@ function renderSetupHtml(nonce, token, initialStatus) {
12530
13172
  const dllList = state.discoveredDlls || [];
12531
13173
  if (dllsEl) {
12532
13174
  if (!dllList.length) {
12533
- dllsEl.textContent = "\u672A\u5728\u672C\u673A\u5E38\u7528\u76EE\u5F55\u9884\u53D1\u73B0 DLL\uFF1B\u70B9\u51FB\u5B89\u88C5\u65F6\u5C06\u6309\u9700\u4ECE\u5B89\u5168 Release \u62C9\u53D6\u5E76\u6821\u9A8C SHA-256\u3002";
13175
+ dllsEl.textContent = "\u672A\u5728\u672C\u673A\u5E38\u7528\u76EE\u5F55\u9884\u53D1\u73B0 DLL\uFF1B\u70B9\u51FB\u5B89\u88C5\u65F6\u5C06\u81EA\u52A8\u901A\u8FC7 HTTP Range \u4EC5\u62C9\u53D6\u6240\u9700 DLL\uFF08\u7EA6 150 KB\uFF0C\u652F\u6301\u7CFB\u7EDF\u4EE3\u7406\uFF09\u5E76\u6821\u9A8C SHA-256\u3002";
12534
13176
  } else {
12535
13177
  dllsEl.innerHTML = "\u672C\u673A\u5DF2\u53D1\u73B0\u53EF\u7528\u5305\uFF08\u70B9\u51FB\u53EF\u586B\u5165\u8DEF\u5F84\uFF09\uFF1A" + dllList.slice(0, 4).map(function (c, i) {
12536
13178
  const ok = c.sha256MatchesExpected ? "\u2705" : "\u26A0\uFE0F";
12537
- return '<button type="button" class="pick-dll" data-idx="' + i + '" style="margin:4px 6px 0 0;padding:3px 8px;font-size:12px;">' + ok + " " + c.path.replace(/</g, "&lt;") + "</button>";
13179
+ return '<button type="button" class="pick-dll" data-idx="' + i + '" style="margin:4px 6px 0 0;padding:3px 8px;font-size:12px;">' + ok + " " + esc(c.path) + "</button>";
12538
13180
  }).join("");
12539
13181
  dllsEl.querySelectorAll(".pick-dll").forEach(function (btn) {
12540
13182
  btn.addEventListener("click", function () {
@@ -12558,7 +13200,8 @@ function renderSetupHtml(nonce, token, initialStatus) {
12558
13200
  }
12559
13201
 
12560
13202
  async function api(path, method, body) {
12561
- const res = await fetch(path + "?token=" + encodeURIComponent(token), {
13203
+ const sep = path.indexOf("?") >= 0 ? "&" : "?";
13204
+ const res = await fetch(path + sep + "token=" + encodeURIComponent(token), {
12562
13205
  method: method,
12563
13206
  headers: { "Content-Type": "application/json", "X-Setup-Token": token },
12564
13207
  body: body ? JSON.stringify(body) : undefined
@@ -12571,7 +13214,7 @@ function renderSetupHtml(nonce, token, initialStatus) {
12571
13214
  document.getElementById("btn-refresh").addEventListener("click", async function () {
12572
13215
  try {
12573
13216
  const custom = document.getElementById("custom-dir").value.trim();
12574
- const data = await api("/api/status" + (custom ? "&customDir=" + encodeURIComponent(custom) : ""), "GET");
13217
+ const data = await api("/api/status" + (custom ? "?customDir=" + encodeURIComponent(custom) : ""), "GET");
12575
13218
  render(data);
12576
13219
  showMessage("\u5DF2\u5237\u65B0\u672C\u673A\u72B6\u6001\u3002", false);
12577
13220
  } catch (e) { showMessage(e.message, true); }
@@ -12595,7 +13238,7 @@ function renderSetupHtml(nonce, token, initialStatus) {
12595
13238
  const payload = dllPath ? { memoqRoot: root, dllPath: dllPath } : { memoqRoot: root };
12596
13239
  const res = await api("/api/install", "POST", payload);
12597
13240
  render(res.status);
12598
- showMessage("\u5B89\u88C5\u6210\u529F\uFF01DLL \u6821\u9A8C\u503C " + res.result.dllSha256 + "\u3002\u8BF7\u91CD\u542F memoQ \u5E76\u5728 MT settings \u4E2D\u542F\u7528\u3002", false);
13241
+ showMessage("\u5B89\u88C5\u6210\u529F\uFF01DLL \u6821\u9A8C\u503C " + res.result.dllSha256 + "\u3002\u8BF7\u5B8C\u5168\u91CD\u542F memoQ\uFF0C\u5E76\u6309\u7B2C 4 \u8282\u5728 Resource Console \u4E0E\u5F53\u524D\u9879\u76EE\u4E2D\u542F\u7528 memoQ AI Hub\u3002", false);
12599
13242
  } catch (e) { showMessage("\u5B89\u88C5\u5931\u8D25\uFF1A" + e.message, true); }
12600
13243
  finally { btn.disabled = false; }
12601
13244
  });
@@ -12626,6 +13269,8 @@ async function startSetupServer(options = {}) {
12626
13269
  const probeGateway = options.probeGateway ?? ((p) => probeGatewayPort(p ?? gatewayPort));
12627
13270
  const resolveDll = options.resolveDll ?? resolvePluginDllAsset;
12628
13271
  const dataDir = options.dataDir ?? defaultBridgeDataDir();
13272
+ const tool = sanitizeReviewTool(options.tool) ?? { name: "@langlink/memoq-bridge", version: BRIDGE_VERSION };
13273
+ const toolLabel = formatReviewTool(tool);
12629
13274
  let actualPort = requestedPort;
12630
13275
  let expectedOrigin = "";
12631
13276
  let expectedHost = "";
@@ -12672,7 +13317,7 @@ async function startSetupServer(options = {}) {
12672
13317
  `default-src 'none'; script-src 'nonce-${nonce}'; style-src 'unsafe-inline'; connect-src 'self'; frame-ancestors 'none'; base-uri 'none';`
12673
13318
  );
12674
13319
  const status = await collectStatus(url.searchParams.get("customDir") ?? void 0);
12675
- send(response, 200, "text/html; charset=utf-8", renderSetupHtml(nonce, token, status));
13320
+ send(response, 200, "text/html; charset=utf-8", renderSetupHtml(nonce, token, status, toolLabel));
12676
13321
  return;
12677
13322
  }
12678
13323
  if (method === "GET" && url.pathname === "/api/status") {
@@ -12692,11 +13337,22 @@ async function startSetupServer(options = {}) {
12692
13337
  sendJson2(response, 400, { error: "memoqRoot \u4E0D\u80FD\u4E3A\u7A7A\u3002" });
12693
13338
  return;
12694
13339
  }
13340
+ const currentIntegration = getIntegrationStatus({
13341
+ ...options.detectOptions,
13342
+ dataDir,
13343
+ ...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
13344
+ customInstallDir: memoqRoot
13345
+ });
13346
+ const siblingDllPaths = currentIntegration.installations.filter((item) => item.pluginInstalled).map((item) => item.pluginTarget);
12695
13347
  const resolvedAsset = await resolveDll({
12696
13348
  dataDir,
13349
+ ...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
13350
+ ...options.detectOptions?.helperExecutablePath === void 0 ? {} : { helperExecutablePath: options.detectOptions.helperExecutablePath },
12697
13351
  ...dllPath ? { dllPath } : {},
12698
13352
  ...options.allowDownload === void 0 ? {} : { allowDownload: options.allowDownload },
12699
- ...options.detectOptions?.expectedSha256 === void 0 ? {} : { expectedSha256: options.detectOptions.expectedSha256 }
13353
+ ...options.detectOptions?.expectedSha256 === void 0 ? {} : { expectedSha256: options.detectOptions.expectedSha256 },
13354
+ searchPaths: siblingDllPaths,
13355
+ includeDefaultUserDirs: !options.detectOptions?.skipHostDiscovery
12700
13356
  });
12701
13357
  const elevate = options.elevate ?? process.platform === "win32";
12702
13358
  const result = await installPluginWithHelper({
@@ -13448,8 +14104,12 @@ function createDshMemoqTools(ctx, controller) {
13448
14104
  const resolvedModel = resolveModelSelection(ctx, liveCfg);
13449
14105
  const llmReady = Boolean(getDshLlmService(ctx));
13450
14106
  const coverage = status.coverage;
14107
+ const integ = status.integration;
13451
14108
  return JSON.stringify({
13452
14109
  ...status,
14110
+ ...integ?.status && integ.status !== "installed" ? {
14111
+ setupHint: "\u68C0\u6D4B\u5230 memoQ MT \u63D2\u4EF6\u5C1A\u672A\u5B8C\u5168\u5C31\u7EEA\uFF0C\u53EF\u8BA9 Agent \u8C03\u7528 memoq_setup\uFF08action: 'plan' / 'install'\uFF09\u83B7\u53D6\u672C\u5730 DLL \u5E76\u5F15\u5BFC\u5B8C\u6210\u9996\u6B21\u914D\u7F6E\u3002"
14112
+ } : {},
13453
14113
  ...coverage?.attentionMessage ? { warning: coverage.attentionMessage } : {},
13454
14114
  gatewayRuntime: {
13455
14115
  actualPort: runtime.actualPort,
@@ -13897,7 +14557,8 @@ function createDshMemoqTools(ctx, controller) {
13897
14557
  return JSON.stringify({
13898
14558
  action: "install",
13899
14559
  installed: true,
13900
- ...installResult
14560
+ ...installResult,
14561
+ memoqResourceSetupSteps: [...MEMOQ_FIRST_TIME_RESOURCE_STEPS]
13901
14562
  });
13902
14563
  }
13903
14564
  if (effectiveAction === "uninstall") {
@@ -13944,7 +14605,8 @@ function createDshMemoqTools(ctx, controller) {
13944
14605
  plan,
13945
14606
  gateway: probe,
13946
14607
  confirmationRequired: true,
13947
- nextStep: integration.canReuseExisting ? "\u68C0\u6D4B\u5230\u5DF2\u5B89\u88C5\u7684\u517C\u5BB9\u63D2\u4EF6\u53EF\u76F4\u63A5\u590D\u7528\u3002\u5982\u9700\u4FEE\u590D\u6216\u5B89\u88C5\u5230\u5176\u4ED6\u7248\u672C\uFF0C\u8BF7\u5411\u7528\u6237\u5C55\u793A plan.plannedChanges \u5E76\u83B7\u660E\u786E\u786E\u8BA4\u540E\u8C03\u7528 memoq_setup({ action: 'install', confirmed: true, memoqRoot, dllPath })\u3002" : plan.readyToInstall ? "\u5DF2\u5B9A\u4F4D\u76EE\u6807 memoQ \u76EE\u5F55\u4E0E\u6E90 DLL\u3002\u8BF7\u5148\u5728\u5BF9\u8BDD\u4E2D\u5217\u51FA plan.plannedChanges\uFF08\u6E90\u8DEF\u5F84\u3001\u590D\u5236\u76EE\u6807\u8DEF\u5F84\u3001SHA-256\u3001ClientDevConfig.xml \u5907\u4EFD\u5408\u5E76\u8BA1\u5212\u3001\u662F\u5426\u5F39 UAC\uFF09\uFF0C\u7B49\u7528\u6237\u786E\u8BA4\u540E\u518D\u8C03\u7528 memoq_setup({ action: 'install', confirmed: true, memoqRoot: plan.recommendedMemoqRoot, dllPath: plan.plannedChanges.sourceDllPath })\u3002" : `\u5C1A\u672A\u5C31\u7EEA\uFF1A${plan.blockers.join("\uFF1B")}\u3002\u8BF7\u5411\u7528\u6237\u786E\u8BA4 memoQ \u76EE\u5F55 (customInstallDir) \u6216\u672C\u5730 DLL/ZIP \u8DEF\u5F84 (dllPath)\uFF0C\u6216\u4F7F\u7528\u672C\u5730\u53EF\u89C6\u5316\u5411\u5BFC\u3002`,
14608
+ memoqResourceSetupSteps: [...MEMOQ_FIRST_TIME_RESOURCE_STEPS],
14609
+ nextStep: integration.canReuseExisting ? "\u68C0\u6D4B\u5230\u5DF2\u5B89\u88C5\u7684\u517C\u5BB9\u63D2\u4EF6\u53EF\u76F4\u63A5\u590D\u7528\u3002\u5982\u679C\u7528\u6237\u662F\u9996\u6B21\u4F7F\u7528\u672C\u5DE5\u5177\uFF0C\u8BF7\u5BF9\u7167 memoqResourceSetupSteps \u5F15\u5BFC\u7528\u6237\u5728 memoQ \u4E2D\u6253\u5F00 Resource Console \u2192 MT settings \u2192 Create new \u65B0\u5EFA\u5E76\u52FE\u9009 memoQ AI Hub\uFF0C\u540C\u65F6\u5728\u5F53\u524D\u9879\u76EE\u7684 Project home \u2192 Settings \u2192 MT settings \u4E2D\u542F\u7528\u8BE5\u8D44\u6E90\uFF1B\u5982\u9700\u4FEE\u590D\u6216\u5B89\u88C5\u5230\u5176\u4ED6\u7248\u672C\uFF0C\u8BF7\u5148\u5411\u7528\u6237\u5C55\u793A plan.plannedChanges \u5E76\u83B7\u660E\u786E\u786E\u8BA4\u540E\u518D\u8C03\u7528 memoq_setup({ action: 'install', confirmed: true, memoqRoot, dllPath })\u3002" : plan.readyToInstall ? "\u5DF2\u5B9A\u4F4D\u76EE\u6807 memoQ \u76EE\u5F55\u4E0E\u6E90 DLL\u3002\u8BF7\u5148\u5728\u5BF9\u8BDD\u4E2D\u5217\u51FA plan.plannedChanges\uFF08\u6E90\u8DEF\u5F84\u3001\u590D\u5236\u76EE\u6807\u8DEF\u5F84\u3001SHA-256\u3001ClientDevConfig.xml \u5907\u4EFD\u5408\u5E76\u8BA1\u5212\u3001\u662F\u5426\u5F39 UAC\uFF09\uFF0C\u7B49\u7528\u6237\u786E\u8BA4\u540E\u518D\u8C03\u7528 memoq_setup({ action: 'install', confirmed: true, memoqRoot: plan.recommendedMemoqRoot, dllPath: plan.plannedChanges.sourceDllPath })\uFF0C\u5B89\u88C5\u5B8C\u6210\u540E\u518D\u5BF9\u7167 memoqResourceSetupSteps \u5F15\u5BFC\u7528\u6237\u5728 memoQ \u4E2D\u65B0\u5EFA\u5E76\u542F\u7528 MT \u8D44\u6E90\u3002" : `\u5C1A\u672A\u5C31\u7EEA\uFF1A${plan.blockers.join("\uFF1B")}\u3002\u8BF7\u5411\u7528\u6237\u786E\u8BA4 memoQ \u76EE\u5F55 (customInstallDir) \u6216\u672C\u5730 DLL/ZIP \u8DEF\u5F84 (dllPath)\uFF0C\u6216\u4F7F\u7528\u672C\u5730\u53EF\u89C6\u5316\u5411\u5BFC\u3002`,
13948
14610
  message: integration.canReuseExisting ? `\u68C0\u6D4B\u5230\u5DF2\u5B89\u88C5\u7684 memoQ \u63D2\u4EF6\u53EF\u76F4\u63A5\u590D\u7528\u3002${url ? `\u5982\u9700\u67E5\u770B\u8BE6\u60C5\u6216\u4FEE\u590D\uFF0C\u8BF7\u6253\u5F00\uFF1A[\u6253\u5F00 memoQ \u8FDE\u63A5\u5668\u5B89\u88C5\u4E0E\u8BCA\u65AD\u5411\u5BFC](${url})` : ""}` : plan.readyToInstall ? `\u5DF2\u627E\u5230\u5B89\u88C5\u8DEF\u5F84\u4E0E\u63D2\u4EF6\u6587\u4EF6\uFF08\u5C06\u590D\u5236\u5E76\u4FDD\u7559\u539F\u4EF6\uFF09\u3002\u8BF7\u5728\u4E0E\u7528\u6237\u786E\u8BA4\u5177\u4F53\u53D8\u66F4\u8DEF\u5F84\u540E\u8C03\u7528 memoq_setup({ action: "install", confirmed: true, ... }) \u5B8C\u6210\u5B89\u88C5${url ? `\uFF0C\u6216\u6253\u5F00\u53EF\u89C6\u5316\u5411\u5BFC\uFF1A[\u6253\u5F00 memoQ \u8FDE\u63A5\u5668\u5B89\u88C5\u4E0E\u8BCA\u65AD\u5411\u5BFC](${url})` : ""}\u3002` : `\u8BF7\u5728\u6D4F\u89C8\u5668\u4E2D\u6253\u5F00\u672C\u5730\u8BBE\u7F6E\u5411\u5BFC\u67E5\u770B\u5C06\u8981\u5199\u5165\u7684 2 \u4E2A\u8DEF\u5F84\u5E76\u70B9\u51FB\u5B89\u88C5${url ? `\uFF1A[\u6253\u5F00 memoQ \u8FDE\u63A5\u5668\u5B89\u88C5\u4E0E\u8BCA\u65AD\u5411\u5BFC](${url})` : ""}`
13949
14611
  });
13950
14612
  }
@@ -14038,7 +14700,40 @@ function createDshMemoqTools(ctx, controller) {
14038
14700
  ];
14039
14701
  }
14040
14702
 
14703
+ // packages/dsh-memoq/package.json
14704
+ var package_default2 = {
14705
+ name: "@langlink/dsh-memoq",
14706
+ version: "0.1.11",
14707
+ private: true,
14708
+ type: "module",
14709
+ dependencies: {
14710
+ "@langlink/memoq-bridge": "workspace:*",
14711
+ "@langlink/l10n-core": "workspace:*"
14712
+ },
14713
+ devDependencies: {
14714
+ "@deepseek-ai/dsh-tools": "0.2.1-rc.3"
14715
+ },
14716
+ main: "./src/index.ts",
14717
+ exports: {
14718
+ ".": "./src/index.ts",
14719
+ "./cordis.patch.yml": "./cordis.patch.yml"
14720
+ },
14721
+ dsh: {
14722
+ bundle: {
14723
+ patch: "./cordis.patch.yml"
14724
+ }
14725
+ },
14726
+ license: "MIT",
14727
+ repository: {
14728
+ type: "git",
14729
+ url: "git+https://github.com/langlink-tech/langlink-harness-toolsets.git",
14730
+ directory: "packages/dsh-memoq"
14731
+ },
14732
+ description: "LangLink memoQ Desktop connector for DeepSeek Harness (dsh): Preview bidirectional bridge, staging pool, confirmed feedback, and DSH live LLM+TM/TB MT fallback."
14733
+ };
14734
+
14041
14735
  // packages/dsh-memoq/src/index.ts
14736
+ var DSH_MEMOQ_TOOL = { name: package_default2.name, version: package_default2.version };
14042
14737
  var name = "langlink-memoq";
14043
14738
  var inject = ["tools"];
14044
14739
  var LIVE_CONFIG_FILENAME = "dsh-live-config.json";
@@ -14176,6 +14871,8 @@ ${user}`,
14176
14871
  packageRoot,
14177
14872
  preferredPort,
14178
14873
  ownerLabel: "dsh-memoq",
14874
+ toolName: package_default2.name,
14875
+ version: package_default2.version,
14179
14876
  mode: "dsh-live",
14180
14877
  writeDaemonFile: config.writeDaemonFile ?? true,
14181
14878
  startPreview: config.startPreview ?? true,
@@ -14231,6 +14928,7 @@ ${user}`,
14231
14928
  dataDir,
14232
14929
  packageRoot,
14233
14930
  gatewayPort: activeRuntime?.actualPort ?? preferredPort,
14931
+ tool: DSH_MEMOQ_TOOL,
14234
14932
  ...customInstallDir === void 0 ? {} : { detectOptions: { customInstallDir } }
14235
14933
  });
14236
14934
  return setupServer.url;