@j0hanz/code-review-analyst-mcp 1.7.3 → 1.7.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/dist/lib/tool-factory.js +52 -27
- package/package.json +1 -1
package/dist/lib/tool-factory.js
CHANGED
|
@@ -183,13 +183,17 @@ function createProgressReporter(extra) {
|
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
185
|
const progressToken = rawToken;
|
|
186
|
-
let lastCurrent =
|
|
186
|
+
let lastCurrent = -1;
|
|
187
187
|
let didSendTerminal = false;
|
|
188
188
|
return async (payload) => {
|
|
189
189
|
if (didSendTerminal) {
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
|
-
|
|
192
|
+
let { current } = payload;
|
|
193
|
+
if (current <= lastCurrent && current < (payload.total ?? Infinity)) {
|
|
194
|
+
current = lastCurrent + 0.01;
|
|
195
|
+
}
|
|
196
|
+
current = Math.max(current, lastCurrent);
|
|
193
197
|
const total = payload.total !== undefined
|
|
194
198
|
? Math.max(payload.total, current)
|
|
195
199
|
: undefined;
|
|
@@ -265,18 +269,20 @@ async function sendSingleStepProgress(extra, toolName, context, current, state)
|
|
|
265
269
|
async function reportProgressStepUpdate(reportProgress, toolName, context, current, metadata) {
|
|
266
270
|
await reportProgress({
|
|
267
271
|
current,
|
|
272
|
+
total: TASK_PROGRESS_TOTAL,
|
|
268
273
|
message: formatProgressStep(toolName, context, metadata),
|
|
269
274
|
});
|
|
270
275
|
}
|
|
271
276
|
async function reportProgressCompletionUpdate(reportProgress, toolName, context, outcome) {
|
|
272
277
|
await reportProgress({
|
|
273
278
|
current: TASK_PROGRESS_TOTAL,
|
|
279
|
+
total: TASK_PROGRESS_TOTAL,
|
|
274
280
|
message: formatProgressCompletion(toolName, context, outcome),
|
|
275
281
|
});
|
|
276
282
|
}
|
|
277
283
|
async function reportSchemaRetryProgressBestEffort(reportProgress, toolName, context, retryCount, maxRetries) {
|
|
278
284
|
try {
|
|
279
|
-
await reportProgressStepUpdate(reportProgress, toolName, context, STEP_VALIDATING_RESPONSE, `Schema repair in progress (attempt ${retryCount}/${maxRetries})...`);
|
|
285
|
+
await reportProgressStepUpdate(reportProgress, toolName, context, STEP_VALIDATING_RESPONSE + retryCount / (maxRetries + 1), `Schema repair in progress (attempt ${retryCount}/${maxRetries})...`);
|
|
280
286
|
}
|
|
281
287
|
catch {
|
|
282
288
|
// Progress updates are best-effort and must not interrupt retries.
|
|
@@ -557,35 +563,54 @@ export function registerStructuredToolTask(server, config) {
|
|
|
557
563
|
geminiSchema: config.geminiSchema,
|
|
558
564
|
resultSchema: config.resultSchema,
|
|
559
565
|
});
|
|
560
|
-
server.
|
|
566
|
+
server.experimental.tasks.registerToolTask(config.name, {
|
|
561
567
|
title: config.title,
|
|
562
568
|
description: config.description,
|
|
563
569
|
inputSchema: config.inputSchema,
|
|
564
570
|
outputSchema: DefaultOutputSchema,
|
|
565
571
|
annotations: buildToolAnnotations(config.annotations),
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
572
|
+
execution: {
|
|
573
|
+
taskSupport: 'optional',
|
|
574
|
+
},
|
|
575
|
+
}, {
|
|
576
|
+
createTask: async (input, extra) => {
|
|
577
|
+
const task = await extra.taskStore.createTask({ ttl: 300000 });
|
|
578
|
+
const extendedStore = extra.taskStore;
|
|
579
|
+
const runner = new ToolExecutionRunner(config, {
|
|
580
|
+
onLog: async (level, data) => {
|
|
581
|
+
try {
|
|
582
|
+
await server.sendLoggingMessage({
|
|
583
|
+
level: toLoggingLevel(level),
|
|
584
|
+
logger: 'gemini',
|
|
585
|
+
data: asObjectRecord(data),
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
catch {
|
|
589
|
+
// Fallback if logging fails
|
|
590
|
+
}
|
|
585
591
|
},
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
592
|
+
reportProgress: createProgressReporter(extra),
|
|
593
|
+
statusReporter: {
|
|
594
|
+
updateStatus: async (message) => {
|
|
595
|
+
await extendedStore.updateTaskStatus(task.taskId, 'working', message);
|
|
596
|
+
},
|
|
597
|
+
storeResult: async (status, result) => {
|
|
598
|
+
await extra.taskStore.storeTaskResult(task.taskId, status, result);
|
|
599
|
+
},
|
|
600
|
+
},
|
|
601
|
+
});
|
|
602
|
+
runner.setResponseSchemaOverride(responseSchema);
|
|
603
|
+
// Run in background
|
|
604
|
+
runner.run(input).catch(async (error) => {
|
|
605
|
+
await extendedStore.updateTaskStatus(task.taskId, 'failed', getErrorMessage(error));
|
|
606
|
+
});
|
|
607
|
+
return { task };
|
|
608
|
+
},
|
|
609
|
+
getTask: async (input, extra) => {
|
|
610
|
+
return await extra.taskStore.getTask(extra.taskId);
|
|
611
|
+
},
|
|
612
|
+
getTaskResult: async (input, extra) => {
|
|
613
|
+
return (await extra.taskStore.getTaskResult(extra.taskId));
|
|
614
|
+
},
|
|
590
615
|
});
|
|
591
616
|
}
|