mirror of
https://github.com/morluto/rea.git
synced 2026-10-26 17:35:11 +00:00
refactor(mcp): bind Electron provider failures at registration
This commit is contained in:
1 parent
3966c92c71
commit
d8948efb81
1 file changed
+8
-9
@@ -78,6 +78,7 @@ export const registerElectronTools = (
|
||||
runElectronTool(
|
||||
registration,
|
||||
listContract,
|
||||
options.observationLoadFailure,
|
||||
{ input, context },
|
||||
(parsed, { signal }) =>
|
||||
listElectronTargets(options.electron, parsed, {
|
||||
@@ -92,6 +93,7 @@ export const registerElectronTools = (
|
||||
runElectronTool(
|
||||
registration,
|
||||
inspectContract,
|
||||
options.observationLoadFailure,
|
||||
{ input, context },
|
||||
(parsed, { signal, progress }) =>
|
||||
inspectElectronPage(options.electron, parsed, {
|
||||
@@ -107,6 +109,7 @@ export const registerElectronTools = (
|
||||
runElectronTool(
|
||||
registration,
|
||||
analyzeContract,
|
||||
undefined,
|
||||
{ input, context },
|
||||
async ({ detail, ...request }, { signal, progress }) => {
|
||||
const analyzed = await analyzeJavaScriptApplicationValidated(
|
||||
@@ -127,6 +130,7 @@ export const registerElectronTools = (
|
||||
runElectronTool(
|
||||
registration,
|
||||
reconcileContract,
|
||||
undefined,
|
||||
{ input, context },
|
||||
(parsed) =>
|
||||
Promise.resolve(reconcileJavaScriptRuntimeEvidenceValidated(parsed)),
|
||||
@@ -139,6 +143,7 @@ export const registerElectronTools = (
|
||||
runElectronTool(
|
||||
registration,
|
||||
activeContract,
|
||||
options.activeLoadFailure,
|
||||
{ input, context },
|
||||
(parsed, { signal, progress }) =>
|
||||
captureElectronScenario(options.electronActive, parsed, {
|
||||
@@ -174,6 +179,7 @@ const runElectronTool = async <Input>(
|
||||
readonly server: EvidenceMcpServer;
|
||||
},
|
||||
contract: ToolContract,
|
||||
loadFailure: OptionalProviderLoadFailure | undefined,
|
||||
request: {
|
||||
readonly input: Input;
|
||||
readonly context: ServerContext;
|
||||
@@ -184,16 +190,9 @@ const runElectronTool = async <Input>(
|
||||
) => Promise<Result<Evidence, AnalysisError>>,
|
||||
) => {
|
||||
const { input, context } = request;
|
||||
const failure =
|
||||
contract.name === "capture_electron_scenario"
|
||||
? options.activeLoadFailure
|
||||
: contract.name === "list_electron_targets" ||
|
||||
contract.name === "inspect_electron_page"
|
||||
? options.observationLoadFailure
|
||||
: undefined;
|
||||
if (failure !== undefined)
|
||||
if (loadFailure !== undefined)
|
||||
return options.delivery.toCallToolResult(
|
||||
err(optionalProviderUnavailable(failure, contract.name)),
|
||||
err(optionalProviderUnavailable(loadFailure, contract.name)),
|
||||
contract,
|
||||
);
|
||||
return runAdmittedToolOperation(
|
||||
|
||||
Reference in new issue
Block a user