




















@@ -342,6 +342,7 @@ type QmdMcporterSearchParams =
342342minScore: number;
343343collection?: string;
344344timeoutMs: number;
345+signal?: AbortSignal;
345346}
346347| {
347348mcporter: ResolvedQmdMcporterConfig;
@@ -353,6 +354,7 @@ type QmdMcporterSearchParams =
353354minScore: number;
354355collection?: string;
355356timeoutMs: number;
357+signal?: AbortSignal;
356358};
357359type QmdMcporterAcrossCollectionsParams =
358360| {
@@ -363,6 +365,7 @@ type QmdMcporterAcrossCollectionsParams =
363365limit: number;
364366minScore: number;
365367collectionNames: string[];
368+signal?: AbortSignal;
366369}
367370| {
368371tool: BuiltinQmdMcpTool;
@@ -372,6 +375,7 @@ type QmdMcporterAcrossCollectionsParams =
372375limit: number;
373376minScore: number;
374377collectionNames: string[];
378+signal?: AbortSignal;
375379};
376380377381export class QmdMemoryManager implements MemorySearchManager {
@@ -1353,6 +1357,7 @@ export class QmdMemoryManager implements MemorySearchManager {
13531357 limit,
13541358 minScore,
13551359 collectionNames,
1360+signal: searchSignal,
13561361});
13571362}
13581363return await this.runQmdSearchViaMcporter({
@@ -1365,6 +1370,7 @@ export class QmdMemoryManager implements MemorySearchManager {
13651370 minScore,
13661371collection: collectionNames[0],
13671372timeoutMs: this.qmd.limits.timeoutMs,
1373+signal: searchSignal,
13681374});
13691375}
13701376const tool = this.resolveQmdMcpTool(qmdSearchCommand);
@@ -1377,6 +1383,7 @@ export class QmdMemoryManager implements MemorySearchManager {
13771383 limit,
13781384 minScore,
13791385 collectionNames,
1386+signal: searchSignal,
13801387});
13811388}
13821389return await this.runQmdSearchViaMcporter({
@@ -1389,6 +1396,7 @@ export class QmdMemoryManager implements MemorySearchManager {
13891396 minScore,
13901397collection: collectionNames[0],
13911398timeoutMs: this.qmd.limits.timeoutMs,
1399+signal: searchSignal,
13921400});
13931401}
13941402const collectionGroups = await this.resolveCollectionSearchGroups(collectionNames);
@@ -2336,7 +2344,7 @@ export class QmdMemoryManager implements MemorySearchManager {
2336234423372345private async runMcporter(
23382346args: string[],
2339-opts?: { timeoutMs?: number },
2347+opts?: { timeoutMs?: number; signal?: AbortSignal },
23402348): Promise<{ stdout: string; stderr: string }> {
23412349const spawnInvocation = resolveCliSpawnInvocation({
23422350command: "mcporter",
@@ -2352,12 +2360,16 @@ export class QmdMemoryManager implements MemorySearchManager {
23522360cwd: this.workspaceDir,
23532361timeoutMs: opts?.timeoutMs,
23542362maxOutputChars: this.maxQmdOutputChars,
2363+signal: opts?.signal,
23552364});
23562365}
2357236623582367private async runQmdSearchViaMcporter(
23592368params: QmdMcporterSearchParams,
23602369): Promise<QmdQueryResult[]> {
2370+if (params.signal?.aborted) {
2371+throw asAbortError(params.signal);
2372+}
23612373await this.ensureMcporterDaemonStarted(params.mcporter);
2362237423632375// If the version is already known as v1 but we received a stale "query" tool name
@@ -2414,7 +2426,10 @@ export class QmdMemoryManager implements MemorySearchManager {
24142426"--timeout",
24152427String(Math.max(0, params.timeoutMs)),
24162428],
2417-{ timeoutMs: resolveQmdMcporterSearchProcessTimeoutMs(params.timeoutMs) },
2429+{
2430+timeoutMs: resolveQmdMcporterSearchProcessTimeoutMs(params.timeoutMs),
2431+signal: params.signal,
2432+},
24182433);
24192434// If we got here with the v2 "query" tool, confirm v2 for future calls.
24202435if (useUnifiedQueryTool && this.qmdMcpToolVersion === null) {
@@ -2443,6 +2458,7 @@ export class QmdMemoryManager implements MemorySearchManager {
24432458minScore: params.minScore,
24442459collection: params.collection,
24452460timeoutMs: params.timeoutMs,
2461+signal: params.signal,
24462462});
24472463}
24482464throw err;
@@ -3470,6 +3486,7 @@ export class QmdMemoryManager implements MemorySearchManager {
34703486minScore: params.minScore,
34713487collection: collectionName,
34723488timeoutMs: this.qmd.limits.timeoutMs,
3489+signal: params.signal,
34733490})
34743491 : await this.runQmdSearchViaMcporter({
34753492mcporter: this.qmd.mcporter,
@@ -3481,6 +3498,7 @@ export class QmdMemoryManager implements MemorySearchManager {
34813498minScore: params.minScore,
34823499collection: collectionName,
34833500timeoutMs: this.qmd.limits.timeoutMs,
3501+signal: params.signal,
34843502});
34853503for (const entry of parsed) {
34863504if (typeof entry.docid !== "string" || !entry.docid.trim()) {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。