@langlink/memoq-mcp 0.2.3 → 0.2.4
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/bin/MemoQ.Bridge.Helper.exe +0 -0
- package/dist/index.js +107 -16
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -23595,7 +23595,8 @@ var CONTROL_ROUTES = {
|
|
|
23595
23595
|
liveConfig: "/bridge/live-config",
|
|
23596
23596
|
qaCatalog: "/bridge/qa/catalog",
|
|
23597
23597
|
qaRun: "/bridge/qa/run",
|
|
23598
|
-
reviewUrl: "/bridge/review-url"
|
|
23598
|
+
reviewUrl: "/bridge/review-url",
|
|
23599
|
+
shutdown: "/bridge/shutdown"
|
|
23599
23600
|
};
|
|
23600
23601
|
var ERROR_CODES = {
|
|
23601
23602
|
contractVersionMismatch: "CONTRACT_VERSION_MISMATCH",
|
|
@@ -30880,6 +30881,22 @@ async function createMtGateway(options) {
|
|
|
30880
30881
|
return;
|
|
30881
30882
|
}
|
|
30882
30883
|
}
|
|
30884
|
+
if (method === "POST" && pathname === CONTROL_ROUTES.shutdown) {
|
|
30885
|
+
const triggerShutdown = options.onShutdown;
|
|
30886
|
+
if (!triggerShutdown) {
|
|
30887
|
+
sendJson(response, 400, { ok: false, error: "Graceful shutdown is not enabled for this host." });
|
|
30888
|
+
return;
|
|
30889
|
+
}
|
|
30890
|
+
response.setHeader("Connection", "close");
|
|
30891
|
+
response.once("finish", () => {
|
|
30892
|
+
setImmediate(() => {
|
|
30893
|
+
void Promise.resolve(triggerShutdown()).catch(() => {
|
|
30894
|
+
});
|
|
30895
|
+
});
|
|
30896
|
+
});
|
|
30897
|
+
sendJson(response, 200, { ok: true, shuttingDown: true });
|
|
30898
|
+
return;
|
|
30899
|
+
}
|
|
30883
30900
|
sendJson(response, 404, { error: `Unknown control route: ${pathname}` });
|
|
30884
30901
|
}
|
|
30885
30902
|
await new Promise((resolve7, reject) => {
|
|
@@ -30911,6 +30928,7 @@ async function createMtGateway(options) {
|
|
|
30911
30928
|
options.stagingStore.flush?.();
|
|
30912
30929
|
return new Promise((resolve7, reject) => {
|
|
30913
30930
|
server.close((error2) => error2 ? reject(error2) : resolve7());
|
|
30931
|
+
server.closeIdleConnections?.();
|
|
30914
30932
|
});
|
|
30915
30933
|
},
|
|
30916
30934
|
handleTranslateForTest: processTranslate
|
|
@@ -31929,6 +31947,7 @@ function readDaemonRecord(dataDir = defaultBridgeDataDir()) {
|
|
|
31929
31947
|
port: Number(parsed.port),
|
|
31930
31948
|
controlToken: String(parsed.controlToken),
|
|
31931
31949
|
owner: String(parsed.owner ?? "bridge"),
|
|
31950
|
+
...typeof parsed.version === "string" && parsed.version.trim() ? { version: parsed.version.trim() } : {},
|
|
31932
31951
|
mode: parsed.mode === "dsh-live" ? "dsh-live" : "staging",
|
|
31933
31952
|
startedAt: String(parsed.startedAt ?? "")
|
|
31934
31953
|
};
|
|
@@ -32075,6 +32094,9 @@ var BridgeHttpClient = class {
|
|
|
32075
32094
|
updateLiveConfig(patch) {
|
|
32076
32095
|
return this.request("POST", CONTROL_ROUTES.liveConfig, patch);
|
|
32077
32096
|
}
|
|
32097
|
+
shutdown() {
|
|
32098
|
+
return this.request("POST", CONTROL_ROUTES.shutdown, {});
|
|
32099
|
+
}
|
|
32078
32100
|
};
|
|
32079
32101
|
async function startBridgeRuntime(options = {}) {
|
|
32080
32102
|
const dataDir = options.dataDir ?? defaultBridgeDataDir();
|
|
@@ -32103,6 +32125,7 @@ async function startBridgeRuntime(options = {}) {
|
|
|
32103
32125
|
host,
|
|
32104
32126
|
port: bindPort,
|
|
32105
32127
|
mode: options.mode ?? "staging",
|
|
32128
|
+
...options.version === void 0 ? {} : { desktopVersion: options.version },
|
|
32106
32129
|
...persistedReviewToken ? { reviewToken: persistedReviewToken } : {},
|
|
32107
32130
|
stagingStore,
|
|
32108
32131
|
previewClient,
|
|
@@ -32110,7 +32133,8 @@ async function startBridgeRuntime(options = {}) {
|
|
|
32110
32133
|
...options.liveTranslator === void 0 ? {} : { liveTranslator: options.liveTranslator },
|
|
32111
32134
|
...options.tagAligner === void 0 ? {} : { tagAligner: options.tagAligner },
|
|
32112
32135
|
...options.getLiveConfig === void 0 ? {} : { getLiveConfig: options.getLiveConfig },
|
|
32113
|
-
...options.updateLiveConfig === void 0 ? {} : { updateLiveConfig: options.updateLiveConfig }
|
|
32136
|
+
...options.updateLiveConfig === void 0 ? {} : { updateLiveConfig: options.updateLiveConfig },
|
|
32137
|
+
...options.onShutdown === void 0 ? {} : { onShutdown: options.onShutdown }
|
|
32114
32138
|
});
|
|
32115
32139
|
if (shouldWriteDaemon) {
|
|
32116
32140
|
writeDaemonRecord(
|
|
@@ -32120,6 +32144,7 @@ async function startBridgeRuntime(options = {}) {
|
|
|
32120
32144
|
port: gateway.port,
|
|
32121
32145
|
controlToken: gateway.controlToken,
|
|
32122
32146
|
owner: options.ownerLabel ?? "memoq-bridge",
|
|
32147
|
+
...options.version ? { version: options.version } : {},
|
|
32123
32148
|
mode: options.mode ?? "staging",
|
|
32124
32149
|
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
32125
32150
|
},
|
|
@@ -32808,7 +32833,7 @@ async function trySpawnViaWindowsWmi(entrypoint, workerArgs, dataDir) {
|
|
|
32808
32833
|
JSON.stringify({
|
|
32809
32834
|
executable: process.execPath,
|
|
32810
32835
|
args: workerArgs,
|
|
32811
|
-
workingDirectory:
|
|
32836
|
+
workingDirectory: dataDir
|
|
32812
32837
|
}),
|
|
32813
32838
|
"utf8"
|
|
32814
32839
|
);
|
|
@@ -32833,7 +32858,7 @@ function spawnViaNodeDetached(entrypoint, workerArgs, dataDir) {
|
|
|
32833
32858
|
detached: true,
|
|
32834
32859
|
windowsHide: true,
|
|
32835
32860
|
stdio: "ignore",
|
|
32836
|
-
cwd:
|
|
32861
|
+
cwd: dataDir,
|
|
32837
32862
|
env: { ...process.env, MEMOQ_BRIDGE_DATA_DIR: dataDir }
|
|
32838
32863
|
});
|
|
32839
32864
|
child.unref();
|
|
@@ -32903,18 +32928,69 @@ async function publishWorkerOutcome(readyFile, outcome) {
|
|
|
32903
32928
|
}
|
|
32904
32929
|
}
|
|
32905
32930
|
}
|
|
32931
|
+
async function waitForDaemonShutdown(client, timeoutMs = 3e3) {
|
|
32932
|
+
const deadline = Date.now() + timeoutMs;
|
|
32933
|
+
while (Date.now() < deadline) {
|
|
32934
|
+
try {
|
|
32935
|
+
await client.getStatus();
|
|
32936
|
+
} catch {
|
|
32937
|
+
return true;
|
|
32938
|
+
}
|
|
32939
|
+
await new Promise((res) => setTimeout(res, READY_POLL_INTERVAL_MS));
|
|
32940
|
+
}
|
|
32941
|
+
return false;
|
|
32942
|
+
}
|
|
32906
32943
|
async function connectOrLaunchBridgeClient(entrypoint, options = {}) {
|
|
32907
32944
|
const dataDir = options.dataDir ?? defaultBridgeDataDir();
|
|
32908
32945
|
const existing = readDaemonRecord(dataDir);
|
|
32909
32946
|
if (existing) {
|
|
32910
32947
|
const client = new BridgeHttpClient(`http://${existing.host}:${existing.port}`, existing.controlToken);
|
|
32948
|
+
let alive = false;
|
|
32911
32949
|
try {
|
|
32912
32950
|
await client.getStatus();
|
|
32913
|
-
|
|
32951
|
+
alive = true;
|
|
32914
32952
|
} catch {
|
|
32953
|
+
alive = false;
|
|
32954
|
+
}
|
|
32955
|
+
if (alive) {
|
|
32956
|
+
const shouldUpgrade = Boolean(options.expectedVersion) && existing.owner === "memoq-mcp-daemon" && existing.version !== options.expectedVersion;
|
|
32957
|
+
if (!shouldUpgrade) {
|
|
32958
|
+
return client;
|
|
32959
|
+
}
|
|
32960
|
+
let shutdownRequested = false;
|
|
32961
|
+
try {
|
|
32962
|
+
const res = await client.shutdown();
|
|
32963
|
+
shutdownRequested = res.ok === true;
|
|
32964
|
+
} catch {
|
|
32965
|
+
shutdownRequested = false;
|
|
32966
|
+
}
|
|
32967
|
+
if (shutdownRequested) {
|
|
32968
|
+
const stopped = await waitForDaemonShutdown(client);
|
|
32969
|
+
if (!stopped) {
|
|
32970
|
+
return client;
|
|
32971
|
+
}
|
|
32972
|
+
const refreshed = readDaemonRecord(dataDir);
|
|
32973
|
+
if (refreshed && refreshed.controlToken !== existing.controlToken) {
|
|
32974
|
+
const refreshedClient = new BridgeHttpClient(
|
|
32975
|
+
`http://${refreshed.host}:${refreshed.port}`,
|
|
32976
|
+
refreshed.controlToken
|
|
32977
|
+
);
|
|
32978
|
+
try {
|
|
32979
|
+
await refreshedClient.getStatus();
|
|
32980
|
+
return refreshedClient;
|
|
32981
|
+
} catch {
|
|
32982
|
+
}
|
|
32983
|
+
}
|
|
32984
|
+
} else {
|
|
32985
|
+
try {
|
|
32986
|
+
await client.getStatus();
|
|
32987
|
+
return client;
|
|
32988
|
+
} catch {
|
|
32989
|
+
}
|
|
32990
|
+
}
|
|
32915
32991
|
}
|
|
32916
32992
|
}
|
|
32917
|
-
const configuredPort = parseConfiguredBridgePort();
|
|
32993
|
+
const configuredPort = options.port ?? parseConfiguredBridgePort();
|
|
32918
32994
|
const payload = await spawnDetachedWorker(entrypoint, MEMOQ_BRIDGE_DAEMON_FLAG, {
|
|
32919
32995
|
dataDir,
|
|
32920
32996
|
...configuredPort === void 0 ? {} : { port: configuredPort }
|
|
@@ -32952,23 +33028,35 @@ function createSetupWizardLauncher(entrypoint, options = {}) {
|
|
|
32952
33028
|
return inFlight;
|
|
32953
33029
|
};
|
|
32954
33030
|
}
|
|
32955
|
-
async function runBridgeDaemonWorker(argv = process.argv.slice(2)) {
|
|
33031
|
+
async function runBridgeDaemonWorker(argv = process.argv.slice(2), version2, runtimeOptions = {}) {
|
|
32956
33032
|
const args = parseWorkerCliArgs(argv);
|
|
32957
33033
|
if (!args.readyFile && (!process.send || !process.connected)) {
|
|
32958
33034
|
throw new Error("memoQ bridge daemon requires --ready-file or IPC.");
|
|
32959
33035
|
}
|
|
32960
33036
|
const dataDir = args.dataDir ?? defaultBridgeDataDir();
|
|
32961
33037
|
try {
|
|
32962
|
-
|
|
33038
|
+
let closing = false;
|
|
33039
|
+
let runtime;
|
|
33040
|
+
const cleanup = () => {
|
|
33041
|
+
if (closing) return;
|
|
33042
|
+
closing = true;
|
|
33043
|
+
if (runtime) {
|
|
33044
|
+
removeDaemonRecord(runtime.gateway.controlToken, dataDir);
|
|
33045
|
+
void runtime.close().catch(() => {
|
|
33046
|
+
}).finally(() => process.exit(0));
|
|
33047
|
+
} else {
|
|
33048
|
+
process.exit(0);
|
|
33049
|
+
}
|
|
33050
|
+
};
|
|
33051
|
+
runtime = await startBridgeRuntime({
|
|
32963
33052
|
dataDir,
|
|
32964
33053
|
...args.port === void 0 ? {} : { preferredPort: args.port },
|
|
32965
33054
|
ownerLabel: "memoq-mcp-daemon",
|
|
32966
|
-
|
|
33055
|
+
...version2 ? { version: version2 } : {},
|
|
33056
|
+
...runtimeOptions.startPreview === void 0 ? {} : { startPreview: runtimeOptions.startPreview },
|
|
33057
|
+
mode: "staging",
|
|
33058
|
+
onShutdown: cleanup
|
|
32967
33059
|
});
|
|
32968
|
-
const cleanup = () => {
|
|
32969
|
-
removeDaemonRecord(runtime.gateway.controlToken, dataDir);
|
|
32970
|
-
void runtime.close().finally(() => process.exit(0));
|
|
32971
|
-
};
|
|
32972
33060
|
process.once("SIGINT", cleanup);
|
|
32973
33061
|
process.once("SIGTERM", cleanup);
|
|
32974
33062
|
try {
|
|
@@ -33029,8 +33117,9 @@ function textResult(value) {
|
|
|
33029
33117
|
content: [{ type: "text", text: typeof value === "string" ? value : JSON.stringify(value) }]
|
|
33030
33118
|
};
|
|
33031
33119
|
}
|
|
33120
|
+
var MEMOQ_MCP_VERSION = "0.2.4";
|
|
33032
33121
|
function createMemoqMcpServer(options = {}) {
|
|
33033
|
-
const server = new McpServer({ name: "langlink-memoq", version:
|
|
33122
|
+
const server = new McpServer({ name: "langlink-memoq", version: MEMOQ_MCP_VERSION });
|
|
33034
33123
|
const here = dirname8(fileURLToPath2(import.meta.url));
|
|
33035
33124
|
const entrypoint = fileURLToPath2(import.meta.url);
|
|
33036
33125
|
const packageRoot = resolve6(here, "..");
|
|
@@ -33039,7 +33128,8 @@ function createMemoqMcpServer(options = {}) {
|
|
|
33039
33128
|
if (options.bridgeClient) return options.bridgeClient;
|
|
33040
33129
|
if (options.getBridgeClient) return options.getBridgeClient();
|
|
33041
33130
|
clientPromise ??= connectOrLaunchBridgeClient(entrypoint, {
|
|
33042
|
-
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir }
|
|
33131
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
33132
|
+
expectedVersion: MEMOQ_MCP_VERSION
|
|
33043
33133
|
}).catch((error2) => {
|
|
33044
33134
|
clientPromise = void 0;
|
|
33045
33135
|
throw error2;
|
|
@@ -33514,7 +33604,7 @@ async function runConfigCommand(args) {
|
|
|
33514
33604
|
async function main() {
|
|
33515
33605
|
const command = process.argv[2];
|
|
33516
33606
|
if (command === MEMOQ_BRIDGE_DAEMON_FLAG) {
|
|
33517
|
-
await runBridgeDaemonWorker(process.argv.slice(3));
|
|
33607
|
+
await runBridgeDaemonWorker(process.argv.slice(3), MEMOQ_MCP_VERSION);
|
|
33518
33608
|
return;
|
|
33519
33609
|
}
|
|
33520
33610
|
if (command === MEMOQ_SETUP_WORKER_FLAG) {
|
|
@@ -33543,6 +33633,7 @@ if (process.argv[1] && import.meta.url === pathToFileURL(realpathSync(process.ar
|
|
|
33543
33633
|
});
|
|
33544
33634
|
}
|
|
33545
33635
|
export {
|
|
33636
|
+
MEMOQ_MCP_VERSION,
|
|
33546
33637
|
createMemoqMcpServer
|
|
33547
33638
|
};
|
|
33548
33639
|
//# sourceMappingURL=index.js.map
|