@zltquant/zlt-mcp 0.7.0-beta.0 → 0.7.0-beta.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zltquant/zlt-mcp",
3
- "version": "0.7.0-beta.0",
3
+ "version": "0.7.0-beta.2",
4
4
  "description": "智量通 ZLT Quant MCP server(Windows x64;量化策略创建与本地回测)",
5
5
  "bin": {
6
6
  "zlt-mcp": "./zlt-mcp-proxy.bundle.cjs"
@@ -19328,8 +19328,9 @@ var AssistantMasterIpcClient = class {
19328
19328
  onProgress?.(`VSCode \u8FDB\u7A0B\u6CE8\u518C\u5931\u8D25\uFF08\u4E0D\u5F71\u54CD\u5B89\u88C5\u7EE7\u7EED\uFF09: ${message}`);
19329
19329
  }
19330
19330
  }
19331
- async startDefaultServices(config2, onProgress) {
19332
- await this.reportInstallLanePid(config2, onProgress);
19331
+ async startDefaultServices(config2, onProgress, options = {}) {
19332
+ if (options.registerConsumerPid !== false)
19333
+ await this.reportInstallLanePid(config2, onProgress);
19333
19334
  for (const serviceIndex of config2.manualServiceIndices) {
19334
19335
  await this.sendRequest("zltMClient", "CallInnerRpc", {
19335
19336
  modeType: 0,
@@ -19806,26 +19807,20 @@ var AssistantMasterIpcClient = class {
19806
19807
  throw new Error(formatModuleInstallError("\u6295\u7814\u6A21\u5757\u5305\u8986\u76D6\u5B89\u88C5\u72B6\u6001\u8F6E\u8BE2\u8D85\u65F6", moduleIndex, lastProgress ?? { status: 0, process: 0, phase: 0, response: null }));
19807
19808
  }
19808
19809
  };
19809
- async function startManualServices(workRoot, zltContent, config2, onProgress) {
19810
+ async function startManualServices(workRoot, zltContent, config2, onProgress, options = {}) {
19810
19811
  const client = new AssistantMasterIpcClient();
19811
19812
  try {
19812
19813
  await client.connect(zltContent, config2);
19813
- await client.startDefaultServices(config2, onProgress);
19814
+ if (options.registerConsumerPid === void 0)
19815
+ await client.startDefaultServices(config2, onProgress);
19816
+ else
19817
+ await client.startDefaultServices(config2, onProgress, options);
19814
19818
  await client.pollStartupServices(config2);
19815
19819
  await waitForPipe(workRoot, "ZLTAF", config2.zltafPipeWait);
19816
19820
  } finally {
19817
19821
  await client.disconnect();
19818
19822
  }
19819
19823
  }
19820
- async function unregisterRuntimeConsumerPid(zltContent, config2) {
19821
- const client = new AssistantMasterIpcClient();
19822
- try {
19823
- await client.connect(zltContent, config2);
19824
- await client.logoutVSCodePid(process.pid, config2);
19825
- } finally {
19826
- await client.disconnect();
19827
- }
19828
- }
19829
19824
  async function installBacktestModules(workRoot, zltContent, config2, onProgress, hooks = {}) {
19830
19825
  const client = new AssistantMasterIpcClient();
19831
19826
  try {
@@ -20732,7 +20727,7 @@ async function acquireMcpRuntime(config2, explicitWorkRoot) {
20732
20727
  const workRoot = explicitWorkRoot ?? await locateInstalledRuntime(config2);
20733
20728
  return acquireRuntimeLease(workRoot, "starter", {
20734
20729
  ensureRuntime: async () => {
20735
- await startAssistantManagedRuntime(workRoot, config2);
20730
+ await startAssistantManagedRuntime(workRoot, config2, void 0, { registerConsumerPid: false });
20736
20731
  return null;
20737
20732
  }
20738
20733
  });
@@ -20761,7 +20756,11 @@ async function startAssistantBackServices(workRoot, config2, onProgress, options
20761
20756
  return;
20762
20757
  const zltContent = await ensureAssistantHostRunning(workRoot, config2, onProgress, options);
20763
20758
  onProgress?.("\u542F\u52A8\u667A\u80FD\u7BA1\u5BB6\u540E\u53F0\u670D\u52A1");
20764
- await startManualServices(workRoot, zltContent, config2, onProgress);
20759
+ const serviceOptions = options.registerConsumerPid === void 0 ? void 0 : { registerConsumerPid: options.registerConsumerPid };
20760
+ if (serviceOptions)
20761
+ await startManualServices(workRoot, zltContent, config2, onProgress, serviceOptions);
20762
+ else
20763
+ await startManualServices(workRoot, zltContent, config2, onProgress);
20765
20764
  }
20766
20765
  async function ensureAssistantHostRunning(workRoot, config2, onProgress, options = {}) {
20767
20766
  const masterPipeExists = (suffix) => pipeExists(workRoot, `${config2.masterPipePrefix}_${suffix}`);
@@ -27224,8 +27223,15 @@ async function startMcpServer() {
27224
27223
  const text = result.content?.map((item) => item.type === "text" ? item.text : "").join("\n") ?? "";
27225
27224
  const match = text.match(/"uuid"\s*:\s*"([^"]+)"/);
27226
27225
  if (!match) return;
27227
- leaseStateUpdate = leaseStateUpdate.then(() => updateRuntimeLeaseActiveJob(runtimeLease, `download:${match[1]}`, true)).catch((error2) => {
27226
+ leaseStateUpdate = leaseStateUpdate.then(() => updateRuntimeLeaseActiveJob(runtimeLease, "runtime:explicit-start", false)).then(() => updateRuntimeLeaseActiveJob(runtimeLease, `download:${match[1]}`, true)).catch((error2) => {
27228
27227
  process.stderr.write(`[zlt-mcp-proxy] runtime download lease update failed: ${error2 instanceof Error ? error2.message : String(error2)}
27228
+ `);
27229
+ });
27230
+ };
27231
+ const recordRuntimeKeepalive = (active2) => {
27232
+ if (!runtimeLease) return;
27233
+ leaseStateUpdate = leaseStateUpdate.then(() => updateRuntimeLeaseActiveJob(runtimeLease, "runtime:explicit-start", active2)).catch((error2) => {
27234
+ process.stderr.write(`[zlt-mcp-proxy] runtime keepalive update failed: ${error2 instanceof Error ? error2.message : String(error2)}
27229
27235
  `);
27230
27236
  });
27231
27237
  };
@@ -27341,7 +27347,9 @@ async function startMcpServer() {
27341
27347
  return handleBacktestProfitTool(toolArgs, backtestRunContexts);
27342
27348
  }
27343
27349
  if (tool.localHandler) {
27344
- return handleRuntimeTool(tool.localHandler, toolArgs, runtimeConfig, ensureRuntimeLease, runRuntimeDoctor);
27350
+ const result = await handleRuntimeTool(tool.localHandler, toolArgs, runtimeConfig, ensureRuntimeLease, runRuntimeDoctor);
27351
+ if (tool.localHandler === "runtimeStart" && !result.isError) recordRuntimeKeepalive(true);
27352
+ return result;
27345
27353
  }
27346
27354
  const dangerousToolGuard = guardDangerousTool(tool, toolArgs);
27347
27355
  if (dangerousToolGuard) {
@@ -27444,14 +27452,7 @@ async function startMcpServer() {
27444
27452
  if (runtimeLease) {
27445
27453
  const lease = runtimeLease;
27446
27454
  runtimeLease = void 0;
27447
- try {
27448
- const zltContent = await readZltContent(lease.workRoot, runtimeConfig.temporaryZltFile);
27449
- if (zltContent) await unregisterRuntimeConsumerPid(zltContent, runtimeConfig);
27450
- process.stderr.write("[zlt-mcp-proxy] runtime PID \u5DF2\u6CE8\u9500\n");
27451
- } catch (error2) {
27452
- process.stderr.write(`[zlt-mcp-proxy] runtime PID \u6CE8\u9500\u5931\u8D25\uFF08\u5FFD\u7565\uFF09: ${error2 instanceof Error ? error2.message : String(error2)}
27453
- `);
27454
- }
27455
+ process.stderr.write("[zlt-mcp-proxy] standalone MCP \u4E0D\u6CE8\u9500 ZLTHome consumer PID\n");
27455
27456
  try {
27456
27457
  const released = await releaseRuntimeLease(lease);
27457
27458
  process.stderr.write(`[zlt-mcp-proxy] runtime lease released: ${released.reason}