@adminforth/mcp 1.4.1 → 1.4.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/adminPanelConfirmation.js +2 -1
- package/dist/apiTools.js +2 -1
- package/dist/custom/McpConfirm.vue +11 -12
- package/dist/toolOutput.d.ts +1 -0
- package/dist/toolOutput.js +13 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { MAX_ACTIONS_PER_CONFIRMATION } from './schemas/confirmation.js';
|
|
3
|
+
import { isErrorOutput } from './toolOutput.js';
|
|
3
4
|
import { adminApiPrefix, CONFIRMATION_PAGE_PATH } from './urls.js';
|
|
4
5
|
export const WAIT_FOR_CONFIRMATION_TOOL_NAME = 'wait_for_confirmation';
|
|
5
6
|
const CONFIRMATION_TTL_MS = 10 * 60 * 1000;
|
|
@@ -208,7 +209,7 @@ export class McpAdminPanelConfirmation {
|
|
|
208
209
|
clearTimeout(timer);
|
|
209
210
|
input.abortSignal?.removeEventListener('abort', abort);
|
|
210
211
|
}
|
|
211
|
-
return { output, isError: responseStatus
|
|
212
|
+
return { output, isError: isErrorOutput(responseStatus, output) };
|
|
212
213
|
}
|
|
213
214
|
/** All actions of a group belong to one user and run as one agent, so they can share one verification. */
|
|
214
215
|
openGroup(ids, adminUser) {
|
package/dist/apiTools.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { compactInputSchema } from './compactInputSchema.js';
|
|
2
|
+
import { isErrorOutput } from './toolOutput.js';
|
|
2
3
|
import { adminApiPrefix } from './urls.js';
|
|
3
4
|
import { AdminForthDataTypes } from 'adminforth';
|
|
4
5
|
const METHODS_WITHOUT_REQUEST_BODY = new Set(['GET', 'HEAD']);
|
|
@@ -308,7 +309,7 @@ export class AdminForthApiTools {
|
|
|
308
309
|
isError: true,
|
|
309
310
|
};
|
|
310
311
|
}
|
|
311
|
-
const isError = response.status
|
|
312
|
+
const isError = isErrorOutput(response.status, output);
|
|
312
313
|
return {
|
|
313
314
|
output: isError || !override?.project ? output : override.project(output, args, params.arguments ?? {}),
|
|
314
315
|
isError,
|
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="af-mcp-confirm flex min-h-screen items-center justify-center bg-gray-100 p-4 dark:bg-gray-800">
|
|
3
|
-
<div class="w-full max-w-lg rounded-lg bg-white p-6 shadow dark:bg-gray-700">
|
|
3
|
+
<div v-if="resultMessage || error" class="w-full max-w-lg rounded-lg bg-white p-6 shadow dark:bg-gray-700">
|
|
4
4
|
<template v-if="pending">
|
|
5
5
|
<h1 class="text-xl font-medium text-gray-900 dark:text-white">{{ title }}</h1>
|
|
6
6
|
<p class="mt-3 text-sm text-gray-600 dark:text-gray-300">
|
|
7
7
|
<b>{{ pending.connectionName }}</b>
|
|
8
8
|
{{ $t('asks to run this action on your behalf. | asks to run these actions on your behalf.', pending.actions.length) }}
|
|
9
9
|
</p>
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
</ul>
|
|
17
|
-
</template>
|
|
18
|
-
<Spinner v-else class="mx-auto mt-4 h-8 w-8" />
|
|
10
|
+
<p class="mt-4 text-sm font-medium" :class="failed ? 'text-red-700 dark:text-red-300' : 'text-green-700 dark:text-green-300'">
|
|
11
|
+
{{ resultMessage }}
|
|
12
|
+
</p>
|
|
13
|
+
<ul v-if="failedErrors.length" class="mt-2 list-disc space-y-1 pl-5 text-sm text-red-700 dark:text-red-300">
|
|
14
|
+
<li v-for="(failedError, i) in failedErrors" :key="i">{{ failedError }}</li>
|
|
15
|
+
</ul>
|
|
19
16
|
</template>
|
|
20
|
-
<template v-else
|
|
17
|
+
<template v-else>
|
|
21
18
|
<h1 class="text-xl font-medium text-gray-900 dark:text-white">{{ $t('Cannot run the action') }}</h1>
|
|
22
19
|
<p class="mt-3 text-sm text-gray-600 dark:text-gray-300">{{ error }}</p>
|
|
23
20
|
</template>
|
|
24
|
-
<Spinner v-else class="mx-auto h-8 w-8" />
|
|
25
21
|
</div>
|
|
22
|
+
<Spinner v-else-if="running" class="h-8 w-8" />
|
|
26
23
|
</div>
|
|
27
24
|
</template>
|
|
28
25
|
|
|
@@ -49,6 +46,7 @@ const route = useRoute();
|
|
|
49
46
|
const pending = ref<PendingConfirmation | null>(null);
|
|
50
47
|
const error = ref('');
|
|
51
48
|
const failed = ref(false);
|
|
49
|
+
const running = ref(false);
|
|
52
50
|
const resultMessage = ref('');
|
|
53
51
|
const failedErrors = ref<string[]>([]);
|
|
54
52
|
const ids = computed(() => pending.value!.actions.map((action) => action.id));
|
|
@@ -90,6 +88,7 @@ async function confirm() {
|
|
|
90
88
|
}
|
|
91
89
|
return;
|
|
92
90
|
}
|
|
91
|
+
running.value = true;
|
|
93
92
|
const response = await callAdminForthApi({ method: 'POST', path: '/mcp/confirmation/run', body: { ids: ids.value, verificationResult } });
|
|
94
93
|
if (!response || response.error) {
|
|
95
94
|
failed.value = true;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isErrorOutput(status: number, output: unknown): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// AdminForth core reports a beforeSave hook that returned { ok: false, error: null } with this error.
|
|
2
|
+
// The hook saved the record itself and may point to it with redirectToRecordId; the admin panel treats it as a success.
|
|
3
|
+
const HOOK_ABORT_ERROR = 'Operation aborted by hook';
|
|
4
|
+
export function isErrorOutput(status, output) {
|
|
5
|
+
if (status >= 400)
|
|
6
|
+
return true;
|
|
7
|
+
if (!output || typeof output !== 'object')
|
|
8
|
+
return false;
|
|
9
|
+
const { error, ok } = output;
|
|
10
|
+
if (error === HOOK_ABORT_ERROR)
|
|
11
|
+
return false;
|
|
12
|
+
return 'error' in output || ok === false;
|
|
13
|
+
}
|