@nocobase/plugin-ai 2.1.9 → 2.1.10
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/ai/docs/nocobase/api/cli/app/restart.md +4 -0
- package/dist/ai/docs/nocobase/api/cli/app/start.md +7 -0
- package/dist/ai/docs/nocobase/api/cli/app/upgrade.md +6 -0
- package/dist/ai/docs/nocobase/api/cli/init.md +39 -2
- package/dist/ai/docs/nocobase/api/cli/source/download.md +19 -0
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/validation.md +11 -8
- package/dist/ai/docs/nocobase/interface-builder/fields/field-settings/validation-rules.md +6 -2
- package/dist/client/580.05dc0322d3a747be.js +10 -0
- package/dist/client/ai-employees/admin/mcp/schemas.d.ts +57 -17
- package/dist/client/index.js +1 -1
- package/dist/collections/ai-mcp-clients.js +5 -0
- package/dist/externalVersion.js +16 -16
- package/dist/locale/en-US.json +6 -3
- package/dist/locale/zh-CN.json +6 -3
- package/dist/node_modules/@langchain/xai/package.json +1 -1
- package/dist/node_modules/fs-extra/package.json +1 -1
- package/dist/node_modules/jsonrepair/package.json +1 -1
- package/dist/node_modules/just-bash/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/node_modules/openai/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/ai-employees/ai-employee.js +8 -3
- package/dist/server/plugin.d.ts +2 -0
- package/dist/server/plugin.js +30 -0
- package/dist/server/resource/aiConversations.js +1 -1
- package/dist/server/resource/aiMcpClients.js +2 -2
- package/dist/server/resource/aiTools.js +14 -9
- package/package.json +2 -2
- package/dist/client/580.e75f97fb883ad042.js +0 -10
|
@@ -35,6 +35,10 @@ If you explicitly pass `--env` and it differs from the current env, the CLI asks
|
|
|
35
35
|
|
|
36
36
|
By default, when applicable, the CLI first runs `nb license plugins sync --skip-if-no-license` to synchronize the commercial plugins allowed by the current license. Then local envs automatically complete any required install or upgrade preparation before starting again, and Docker envs complete that step before recreating the container. Whenever the CLI needs to wait for readiness, it checks `__health_check`: it prints one waiting line first, then one progress line every 10 seconds until the app becomes available or times out.
|
|
37
37
|
|
|
38
|
+
## Hook Scripts
|
|
39
|
+
|
|
40
|
+
If the current env saved a hook with `nb init --hook-script`, `nb app restart` runs `afterAppStart(context)` once after the app restarts and passes `__health_check`. It uses `context.phase = 'app-start'` and `context.command = 'app:restart'`.
|
|
41
|
+
|
|
38
42
|
## Related Commands
|
|
39
43
|
|
|
40
44
|
- [`nb app start`](./start.md)
|
|
@@ -34,6 +34,13 @@ nb app start --env local-docker
|
|
|
34
34
|
If you explicitly pass `--env` and it differs from the current env, the CLI asks for confirmation first. In non-interactive terminals or AI agent sessions, add `--yes` yourself or run `nb env use <name>` first and try again.
|
|
35
35
|
|
|
36
36
|
By default, when applicable, the CLI first runs `nb license plugins sync --skip-if-no-license` to synchronize the commercial plugins allowed by the current license. Then local envs automatically complete any required install or upgrade preparation before starting, and Docker envs recreate the app container from saved env config. Whenever the CLI needs to wait for readiness, it checks `__health_check`: it prints one waiting line first, then one progress line every 10 seconds until the app becomes available or times out.
|
|
37
|
+
|
|
38
|
+
## Hook Scripts
|
|
39
|
+
|
|
40
|
+
If the current env saved a hook with `nb init --hook-script`, `nb app start` runs `afterAppStart(context)` after the app actually starts and passes `__health_check`. Installed envs use `context.phase = 'app-start'` and `context.command = 'app:start'`. If the app is already running, this command does not run the hook.
|
|
41
|
+
|
|
42
|
+
For prepared envs created with `--prepare-only`, the first `nb app start` runs `beforeAppInstall(context)`, completes the first install and startup, then runs `afterAppStart(context)`. Both hooks receive `context.phase = 'init'` and `context.command = 'app:start'`.
|
|
43
|
+
|
|
37
44
|
## Related Commands
|
|
38
45
|
|
|
39
46
|
- [`nb app stop`](./stop.md)
|
|
@@ -58,6 +58,12 @@ Step 4 automatically completes any required upgrade preparation for the current
|
|
|
58
58
|
|
|
59
59
|
If the final `nb env update` step fails, the upgrade still counts as successful. The CLI prints a warning and tells you to run `nb env update <envName>` manually afterward.
|
|
60
60
|
|
|
61
|
+
## Hook Scripts
|
|
62
|
+
|
|
63
|
+
If the current env saved a hook with `nb init --hook-script`, `nb app upgrade` passes the upgrade lifecycle to the hook. For npm/Git source, source refresh runs `beforeDependencyInstall(context)` before dependency installation with `context.phase = 'upgrade'` and `context.command = 'app:upgrade'`.
|
|
64
|
+
|
|
65
|
+
The app upgrade startup step then runs `beforeAppInstall(context)`, and after the app starts and passes `__health_check`, it runs `afterAppStart(context)`. Both hooks also use `context.phase = 'upgrade'` and `context.command = 'app:upgrade'`. Docker source does not run `beforeDependencyInstall`, but it does run the app-level hooks.
|
|
66
|
+
|
|
61
67
|
## Related Commands
|
|
62
68
|
|
|
63
69
|
- [`nb source download`](../source/download.md)
|
|
@@ -42,7 +42,7 @@ nb init --env app1 --resume
|
|
|
42
42
|
|
|
43
43
|
`--prepare-only` is intended for flows where the env should be prepared first, then the license is activated, and only after that the app is installed and started.
|
|
44
44
|
|
|
45
|
-
If you want to save the env config
|
|
45
|
+
If you want to save the env config and prepare the database first, while delaying dependency download, app installation, and first startup, you can use:
|
|
46
46
|
|
|
47
47
|
```bash
|
|
48
48
|
nb init --env app1 --prepare-only
|
|
@@ -67,6 +67,7 @@ By default, the CLI organizes local files under `app-path` using the following c
|
|
|
67
67
|
|
|
68
68
|
```text
|
|
69
69
|
<app-path>/
|
|
70
|
+
├── .nb/ # CLI metadata for this env, such as hooks.mjs
|
|
70
71
|
├── source/ # Default directory for app source code or downloaded content
|
|
71
72
|
├── storage/ # Runtime data directory
|
|
72
73
|
└── .env # Optional app environment variable file
|
|
@@ -74,6 +75,7 @@ By default, the CLI organizes local files under `app-path` using the following c
|
|
|
74
75
|
|
|
75
76
|
Typically:
|
|
76
77
|
|
|
78
|
+
- `.nb/` stores CLI-managed metadata. A script passed with `--hook-script` is copied to `<app-path>/.nb/hooks.mjs`, so later `nb app upgrade` and local source restore can reuse it
|
|
77
79
|
- `source/` mainly corresponds to the local app directory for npm / Git envs. For Docker envs, the CLI also keeps this default path derivation, but most of the time you do not need to care about it manually. Pay special attention during upgrades: the `source/` directory will be deleted and downloaded again, so do not put files you need to keep here
|
|
78
80
|
- `storage/` is used for runtime data, such as built-in database data, plugins, logs, and more
|
|
79
81
|
- `.env` is an optional app environment variable file. You only need to add it in `<app-path>/.env` when you want to customize environment variables; if this file exists, Docker, npm, and Git install sources will all read it by default
|
|
@@ -101,7 +103,7 @@ If you are following the local UI wizard step by step, you can first use the tab
|
|
|
101
103
|
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
102
104
|
| `Getting started` | `--env`、`--yes`、`--ui`、`--locale`、`--verbose`、`--skip-skills`、`--resume` |
|
|
103
105
|
| `App environment` | `--lang`、`--app-path`、`--app-port`、`--force` |
|
|
104
|
-
| `App source and version` | `--source`、`--version`、`--skip-download`、`--git-url`、`--docker-registry`、`--docker-platform`、`--npm-registry`、`--replace`、`--dev-dependencies`、`--output-dir`、`--docker-save`、`--build`、`--build-dts` |
|
|
106
|
+
| `App source and version` | `--source`、`--version`、`--skip-download`、`--git-url`、`--docker-registry`、`--docker-platform`、`--npm-registry`、`--replace`、`--dev-dependencies`、`--output-dir`、`--docker-save`、`--build`、`--build-dts`、`--hook-script` |
|
|
105
107
|
| `Configure the database` | `--builtin-db`、`--db-dialect`、`--builtin-db-image`、`--db-host`、`--db-port`、`--db-database`、`--db-user`、`--db-password`、`--db-schema`、`--db-table-prefix`、`--db-underscored` |
|
|
106
108
|
| `Create an admin account` | `--root-username`、`--root-email`、`--root-password`、`--root-nickname` |
|
|
107
109
|
| `Remote connection` | `--api-base-url`、`--auth-type`、`--access-token`、`--username`、`--password`、`--skip-auth` |
|
|
@@ -184,6 +186,7 @@ The “Default” below means the value or behavior that `nb init` usually uses
|
|
|
184
186
|
| `--npm-registry` | string | Empty | Registry used for npm/Git download and dependency installation |
|
|
185
187
|
| `--build` / `--no-build` | boolean | `true` | Whether to build after installing npm/Git dependencies |
|
|
186
188
|
| `--build-dts` | boolean | `false` | Whether to generate TypeScript declaration files during npm/Git builds |
|
|
189
|
+
| `--hook-script` | string | None | Copy the specified hook module to `<app-path>/.nb/hooks.mjs` and save it in the env config; supports the `beforeDependencyInstall`, `beforeAppInstall`, and `afterAppStart` lifecycle hooks |
|
|
187
190
|
|
|
188
191
|
## Examples
|
|
189
192
|
|
|
@@ -233,6 +236,40 @@ nb init --env app1 --yes --source git --version latest \
|
|
|
233
236
|
--git-url https://gitee.com/nocobase/nocobase.git
|
|
234
237
|
```
|
|
235
238
|
|
|
239
|
+
### Extend the install flow with a hook script
|
|
240
|
+
|
|
241
|
+
If you need to prepare extra content during installation, pass a local ESM module with `--hook-script`:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
nb init --env app1 --yes --source git --hook-script ./hooks.mjs
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
The CLI copies this file to `<app-path>/.nb/hooks.mjs` and saves `hookScript: ".nb/hooks.mjs"` in the env config. Later `nb app start`, `nb app restart`, and `nb app upgrade` reuse it from that location.
|
|
248
|
+
|
|
249
|
+
The hook file must default-export an object. Implement only the methods you need:
|
|
250
|
+
|
|
251
|
+
```js
|
|
252
|
+
export default {
|
|
253
|
+
beforeDependencyInstall: async (context) => {
|
|
254
|
+
// Runs after git clone / npm scaffold and before yarn install.
|
|
255
|
+
},
|
|
256
|
+
beforeAppInstall: async (context) => {
|
|
257
|
+
// Runs before the app-level install or upgrade command.
|
|
258
|
+
},
|
|
259
|
+
afterAppStart: async (context) => {
|
|
260
|
+
// Runs after the app actually starts and passes the health check.
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
- `beforeDependencyInstall` only applies to npm/Git source and runs right before the real `yarn install`; Docker source does not run it
|
|
266
|
+
- `beforeAppInstall` runs before app-level install or upgrade commands, and applies to npm/Git/Docker source
|
|
267
|
+
- `afterAppStart` runs after the app actually starts and passes `__health_check`; `nb app start`, `nb app restart`, and `nb app upgrade` may all trigger it
|
|
268
|
+
|
|
269
|
+
`--prepare-only` only saves the env config and copies the hook file. It does not execute hooks. When you later run `nb app start` for the first time, the CLI runs the first-install hooks with `context.phase` set to `init` and `context.command` set to `app:start`.
|
|
270
|
+
|
|
271
|
+
`context` includes lifecycle information such as `phase`, `command`, `source`, `version`, `appPath`, `sourcePath`, `storagePath`, `hookScript`, and `envConfig`. If a hook throws, the current CLI command fails. Because `afterAppStart` can run repeatedly during start, restart, and upgrade flows, keep it idempotent.
|
|
272
|
+
|
|
236
273
|
### Quick install and use basic authentication
|
|
237
274
|
|
|
238
275
|
If you want to quickly install a local app in non-interactive mode and directly save `basic` authentication after installation, you can also write it like this. This way, you do not need to open a browser to complete OAuth.
|
|
@@ -33,6 +33,7 @@ nb source download [flags]
|
|
|
33
33
|
| `--npm-registry` | string | Registry used for npm/Git downloads and dependency installation |
|
|
34
34
|
| `--build` / `--no-build` | boolean | Whether to build after npm/Git dependency installation |
|
|
35
35
|
| `--build-dts` | boolean | Whether to generate TypeScript declaration files during npm/Git build |
|
|
36
|
+
| `--hook-script` | string | Hook module to run after npm scaffold or Git clone and before dependency installation; only applies to npm/Git source |
|
|
36
37
|
|
|
37
38
|
## Examples
|
|
38
39
|
|
|
@@ -47,8 +48,26 @@ nb source download --source git --version alpha --git-url=git@github.com:nocobas
|
|
|
47
48
|
nb source download --source git --version fix/cli-v2
|
|
48
49
|
nb source download -y --source npm --version alpha --build-dts
|
|
49
50
|
nb source download -y --source npm --version alpha --npm-registry=https://registry.npmmirror.com
|
|
51
|
+
nb source download -y --source git --version beta --hook-script ./hooks.mjs
|
|
50
52
|
```
|
|
51
53
|
|
|
54
|
+
## Pre-install hook
|
|
55
|
+
|
|
56
|
+
`--hook-script` only affects the current `nb source download` run. If you want the hook to be saved with the env and reused by `nb app upgrade` or local source restore, pass it through [`nb init --hook-script`](../init.md) instead.
|
|
57
|
+
|
|
58
|
+
The hook file must default-export an object with `beforeDependencyInstall(context)`:
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
export default {
|
|
62
|
+
beforeDependencyInstall: async ({ sourcePath, version, envConfig }) => {
|
|
63
|
+
// Runs after git clone / npm scaffold and before yarn install.
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
When you run `nb source download --hook-script` directly, `beforeDependencyInstall` receives `context.phase` as `source-download` and `context.command` as `source:download`. This command does not run `beforeAppInstall` or `afterAppStart`; those hooks belong to app install, start, restart, and upgrade flows.
|
|
69
|
+
|
|
70
|
+
|
|
52
71
|
## Version Aliases
|
|
53
72
|
|
|
54
73
|
With Git source, common dist-tags are resolved to branches: `latest` -> `main`, `beta` -> `next`, `alpha` -> `develop`.
|
|
@@ -78,6 +78,9 @@ After configuring field rules, the corresponding validation rules will be trigge
|
|
|
78
78
|
|
|
79
79
|

|
|
80
80
|
|
|
81
|
+
When the field is used in a form, field validation rules are also displayed in the field validation settings. These rules appear under **Server-side field validation rules** and are read-only there. If you need to change them, edit the field in Data source → Collection configuration.
|
|
82
|
+
|
|
83
|
+
You can still add extra rules for the current form field under **Client-side validation rules**. These rules only apply to the current field component. The final validation result combines **Server-side field validation rules** and **Client-side validation rules**.
|
|
81
84
|
|
|
82
85
|
Validation rules also apply to sub-table and sub-form components:
|
|
83
86
|
|
|
@@ -93,12 +96,12 @@ Note that in sub-form or sub-table scenarios, required validation for associatio
|
|
|
93
96
|

|
|
94
97
|
|
|
95
98
|
|
|
96
|
-
## Differences
|
|
97
|
-
|
|
99
|
+
## Differences Between Server-Side Field Validation Rules and Client-Side Validation Rules
|
|
100
|
+
Server-side field validation rules and client-side validation rules are configured in different places and have different scopes.
|
|
98
101
|
|
|
99
102
|
### Configuration Method Differences
|
|
100
|
-
- **
|
|
101
|
-
- **
|
|
103
|
+
- **Server-side field validation rules**: Set field rules in Data source → Collection configuration. These rules are the base rules of the field.
|
|
104
|
+
- **Client-side validation rules**: Configure extra rules in a form field's settings. These rules only affect the current field component.
|
|
102
105
|
|
|
103
106
|

|
|
104
107
|
|
|
@@ -109,7 +112,7 @@ Client-side and server-side field validation are applied in different scenarios,
|
|
|
109
112
|
|
|
110
113
|
|
|
111
114
|
### Validation Trigger Timing Differences
|
|
112
|
-
- **
|
|
113
|
-
- **
|
|
114
|
-
- **
|
|
115
|
-
- **Error messages**: Client-side validation
|
|
115
|
+
- **Server-side field validation rules**: Trigger frontend validation when the field is used in a form, and also validate before data is written. They also apply to scenarios that create or update data, such as workflows and data imports.
|
|
116
|
+
- **Client-side validation rules**: Trigger frontend validation in the current form field only.
|
|
117
|
+
- **Rule display**: Server-side field validation rules are shown as inherited read-only rules. Client-side validation rules are shown separately and can be edited there.
|
|
118
|
+
- **Error messages**: Client-side validation rules support custom error messages, while server-side field validation rules do not currently support custom error messages.
|
|
@@ -30,10 +30,14 @@ Most fields support the configuration of validation rules. After a field is conf
|
|
|
30
30
|

|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
###
|
|
33
|
+
### Client-Side Validation Rules in Field Settings
|
|
34
34
|
|
|
35
35
|
Validation rules set in the field configuration will trigger frontend validation to ensure user input complies with the regulations.
|
|
36
36
|
|
|
37
|
+
If the corresponding collection field already has validation rules, those rules are shown in the validation settings under **Server-side field validation rules**. They are inherited from the data source field configuration and are read-only here. If you need to change them, edit the collection field in Data source → Collection configuration.
|
|
38
|
+
|
|
39
|
+
Rules added under **Client-side validation rules** only apply to the current field component. They do not change the collection field configuration. When both groups exist, NocoBase applies the inherited field rules and client-side validation rules together.
|
|
40
|
+
|
|
37
41
|
|
|
38
42
|

|
|
39
43
|
|
|
@@ -45,4 +49,4 @@ Validation rules set in the field configuration will trigger frontend validation
|
|
|
45
49
|
**Text fields** also support custom regex validation to meet specific format requirements.
|
|
46
50
|
|
|
47
51
|
|
|
48
|
-

|
|
52
|
+

|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_ai=self.webpackChunk_nocobase_plugin_ai||[]).push([["580"],{7439:function(e,t,n){n.r(t),n.d(t,{MCPSettings:function(){return eh}});var r=n(3342),o=n(5477),a=n(7375),i=n(2059),l=n(9452),s=n(5230),u=n(9155),c=n.n(u),p={name:"aiMcpClients",fields:[{name:"name",type:"uid",primaryKey:!0},{name:"title",type:"string",interface:"input",uiSchema:{title:'{{t("Title")}}',"x-component":"Input"}},{name:"description",type:"string",interface:"input",uiSchema:{title:'{{t("Description")}}',"x-component":"Input.TextArea"}},{name:"enabled",type:"boolean",defaultValue:!0},{name:"transport",type:"string",interface:"select",uiSchema:{title:'{{t("Transport")}}',"x-component":"Select"}},{name:"useUserContext",type:"boolean",defaultValue:!1},{name:"command",type:"string",interface:"input",uiSchema:{title:'{{t("Command")}}',"x-component":"Input"}},{name:"args",type:"json",defaultValue:[]},{name:"env",type:"json",defaultValue:{}},{name:"url",type:"string",interface:"input",uiSchema:{title:'{{t("URL")}}',"x-component":"Input"}},{name:"headers",type:"json",defaultValue:{}},{name:"restart",type:"json",defaultValue:{}}]},m=n(3079);function d(e,t,n,r,o,a,i){try{var l=e[a](i),s=l.value}catch(e){n(e);return}l.done?t(s):Promise.resolve(s).then(r,o)}var f=(0,u.createContext)({rebuildClient:function(){var e;return(e=function(){return function(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:s(0)}),l(i,"throw",{value:s(1)}),l(i,"return",{value:s(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;function s(l){return function(s){var u=[l,s];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return[2,void 0]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){d(a,r,o,i,l,"next",e)}function l(e){d(a,r,o,i,l,"throw",e)}i(void 0)})})()},rebuilding:!1}),y=function(e,t){var n,r,o;return null!=(n=null!=(r=null==e||null==(o=e.data)?void 0:o.data)?r:null==e?void 0:e.data)?n:t};function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function v(e,t,n,r,o,a,i){try{var l=e[a](i),s=l.value}catch(e){n(e);return}l.done?t(s):Promise.resolve(s).then(r,o)}function x(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){v(a,r,o,i,l,"next",e)}function l(e){v(a,r,o,i,l,"throw",e)}i(void 0)})}}function h(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function C(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){l=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return b(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:s(0)}),l(i,"throw",{value:s(1)}),l(i,"return",{value:s(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;function s(l){return function(s){var u=[l,s];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var P=[{label:"Ask",value:"ASK"},{label:"Allow",value:"ALLOW"}],A=function(e,t){var n=null==e?void 0:e[t];return Array.isArray(n)?n:[]},S=function(){var e=(0,m.kj)(),t=(0,r.useAPIClient)(),n=i.App.useApp().message,o=(0,r.useActionContext)().visible,a=(0,r.useCollectionRecordData)(),l=(0,u.useContext)(f).rebuilding,s=g((0,u.useState)([]),2),p=s[0],d=s[1],b=g((0,u.useState)(!1),2),v=b[0],S=b[1],O=g((0,u.useState)(null),2),E=O[0],k=O[1],j=g((0,u.useState)(1),2),I=j[0],T=j[1],M=p.length,R=(0,u.useRef)(n),D=(0,u.useRef)(e);return R.current=n,D.current=e,(0,u.useEffect)(function(){if(o){var e=!1;return x(function(){var n,r;return w(this,function(o){switch(o.label){case 0:S(!0),o.label=1;case 1:return o.trys.push([1,3,4,5]),[4,t.resource("aiMcpClients").listTools()];case 2:return n=A(y(o.sent(),null),a.name),e||(T(1),d(n)),[3,5];case 3:return r=o.sent(),e||(R.current.error((null==r?void 0:r.message)||D.current("Failed to load MCP tools")),T(1),d([])),[3,5];case 4:return e||S(!1),[7];case 5:return[2]}})})(),function(){e=!0}}},[t,a.name,o]),c().createElement(i.Space,{direction:"vertical",size:"middle",style:{width:"100%"}},v?c().createElement("div",{style:{padding:"24px 0",textAlign:"center"}},c().createElement(i.Spin,null)):p.length?c().createElement(i.List,{itemLayout:"vertical",dataSource:p,pagination:{current:I,pageSize:10,total:M,onChange:T,hideOnSinglePage:!1,size:"small",showTotal:function(t){return e("Total {{count}} items",{count:t})}},renderItem:function(n){return c().createElement(i.List.Item,{key:n.name,extra:c().createElement("div",{style:{fontSize:12,color:"var(--nb-color-text-secondary)"}},e("Permission"),c().createElement(i.Segmented,{style:{marginLeft:8},size:"small",options:P.map(function(t){return C(h({},t),{label:e(t.label)})}),value:n.permission,disabled:l||E===n.name,onChange:function(e){var r;return r=n.name,x(function(){var n,o;return w(this,function(a){switch(a.label){case 0:n=p,k(r),d(function(t){return t.map(function(t){return t.name===r?C(h({},t),{permission:e}):t})}),a.label=1;case 1:return a.trys.push([1,3,4,5]),[4,t.resource("aiMcpClients").updateToolPermission({values:{toolName:r,permission:e}})];case 2:return a.sent(),[3,5];case 3:return o=a.sent(),d(n),R.current.error((null==o?void 0:o.message)||D.current("Failed to update tool permission")),[3,5];case 4:return k(null),[7];case 5:return[2]}})})()}}))},c().createElement("div",null,n.title),n.description?c().createElement(i.Typography.Paragraph,{style:{color:"var(--nb-color-text-secondary)",fontSize:12,marginBottom:0},ellipsis:{rows:3,expandable:"collapsible"}},n.description):null)}}):c().createElement(i.Empty,{image:i.Empty.PRESENTED_IMAGE_SIMPLE,description:e("No data")}))};function O(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}var E=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n="stdio"===e?'{{$deps[0] === "stdio"}}':'{{["http", "sse"].includes($deps[0])}}';return[{dependencies:["transport"],fulfill:{state:O({visible:n},t?{required:n}:{})}}]},k=function(e){return{name:O({type:"string","x-decorator":"FormItem",title:'{{ t("Name") }}',"x-component":"Input",required:!0},e.disableName?{"x-component-props":{disabled:!0}}:{}),title:{type:"string","x-decorator":"FormItem",title:'{{ t("Title") }}',"x-component":"Input",required:!0},description:{type:"string","x-decorator":"FormItem",title:'{{ t("Description") }}',"x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:2,maxRows:4}}},transport:{type:"string","x-decorator":"FormItem",title:'{{ t("Transport") }}',"x-component":"Select",enum:"{{ transportOptions }}",required:!0},useUserContext:{type:"boolean","x-decorator":"FormItem",title:'{{ t("Depends on current user") }}',"x-component":"UserContextCheckbox","x-component-props":{tooltip:'{{ t("When enabled, URL and headers can use current user variables, and the MCP server runs per current user. Stdio transport is not supported.") }}'}},command:{type:"string","x-decorator":"FormItem",title:'{{ t("Command") }}',"x-component":"MCPVariableInput","x-component-props":{placeholder:'{{ t("For example: npx, uvx, node") }}'},"x-reactions":E("stdio",!0)},args:{type:"string","x-decorator":"FormItem",title:'{{ t("Arguments") }}',"x-component":"MCPVariableInput","x-component-props":{placeholder:'{{ t("Space-separated args, e.g.: -u --flag value") }}'},"x-reactions":E("stdio")},env:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:'{{ t("Environment variables") }}',items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{style:{flexWrap:"nowrap",maxWidth:"100%",display:"flex"},className:"{{ keyValueRowClassName }}"},properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Name") }}'}},value:{type:"string","x-decorator":"FormItem","x-component":"MCPVariableInput"},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add variable") }}',"x-component":"ArrayItems.Addition"}},"x-reactions":E("stdio")},url:{type:"string","x-decorator":"FormItem",title:'{{ t("URL") }}',"x-component":"MCPVariableInput","x-component-props":{placeholder:'{{ t("For example: https://example.com/mcp") }}',variableScope:"user"},"x-reactions":E("remote",!0)},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:'{{ t("Headers") }}',items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{style:{flexWrap:"nowrap",maxWidth:"100%",display:"flex"},className:"{{ keyValueRowClassName }}"},properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Name") }}'}},value:{type:"string","x-decorator":"FormItem","x-component":"MCPVariableInput","x-component-props":{variableScope:"user"}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add request header") }}',"x-component":"ArrayItems.Addition"}},"x-reactions":E("remote")},restart:{type:"object","x-decorator":"FormItem",title:'{{ t("Restart options") }}',"x-component":"Input.JSON","x-visible":!1,"x-component-props":{autoSize:{minRows:4}}},testResult:{type:"void","x-component":"TestConnectionResult"},footer:{type:"void","x-component":e.footerComponent||"Action.Drawer.Footer",properties:{test:{type:"void","x-component":"TestConnectionButton"},cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":e.submitPropsHook}}}}},j={type:"void",properties:k({submitPropsHook:"useCreateActionProps"})},I={type:"void",properties:k({disableName:!0,submitPropsHook:"useEditActionProps",footerComponent:"Action.Drawer.FootBar"})},T={type:"void",properties:{tools:{type:"void","x-component":"MCPToolsList"}}},M={type:"void",properties:{createDrawer:{type:"void",title:'{{ t("Add new") }}',"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useCreateFormProps",properties:j.properties}}};I.properties,T.properties;var R={type:"void",name:"ai-mcp-clients",properties:{card:{type:"void","x-component":"CardItem","x-component-props":{heightMode:"fullHeight"},"x-decorator":"TableBlockProvider","x-decorator-props":{collection:"aiMcpClients",action:"list",rowKey:"name"},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:20}},properties:{refresh:{title:"{{t('Refresh')}}","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},bulkDelete:{title:"{{t('Delete')}}","x-action":"destroy","x-component":"Action","x-use-component-props":"useMCPBulkDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},add:{type:"void",title:"{{t('Add new')}}","x-align":"right","x-component":"AddNew"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"name",rowSelection:{type:"checkbox"}},properties:{column1:{type:"void",title:'{{ t("Name") }}',"x-component":"TableV2.Column",properties:{name:{type:"string","x-component":"Input","x-read-pretty":!0}}},column2:{type:"void",title:'{{ t("Title") }}',"x-component":"TableV2.Column",properties:{title:{type:"string","x-component":"Input","x-read-pretty":!0}}},column4:{type:"void",title:'{{ t("Transport") }}',"x-component":"TableV2.Column",properties:{transport:{type:"string","x-component":"TransportTag"}}},column5:{type:"void",title:'{{ t("Depends on current user") }}',"x-component":"TableV2.Column",properties:{useUserContext:{type:"boolean","x-component":"Checkbox","x-read-pretty":!0}}},column6:{type:"void",title:'{{ t("Enabled") }}',"x-component":"TableV2.Column",properties:{enabled:{type:"boolean","x-component":"EnabledSwitch"}}},column7:{type:"void",title:'{{ t("Actions") }}',"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{view:{type:"void",title:'{{ t("View") }}',"x-component":"Action.Link","x-component-props":{openMode:"drawer"},properties:{drawer:{type:"void",title:'{{ t("MCP tools") }}',"x-component":"Action.Drawer","x-component-props":{width:720},properties:{content:{type:"void","x-component":"MCPViewDrawerContent"}}}}},edit:{type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer"},properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useEditFormProps",properties:{content:{type:"void","x-component":"MCPEditDrawerContent"}}}}},destroy:{type:"void",title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useMCPDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}}}}}}}};function D(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function V(e,t,n,r,o,a,i){try{var l=e[a](i),s=l.value}catch(e){n(e);return}l.done?t(s):Promise.resolve(s).then(r,o)}function F(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){V(a,r,o,i,l,"next",e)}function l(e){V(a,r,o,i,l,"throw",e)}i(void 0)})}}function N(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function B(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function U(e,t){if(null==e)return{};var n,r,o,a={};if("u">typeof Reflect&&Reflect.ownKeys){for(o=0,n=Reflect.ownKeys(Object(e));o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r]);return a}if(a=function(e,t){if(null==e)return{};var n,r,o={},a=Object.getOwnPropertyNames(e);for(r=0;r<a.length;r++)n=a[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n]);return o}(e,t),Object.getOwnPropertySymbols)for(o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r]);return a}function L(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){l=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw r}}return a}}(e,t)||q(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function z(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function q(e,t){if(e){if("string"==typeof e)return D(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return D(e,t)}}function H(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:s(0)}),l(i,"throw",{value:s(1)}),l(i,"return",{value:s(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;function s(l){return function(s){var u=[l,s];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function _(){var e,t,n=(e=["\n & > .ant-space-item:first-child,\n & > .ant-space-item:last-child {\n flex-shrink: 0;\n }\n\n & > .ant-space-item:first-child,\n & > .ant-space-item:nth-of-type(2) {\n flex: 1;\n }\n"],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return _=function(){return n},n}var K=[{label:"Stdio",value:"stdio"},{label:"HTTP (Streamable)",value:"http"},{label:"HTTP + SSE (Legacy)",value:"sse"}],W={stdio:"blue",http:"green",sse:"gold"},G=(0,o.css)(_()),$=function(e){return Object.entries(e||{}).map(function(e){var t=L(e,2),n=t[0],r=t[1];return{name:n,value:null==r?"":String(r)}})},J=function(e){return(Array.isArray(e)?e:[]).reduce(function(e,t){return(null==t?void 0:t.name)&&(e[t.name]=t.value||""),e},{})},Q=function(e){var t=e.transport,n=B(N({},e),{useUserContext:"stdio"!==t&&!0===e.useUserContext,args:"string"==typeof e.args?e.args.split(" ").map(function(e){return e.trim()}).filter(function(e){return e.length>0}):Array.isArray(e.args)?e.args:[],env:J(e.env),headers:J(e.headers),restart:e.restart&&"object"===z(e.restart)&&!Array.isArray(e.restart)?e.restart:{}});return"stdio"===t?B(N({},n),{url:null,headers:{}}):B(N({},n),{command:null,args:[],env:{}})},X=function(){var e=(0,r.useActionContext)().visible,t=(0,u.useMemo)(function(){return{enabled:!0,transport:"stdio",useUserContext:!1,command:"",url:"",args:"",env:[],headers:[],restart:{}}},[]),n=(0,u.useMemo)(function(){return(0,l.createForm)({initialValues:t})},[t]);return(0,u.useEffect)(function(){e&&(n.setInitialValues(t),n.reset())},[n,t,e]),{form:n}},Y=function(){var e=(0,r.useCollectionRecordData)(),t=(0,r.useActionContext)().visible,n=(0,u.useMemo)(function(){var t,n;return B(N({},e),{useUserContext:(null==e?void 0:e.useUserContext)===!0,command:null!=(t=null==e?void 0:e.command)?t:"",url:null!=(n=null==e?void 0:e.url)?n:"",args:Array.isArray(null==e?void 0:e.args)?e.args.join(" "):"",env:$(null==e?void 0:e.env),headers:$(null==e?void 0:e.headers),restart:(null==e?void 0:e.restart)&&"object"===z(e.restart)&&!Array.isArray(e.restart)?e.restart:{}})},[e]),o=(0,u.useMemo)(function(){return(0,l.createForm)({initialValues:n})},[n]);return(0,u.useEffect)(function(){t&&(o.setInitialValues(n),o.reset())},[o,n,t]),{form:o}},Z=function(){var e=(0,r.useActionContext)().setVisible;return{type:"default",onClick:function(){e(!1)}}},ee=(0,u.createContext)({result:null,loading:!1,setResult:function(){},setLoading:function(){}}),et=function(){var e=(0,r.useAPIClient)(),t=(0,m.kj)(),n=(0,u.useContext)(ee),o=n.setResult,a=n.setLoading;return function(n){return F(function(){var r,i,l;return H(this,function(s){switch(s.label){case 0:a(!0),o(null),s.label=1;case 1:return s.trys.push([1,3,4,5]),r=Q(n),[4,e.resource("aiMcpClients").testConnection({values:r})];case 2:return o(i=y({data:s.sent().data},null)),[2,!!(null==i?void 0:i.success)];case 3:return o({success:!1,error:(null==(l=s.sent())?void 0:l.message)||t("An error occurred while testing the connection")}),[2,!1];case 4:return a(!1),[7];case 5:return[2]}})})()}},en=function(){var e=i.App.useApp().modal,t=(0,m.kj)();return function(){return F(function(){return H(this,function(n){return[2,e.confirm({title:t("Connection test failed"),content:t("The MCP server uses current user variables and the connection test failed. Do you want to save it anyway?"),okText:t("Save anyway"),cancelText:t("Cancel")})]})})()}},er=function(){var e=(0,r.useActionContext)().setVisible,t=i.App.useApp().message,n=(0,s.useForm)(),o=(0,r.useAPIClient)(),a=(0,r.useDataBlockRequest)().refresh,l=(0,m.kj)(),c=(0,u.useContext)(ee).loading,p=(0,u.useContext)(f),d=p.rebuildClient,y=p.rebuilding,b=et(),v=en();return{type:"primary",loading:y||c,onClick:function(){return F(function(){return H(this,function(r){switch(r.label){case 0:return[4,n.submit()];case 1:return r.sent(),[4,b(n.values)];case 2:if(r.sent())return[3,4];if(!0!==Q(n.values).useUserContext)return[2];return[4,v()];case 3:if(!r.sent())return[2];r.label=4;case 4:return[4,o.resource("aiMcpClients").create({values:Q(n.values)})];case 5:return r.sent(),[4,d()];case 6:return r.sent(),[4,a()];case 7:return r.sent(),t.success(l("Saved successfully")),e(!1),n.reset(),[2]}})})()}}},eo=function(){var e=(0,r.useActionContext)().setVisible,t=i.App.useApp().message,n=(0,s.useForm)(),o=(0,r.useAPIClient)(),a=(0,r.useDataBlockRequest)().refresh,l=(0,r.useCollectionRecordData)(),c=(0,m.kj)(),p=(0,u.useContext)(ee).loading,d=(0,u.useContext)(f),y=d.rebuildClient,b=d.rebuilding,v=et(),x=en();return{type:"primary",loading:b||p,onClick:function(){return F(function(){return H(this,function(r){switch(r.label){case 0:return[4,n.submit()];case 1:return r.sent(),[4,v(n.values)];case 2:if(r.sent())return[3,4];if(!0!==Q(n.values).useUserContext)return[2];return[4,x()];case 3:if(!r.sent())return[2];r.label=4;case 4:return[4,o.resource("aiMcpClients").update({values:Q(n.values),filterByTk:l.name})];case 5:return r.sent(),[4,y()];case 6:return r.sent(),[4,a()];case 7:return r.sent(),t.success(c("Saved successfully")),e(!1),n.reset(),[2]}})})()}}},ea=(0,s.observer)(function(){var e=(0,s.useForm)(),t=(0,r.useAPIClient)(),n=(0,u.useContext)(ee),o=n.setResult,a=n.loading,l=n.setLoading,p=(0,m.kj)();return c().createElement(i.Button,{type:"default",loading:a,onClick:function(){return F(function(){var n,r;return H(this,function(a){switch(a.label){case 0:l(!0),o(null),a.label=1;case 1:return a.trys.push([1,3,4,5]),n=Q(e.values),[4,t.resource("aiMcpClients").testConnection({values:n})];case 2:return o(y({data:a.sent().data},null)),[3,5];case 3:return o({success:!1,error:(null==(r=a.sent())?void 0:r.message)||p("An error occurred while testing the connection")}),[3,5];case 4:return l(!1),[7];case 5:return[2]}})})()}},p("Test flight"))},{displayName:"TestConnectionButton"}),ei=(0,s.observer)(function(){var e=(0,u.useContext)(ee),t=e.result,n=e.loading,r=(0,m.kj)();return n?c().createElement("div",{style:{padding:"16px 0",textAlign:"center"}},c().createElement(i.Spin,{tip:r("Testing connection...")})):t?t.success?c().createElement(i.Alert,{type:"success",showIcon:!0,icon:c().createElement(a.CheckCircleOutlined,null),style:{marginTop:16},message:r("Connection Successful"),description:c().createElement("div",null,c().createElement("p",null,r("Successfully connected to MCP server")),c().createElement("p",null,r("Tools found"),": ",t.toolsCount),t.tools&&t.tools.length>0&&c().createElement("div",{style:{marginTop:8}},c().createElement("p",{style:{fontWeight:"bold",marginBottom:4}},r("Tools"),":"),c().createElement("div",{style:{maxHeight:120,overflow:"auto"}},t.tools.map(function(e){return c().createElement(i.Tag,{key:e,style:{margin:"2px"}},e)}),t.toolsTruncated&&c().createElement("span",null,"..."))))}):c().createElement(i.Alert,{type:"error",showIcon:!0,icon:c().createElement(a.CloseCircleOutlined,null),style:{marginTop:16},message:r("Connection Failed"),description:c().createElement("div",null,c().createElement("p",null,t.error||r("Failed to connect to MCP server")),t.details&&c().createElement("pre",{style:{maxHeight:100,overflow:"auto",fontSize:11,margin:0}},t.details))}):null},{displayName:"TestConnectionResult"}),el=function(e){var t=(0,r.useGlobalVariable)("$env"),n=(0,r.useCurrentUserVariable)({maxDepth:3,noDisabled:!0}).currentUserSettings;return(0,u.useMemo)(function(){return[es(t),e?es(n):null].filter(Boolean)},[n,t,e])},es=function(e){if(!e)return null;var t,n,r,o,a,i,l=null!=(t=e.value)?t:e.name,s=null!=(n=e.label)?n:e.title,u=e.loadChildren?function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return F(function(){var n,o,a;return H(this,function(i){switch(i.label){case 0:return[4,null==(o=e.loadChildren)?void 0:(n=o).call.apply(n,[e,t].concat(function(e){if(Array.isArray(e))return D(e)}(r)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||q(r)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()))];case 1:return i.sent(),t.children=null==(a=t.children)?void 0:a.map(function(e){return es(e)}).filter(function(e){return!!e}),[2]}})})()}:void 0;return N(B(N({},e),{name:null!=(r=e.name)?r:l,title:null!=(o=e.title)?o:s,value:l,label:s,key:null!=(a=e.key)?a:l,children:null==(i=e.children)?void 0:i.map(function(e){return es(e)}).filter(function(e){return!!e})}),u?{loadChildren:u}:{})},eu={value:"name",label:"title"},ec=(0,s.observer)(function(e){var t=e.variableScope,n=U(e,["variableScope"]),o=(0,s.useForm)(),a=el("user"===(void 0===t?"env":t)&&!0===o.values.useUserContext);return c().createElement(r.Variable.TextArea,B(N({},n),{scope:a,fieldNames:eu,trim:!1}))},{displayName:"MCPVariableInput"}),ep=(0,s.observer)(function(e){var t=e.tooltip,n=U(e,["tooltip"]),o=(0,s.useForm)(),a="stdio"===o.values.transport;(0,u.useEffect)(function(){a&&o.values.useUserContext&&o.setValuesIn("useUserContext",!1)},[a,o]);var l=c().createElement(r.Checkbox,B(N({},n),{disabled:a||e.disabled}));return t?c().createElement(i.Tooltip,{title:t},l):l},{displayName:"UserContextCheckbox"}),em=function(){var e=(0,m.kj)(),t=L((0,u.useState)(!1),2),n=t[0],o=t[1],l=L((0,u.useState)(null),2),s=l[0],p=l[1],d=L((0,u.useState)(!1),2),f=d[0],y=d[1],b=(0,u.useMemo)(function(){return{result:s,loading:f,setResult:p,setLoading:y}},[s,f]);return c().createElement(r.ActionContextProvider,{value:{visible:n,setVisible:o}},c().createElement(i.Button,{icon:c().createElement(a.PlusOutlined,null),type:"primary",onClick:function(){p(null),y(!1),o(!0)}},e("Add new")),c().createElement(ee.Provider,{value:b},c().createElement(r.SchemaComponent,{components:{TestConnectionButton:ea,TestConnectionResult:ei,Space:i.Space,MCPVariableInput:ec,UserContextCheckbox:ep},scope:{t:e,transportOptions:K,keyValueRowClassName:G,useCreateFormProps:X,useCancelActionProps:Z,useCreateActionProps:er},schema:M})))},ed=function(){var e=(0,m.kj)(),t=(0,r.useCollectionRecordData)(),n=L((0,u.useState)(null),2),o=n[0],a=n[1],l=L((0,u.useState)(!1),2),s=l[0],p=l[1],d=(0,u.useMemo)(function(){return{result:o,loading:s,setResult:a,setLoading:p}},[o,s]);return c().createElement(r.CollectionRecordProvider,{record:t},c().createElement(ee.Provider,{value:d},c().createElement(r.SchemaComponent,{components:{TestConnectionButton:ea,TestConnectionResult:ei,Space:i.Space,MCPVariableInput:ec,UserContextCheckbox:ep},scope:{t:e,transportOptions:K,keyValueRowClassName:G,useEditFormProps:Y,useCancelActionProps:Z,useEditActionProps:eo},schema:I})))},ef=function(){var e=(0,m.kj)(),t=(0,r.useCollectionRecordData)();return c().createElement(r.CollectionRecordProvider,{record:t},c().createElement(r.SchemaComponent,{components:{MCPToolsList:S},scope:{t:e},schema:T}))},ey=function(){var e,t=(0,r.useCollectionRecordData)().transport,n=(null==(e=K.find(function(e){return e.value===t}))?void 0:e.label)||t;return c().createElement(i.Tag,{color:W[t]},n)},eb=(0,s.observer)(function(){var e=(0,r.useAPIClient)(),t=(0,r.useCollectionRecordData)(),n=(0,r.useDataBlockRequest)().refresh,o=(0,u.useContext)(f),a=o.rebuildClient,l=o.rebuilding,s=L((0,u.useState)(!1),2),p=s[0],m=s[1];return c().createElement(i.Switch,{size:"small",checked:!1!==t.enabled,loading:p,disabled:l,onChange:function(r){return F(function(){return H(this,function(o){switch(o.label){case 0:m(!0),o.label=1;case 1:return o.trys.push([1,,5,6]),[4,e.resource("aiMcpClients").update({filterByTk:t.name,values:{enabled:r}})];case 2:return o.sent(),[4,a()];case 3:return o.sent(),[4,n()];case 4:return o.sent(),[3,6];case 5:return m(!1),[7];case 6:return[2]}})})()}})},{displayName:"MCPEnabledSwitch"}),ev=function(){var e=(0,r.useDestroyActionProps)(),t=(0,u.useContext)(f),n=t.rebuildClient,o=t.rebuilding;return B(N({},e),{loading:o,onClick:function(t,r){return F(function(){var o;return H(this,function(a){switch(a.label){case 0:return[4,null==(o=e.onClick)?void 0:o.call(e,t,r)];case 1:return a.sent(),[4,n()];case 2:return a.sent(),[2]}})})()}})},ex=function(){var e=(0,r.useBulkDestroyActionProps)(),t=(0,r.useBlockRequestContext)().field,n=(0,u.useContext)(f),o=n.rebuildClient,a=n.rebuilding;return B(N({},e),{loading:a,onClick:function(n,r){return F(function(){var a,i,l;return H(this,function(s){switch(s.label){case 0:if(!(null==t||null==(i=t.data)||null==(a=i.selectedRowKeys)?void 0:a.length))return[2];return[4,null==(l=e.onClick)?void 0:l.call(e,n,r)];case 1:return s.sent(),[4,o()];case 2:return s.sent(),[2]}})})()}})},eh=function(){var e=(0,m.kj)(),t=(0,r.useAPIClient)(),n=(0,u.useRef)(Promise.resolve()),o=(0,u.useRef)(0),a=L((0,u.useState)(!1),2),i=a[0],l=a[1],s=(0,u.useCallback)(function(){return F(function(){var e;return H(this,function(r){return o.current+=1,l(!0),e=n.current.catch(function(){}).then(function(){return F(function(){return H(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,t.resource("aiMcpClients").rebuildClient()];case 1:case 2:return e.sent(),[3,3];case 3:return[2]}})})()}),n.current=e.finally(function(){o.current-=1,0===o.current&&l(!1)}),[2,e]})})()},[t]),d=(0,u.useMemo)(function(){return{rebuildClient:s,rebuilding:i}},[s,i]);return c().createElement(f.Provider,{value:d},c().createElement(r.ExtendCollectionsProvider,{collections:[p]},c().createElement(r.SchemaComponent,{components:{AddNew:em,MCPEditDrawerContent:ed,MCPViewDrawerContent:ef,MCPToolsList:S,TestConnectionButton:ea,TestConnectionResult:ei,MCPVariableInput:ec,UserContextCheckbox:ep,TransportTag:ey,EnabledSwitch:eb},scope:{t:e,transportOptions:K,keyValueRowClassName:G,useCreateFormProps:X,useEditFormProps:Y,useCancelActionProps:Z,useCreateActionProps:er,useEditActionProps:eo,useMCPDestroyActionProps:ev,useMCPBulkDestroyActionProps:ex},schema:R})))}}}]);
|
|
@@ -46,6 +46,15 @@ export declare const createMCPFormContentSchema: {
|
|
|
46
46
|
enum: string;
|
|
47
47
|
required: boolean;
|
|
48
48
|
};
|
|
49
|
+
useUserContext: {
|
|
50
|
+
type: string;
|
|
51
|
+
'x-decorator': string;
|
|
52
|
+
title: string;
|
|
53
|
+
'x-component': string;
|
|
54
|
+
'x-component-props': {
|
|
55
|
+
tooltip: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
49
58
|
command: {
|
|
50
59
|
type: string;
|
|
51
60
|
'x-decorator': string;
|
|
@@ -114,9 +123,6 @@ export declare const createMCPFormContentSchema: {
|
|
|
114
123
|
type: string;
|
|
115
124
|
'x-decorator': string;
|
|
116
125
|
'x-component': string;
|
|
117
|
-
'x-component-props': {
|
|
118
|
-
useTypedConstant: boolean;
|
|
119
|
-
};
|
|
120
126
|
};
|
|
121
127
|
remove: {
|
|
122
128
|
type: string;
|
|
@@ -151,6 +157,7 @@ export declare const createMCPFormContentSchema: {
|
|
|
151
157
|
'x-component': string;
|
|
152
158
|
'x-component-props': {
|
|
153
159
|
placeholder: string;
|
|
160
|
+
variableScope: string;
|
|
154
161
|
};
|
|
155
162
|
'x-reactions': {
|
|
156
163
|
dependencies: string[];
|
|
@@ -195,7 +202,7 @@ export declare const createMCPFormContentSchema: {
|
|
|
195
202
|
'x-decorator': string;
|
|
196
203
|
'x-component': string;
|
|
197
204
|
'x-component-props': {
|
|
198
|
-
|
|
205
|
+
variableScope: string;
|
|
199
206
|
};
|
|
200
207
|
};
|
|
201
208
|
remove: {
|
|
@@ -305,6 +312,15 @@ export declare const editMCPFormContentSchema: {
|
|
|
305
312
|
enum: string;
|
|
306
313
|
required: boolean;
|
|
307
314
|
};
|
|
315
|
+
useUserContext: {
|
|
316
|
+
type: string;
|
|
317
|
+
'x-decorator': string;
|
|
318
|
+
title: string;
|
|
319
|
+
'x-component': string;
|
|
320
|
+
'x-component-props': {
|
|
321
|
+
tooltip: string;
|
|
322
|
+
};
|
|
323
|
+
};
|
|
308
324
|
command: {
|
|
309
325
|
type: string;
|
|
310
326
|
'x-decorator': string;
|
|
@@ -373,9 +389,6 @@ export declare const editMCPFormContentSchema: {
|
|
|
373
389
|
type: string;
|
|
374
390
|
'x-decorator': string;
|
|
375
391
|
'x-component': string;
|
|
376
|
-
'x-component-props': {
|
|
377
|
-
useTypedConstant: boolean;
|
|
378
|
-
};
|
|
379
392
|
};
|
|
380
393
|
remove: {
|
|
381
394
|
type: string;
|
|
@@ -410,6 +423,7 @@ export declare const editMCPFormContentSchema: {
|
|
|
410
423
|
'x-component': string;
|
|
411
424
|
'x-component-props': {
|
|
412
425
|
placeholder: string;
|
|
426
|
+
variableScope: string;
|
|
413
427
|
};
|
|
414
428
|
'x-reactions': {
|
|
415
429
|
dependencies: string[];
|
|
@@ -454,7 +468,7 @@ export declare const editMCPFormContentSchema: {
|
|
|
454
468
|
'x-decorator': string;
|
|
455
469
|
'x-component': string;
|
|
456
470
|
'x-component-props': {
|
|
457
|
-
|
|
471
|
+
variableScope: string;
|
|
458
472
|
};
|
|
459
473
|
};
|
|
460
474
|
remove: {
|
|
@@ -580,6 +594,15 @@ export declare const createMCPSchema: {
|
|
|
580
594
|
enum: string;
|
|
581
595
|
required: boolean;
|
|
582
596
|
};
|
|
597
|
+
useUserContext: {
|
|
598
|
+
type: string;
|
|
599
|
+
'x-decorator': string;
|
|
600
|
+
title: string;
|
|
601
|
+
'x-component': string;
|
|
602
|
+
'x-component-props': {
|
|
603
|
+
tooltip: string;
|
|
604
|
+
};
|
|
605
|
+
};
|
|
583
606
|
command: {
|
|
584
607
|
type: string;
|
|
585
608
|
'x-decorator': string;
|
|
@@ -648,9 +671,6 @@ export declare const createMCPSchema: {
|
|
|
648
671
|
type: string;
|
|
649
672
|
'x-decorator': string;
|
|
650
673
|
'x-component': string;
|
|
651
|
-
'x-component-props': {
|
|
652
|
-
useTypedConstant: boolean;
|
|
653
|
-
};
|
|
654
674
|
};
|
|
655
675
|
remove: {
|
|
656
676
|
type: string;
|
|
@@ -685,6 +705,7 @@ export declare const createMCPSchema: {
|
|
|
685
705
|
'x-component': string;
|
|
686
706
|
'x-component-props': {
|
|
687
707
|
placeholder: string;
|
|
708
|
+
variableScope: string;
|
|
688
709
|
};
|
|
689
710
|
'x-reactions': {
|
|
690
711
|
dependencies: string[];
|
|
@@ -729,7 +750,7 @@ export declare const createMCPSchema: {
|
|
|
729
750
|
'x-decorator': string;
|
|
730
751
|
'x-component': string;
|
|
731
752
|
'x-component-props': {
|
|
732
|
-
|
|
753
|
+
variableScope: string;
|
|
733
754
|
};
|
|
734
755
|
};
|
|
735
756
|
remove: {
|
|
@@ -848,6 +869,15 @@ export declare const editMCPDrawerSchema: {
|
|
|
848
869
|
enum: string;
|
|
849
870
|
required: boolean;
|
|
850
871
|
};
|
|
872
|
+
useUserContext: {
|
|
873
|
+
type: string;
|
|
874
|
+
'x-decorator': string;
|
|
875
|
+
title: string;
|
|
876
|
+
'x-component': string;
|
|
877
|
+
'x-component-props': {
|
|
878
|
+
tooltip: string;
|
|
879
|
+
};
|
|
880
|
+
};
|
|
851
881
|
command: {
|
|
852
882
|
type: string;
|
|
853
883
|
'x-decorator': string;
|
|
@@ -916,9 +946,6 @@ export declare const editMCPDrawerSchema: {
|
|
|
916
946
|
type: string;
|
|
917
947
|
'x-decorator': string;
|
|
918
948
|
'x-component': string;
|
|
919
|
-
'x-component-props': {
|
|
920
|
-
useTypedConstant: boolean;
|
|
921
|
-
};
|
|
922
949
|
};
|
|
923
950
|
remove: {
|
|
924
951
|
type: string;
|
|
@@ -953,6 +980,7 @@ export declare const editMCPDrawerSchema: {
|
|
|
953
980
|
'x-component': string;
|
|
954
981
|
'x-component-props': {
|
|
955
982
|
placeholder: string;
|
|
983
|
+
variableScope: string;
|
|
956
984
|
};
|
|
957
985
|
'x-reactions': {
|
|
958
986
|
dependencies: string[];
|
|
@@ -997,7 +1025,7 @@ export declare const editMCPDrawerSchema: {
|
|
|
997
1025
|
'x-decorator': string;
|
|
998
1026
|
'x-component': string;
|
|
999
1027
|
'x-component-props': {
|
|
1000
|
-
|
|
1028
|
+
variableScope: string;
|
|
1001
1029
|
};
|
|
1002
1030
|
};
|
|
1003
1031
|
remove: {
|
|
@@ -1194,13 +1222,25 @@ export declare const mcpSettingsSchema: {
|
|
|
1194
1222
|
title: string;
|
|
1195
1223
|
'x-component': string;
|
|
1196
1224
|
properties: {
|
|
1197
|
-
|
|
1225
|
+
useUserContext: {
|
|
1198
1226
|
type: string;
|
|
1199
1227
|
'x-component': string;
|
|
1228
|
+
'x-read-pretty': boolean;
|
|
1200
1229
|
};
|
|
1201
1230
|
};
|
|
1202
1231
|
};
|
|
1203
1232
|
column6: {
|
|
1233
|
+
type: string;
|
|
1234
|
+
title: string;
|
|
1235
|
+
'x-component': string;
|
|
1236
|
+
properties: {
|
|
1237
|
+
enabled: {
|
|
1238
|
+
type: string;
|
|
1239
|
+
'x-component': string;
|
|
1240
|
+
};
|
|
1241
|
+
};
|
|
1242
|
+
};
|
|
1243
|
+
column7: {
|
|
1204
1244
|
type: string;
|
|
1205
1245
|
title: string;
|
|
1206
1246
|
'x-decorator': string;
|