@j0hanz/code-review-analyst-mcp 1.5.2 → 1.5.3
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/lib/tool-factory.js +33 -14
- package/package.json +1 -1
package/dist/lib/tool-factory.js
CHANGED
|
@@ -136,15 +136,22 @@ function isRetryableUpstreamMessage(message) {
|
|
|
136
136
|
return (RETRYABLE_UPSTREAM_ERROR_PATTERN.test(message) ||
|
|
137
137
|
BUSY_ERROR_PATTERN.test(message));
|
|
138
138
|
}
|
|
139
|
-
function ignoreProgressInput(value) {
|
|
140
|
-
if (value === null) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
139
|
function sendTaskProgress(extra, payload) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
140
|
+
const rawToken = extra._meta?.progressToken;
|
|
141
|
+
if (typeof rawToken !== 'string' && typeof rawToken !== 'number') {
|
|
142
|
+
return Promise.resolve();
|
|
143
|
+
}
|
|
144
|
+
const params = {
|
|
145
|
+
progressToken: rawToken,
|
|
146
|
+
progress: payload.current,
|
|
147
|
+
...(payload.total !== undefined ? { total: payload.total } : {}),
|
|
148
|
+
...(payload.message !== undefined ? { message: payload.message } : {}),
|
|
149
|
+
};
|
|
150
|
+
return extra
|
|
151
|
+
.sendNotification({ method: 'notifications/progress', params })
|
|
152
|
+
.catch(() => {
|
|
153
|
+
// Progress notifications are best-effort; never fail tool execution.
|
|
154
|
+
});
|
|
148
155
|
}
|
|
149
156
|
function createProgressReporter(extra) {
|
|
150
157
|
let lastCurrent = 0;
|
|
@@ -349,16 +356,19 @@ export function registerStructuredToolTask(server, config) {
|
|
|
349
356
|
// statusMessage is best-effort; task may already be terminal.
|
|
350
357
|
}
|
|
351
358
|
};
|
|
359
|
+
const onLog = createGeminiLogger(server, task.taskId);
|
|
352
360
|
const storeResultSafely = async (status, result) => {
|
|
353
361
|
try {
|
|
354
362
|
await extra.taskStore.storeTaskResult(task.taskId, status, result);
|
|
355
363
|
}
|
|
356
|
-
catch {
|
|
357
|
-
|
|
364
|
+
catch (storeErr) {
|
|
365
|
+
await onLog('error', {
|
|
366
|
+
event: 'store_result_failed',
|
|
367
|
+
error: getErrorMessage(storeErr),
|
|
368
|
+
});
|
|
358
369
|
}
|
|
359
370
|
};
|
|
360
371
|
try {
|
|
361
|
-
const onLog = createGeminiLogger(server, task.taskId);
|
|
362
372
|
const inputRecord = parseToolInput(input, config.fullInputSchema);
|
|
363
373
|
progressContext = normalizeProgressContext(config.progressContext?.(inputRecord));
|
|
364
374
|
// Snapshot the diff slot ONCE before any async work so that
|
|
@@ -438,9 +448,18 @@ export function registerStructuredToolTask(server, config) {
|
|
|
438
448
|
await reportProgressCompletionUpdate(reportProgress, config.name, progressContext, outcome);
|
|
439
449
|
}
|
|
440
450
|
};
|
|
441
|
-
|
|
442
|
-
void runTask().catch((error) => {
|
|
443
|
-
|
|
451
|
+
setImmediate(() => {
|
|
452
|
+
void runTask().catch(async (error) => {
|
|
453
|
+
try {
|
|
454
|
+
await server.sendLoggingMessage({
|
|
455
|
+
level: 'error',
|
|
456
|
+
logger: 'task-runner',
|
|
457
|
+
data: { task: config.name, error: getErrorMessage(error) },
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
catch {
|
|
461
|
+
console.error(`[task-runner:${config.name}] ${getErrorMessage(error)}`);
|
|
462
|
+
}
|
|
444
463
|
});
|
|
445
464
|
});
|
|
446
465
|
return { task };
|