@formio/uag 1.3.0
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/LICENSE.txt +19 -0
- package/README.md +336 -0
- package/lib/UAGFormInterface.d.ts +113 -0
- package/lib/UAGFormInterface.js +371 -0
- package/lib/UAGProjectInterface.d.ts +26 -0
- package/lib/UAGProjectInterface.js +96 -0
- package/lib/config.d.ts +54 -0
- package/lib/config.js +2 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +43 -0
- package/lib/router.d.ts +3 -0
- package/lib/router.js +74 -0
- package/lib/template.d.ts +54 -0
- package/lib/template.js +120 -0
- package/lib/templates/allFieldsCollected.md +17 -0
- package/lib/templates/collectedData.md +5 -0
- package/lib/templates/confirmFormSubmission.md +18 -0
- package/lib/templates/fieldCollectedNext.md +14 -0
- package/lib/templates/fieldList.md +5 -0
- package/lib/templates/fieldRules.md +4 -0
- package/lib/templates/fieldValidationErrors.md +7 -0
- package/lib/templates/fields.md +19 -0
- package/lib/templates/formNotFound.md +1 -0
- package/lib/templates/formSubmitted.md +7 -0
- package/lib/templates/getAvailableForms.md +18 -0
- package/lib/templates/getFormFields.md +16 -0
- package/lib/templates/getFormFieldsEmpty.md +4 -0
- package/lib/templates/getFormFieldsError.md +7 -0
- package/lib/templates/getFormFieldsInfo.md +6 -0
- package/lib/templates/getOptionalFields.md +19 -0
- package/lib/templates/noFormsAvailable.md +3 -0
- package/lib/templates/noSubmissionsFound.md +11 -0
- package/lib/templates/submissionNotFound.md +6 -0
- package/lib/templates/submissionPartialIdAmbiguous.md +12 -0
- package/lib/templates/submissionPartialIdNotFound.md +12 -0
- package/lib/templates/submissionSearchError.md +8 -0
- package/lib/templates/submissionUpdateError.md +6 -0
- package/lib/templates/submissionUpdated.md +15 -0
- package/lib/templates/submissionsFound.md +25 -0
- package/lib/templates/submitValidationError.md +7 -0
- package/lib/templates/submittedData.md +4 -0
- package/lib/tools/SchemaBuilder.d.ts +136 -0
- package/lib/tools/SchemaBuilder.js +192 -0
- package/lib/tools/collectData.d.ts +3 -0
- package/lib/tools/collectData.js +72 -0
- package/lib/tools/confirmSubmission.d.ts +3 -0
- package/lib/tools/confirmSubmission.js +56 -0
- package/lib/tools/findSubmission.d.ts +3 -0
- package/lib/tools/findSubmission.js +165 -0
- package/lib/tools/getFieldInfo.d.ts +3 -0
- package/lib/tools/getFieldInfo.js +41 -0
- package/lib/tools/getFormFields.d.ts +3 -0
- package/lib/tools/getFormFields.js +99 -0
- package/lib/tools/getForms.d.ts +3 -0
- package/lib/tools/getForms.js +38 -0
- package/lib/tools/index.d.ts +13 -0
- package/lib/tools/index.js +47 -0
- package/lib/tools/submissionUpdate.d.ts +3 -0
- package/lib/tools/submissionUpdate.js +79 -0
- package/lib/tools/submitForm.d.ts +3 -0
- package/lib/tools/submitForm.js +62 -0
- package/lib/tools/utils.d.ts +28 -0
- package/lib/tools/utils.js +27 -0
- package/package.json +57 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
Copyright (c) 2025 Form.io
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
5
|
+
this software and associated documentation files (the "Software"), to deal in the
|
|
6
|
+
Software without restriction, including without limitation the rights to use,
|
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
8
|
+
Software, and to permit persons to whom the Software is furnished to do so,
|
|
9
|
+
subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
15
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
16
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
17
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
18
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
19
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
# The Form.io "Universal Agent Gateway" (UAG)
|
|
2
|
+
The Universal Agent Gateway (uag) is an exciting new technology that enables the exposure of Form.io forms to AI Agents. Leveraging the power of MCP, this library provides AI Agents with dynamic context of how to interface with any backend system using Form.io JSON Forms as the common language between these agents and enterprise systems.
|
|
3
|
+
|
|
4
|
+
This library can be used in many ways, either by deploying it directly via the Docker container, or by extending the interfaces and introducing your own custom Actions and providers.
|
|
5
|
+
|
|
6
|
+
## How it works
|
|
7
|
+
The UAG leverages the [**Model Context Protocol (MCP)**](https://modelcontextprotocol.io/docs/getting-started/intro) to provide AI Agents the ability to understand the dynamic data structures provided from [Form.io](https://form.io) JSON form definitions. It achieves this though the introduction of new MCP "tools" to provide an AI Agent with dynamic "form" based context. This cabability allows for Developers to treat AI Agents as they would any other Human who is submitting a form, and ensure that the AI Agents stay "on the rails" without requiring extensive domain specific agent training methods to accomplish the same goal. It achieves this by exposing the following MCP tools to an AI Agent.
|
|
8
|
+
|
|
9
|
+
| Tool Name | Tool Description |
|
|
10
|
+
|-------------------|----------------------------------------------------------------------------------|
|
|
11
|
+
| get_forms | Provides the AI Agent an understanding of what Forms are available. It will only return forms that have been tagged **uag**. |
|
|
12
|
+
| get_form_fields | Once a form has been identified by the AI Agent that the user wishes to engage with (using natural language), this tool provides the AI Agent a high level overview of all the fields needed (along with the field data path) to submit that form. |
|
|
13
|
+
| get_field_info | Once the fields have been determined using the `get_form_fields` tool, this tool is used to get specific information about the requested fields, such as validation, conditionals, input formats, etc. This tool provides the AI Agent the ability to undersand how to "format" and structure the data that is sent to the MCP server. |
|
|
14
|
+
| collect_field_data | This tool provides the AI Agent a mechanism to dynamically collect the required information from the user. It is capable of collecting many fields at once, and also provides the AI agent the ability to understand what required fields are missing and what is needed to complete its goal. This tool supports complex, yet structured, data collecting through multiple "nested" data constructs such as Nested Forms and Table structured data (datagrid, editgrid). |
|
|
15
|
+
| confirm_form_submission | This tool provides the AI Agent the ability to confirm all the information it has collected before a submission has been made. It allows the AI Agent the ability to get a confirmation from the user before it submits the form. |
|
|
16
|
+
| submit_completed_form | This tool provides the AI Agent the ability to submit all of the data collected from the user to complete the form submission.
|
|
17
|
+
| find_submissions | A very powerful tool that provides the AI Agent the ability to understand how to query for data within the form. This enables the user to say something like "What is the email address of Joe Smith who is the CTO of Microsoft?" and it will format the query responsible for finding that record within the Form.io database.
|
|
18
|
+
| submission_update | Provides the AI agent the ability to update an existing record with any additional information. This also has the awareness to "append", "prepend", and perform any other operations on the data in congruence with how the user has requested the data be updated.
|
|
19
|
+
|
|
20
|
+
## Getting Started
|
|
21
|
+
The quickest way to become familar with the UAG is to first walk through our Local Example, and run it on your local machine. This will allow you to see how the UAG leverages the power of Form.io to connect with an AI Agent to provide dynamic context. All of this can be ran locally for free without any subscriptions required!
|
|
22
|
+
|
|
23
|
+
**[Go to Local Example »](examples/local)**
|
|
24
|
+
|
|
25
|
+
## Runtime Environments
|
|
26
|
+
There are currently two run-time environments that work with the UAG. **Node.js (Express)** and **Docker**.
|
|
27
|
+
|
|
28
|
+
### Node.js (Express):
|
|
29
|
+
With the Node.js environment, you can import the UAG within a locally running Node.js and Express.js envioronment. This works by first importing the UAG module and "use"ing it within an Express.js application. First, you will install the uag inside of your Node.js Express application like the following.
|
|
30
|
+
|
|
31
|
+
```npm install --save @formio/uag```
|
|
32
|
+
|
|
33
|
+
or
|
|
34
|
+
|
|
35
|
+
```yarn add @formio/uag```
|
|
36
|
+
|
|
37
|
+
You can then mount the UAG within your Express application like the following example shows.
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
import 'dotenv/config';
|
|
41
|
+
import Express from 'express';
|
|
42
|
+
import { UAGServer } from '@formio/uag';
|
|
43
|
+
try {
|
|
44
|
+
(async function () {
|
|
45
|
+
const server = new UAGServer();
|
|
46
|
+
const app = Express();
|
|
47
|
+
app.use(await server.router());
|
|
48
|
+
const port = process.env.PORT || 3200;
|
|
49
|
+
app.listen(port, () => {
|
|
50
|
+
console.log(`Form.io UAG server running on port ${port}`);
|
|
51
|
+
console.log(`Visit http://localhost:${port} to access the application`);
|
|
52
|
+
});
|
|
53
|
+
})();
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error('Failed to start server:', error);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
There is also a way to extend the functionality of the UAG through the use of modules, which is documented in the [Modules Readme](./module/Readme.md)
|
|
61
|
+
|
|
62
|
+
### Docker
|
|
63
|
+
In addition to running the UAG in node.js, you can also run the UAG within the Docker environment. This enables a wide range of deployment options into common hosting environments such as AWS and Azure as well as allow for the use in common orchestration runtimes such as Kubernetes and Docker Compose. The container that you will use for running the UAG is as follows.
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
formio/uag
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
This container can be ran as a standalone container using the common **docker run** command, or inside of a **docker-compose.yml** (for Docker Compose). To see an example of using UAG with Docker Compose, we recommend taking a look at the [Local Example](./examples/local).
|
|
70
|
+
|
|
71
|
+
#### Docker Run
|
|
72
|
+
Here are some examples of running the UAG using the ```docker run``` command.
|
|
73
|
+
|
|
74
|
+
**UAG pointed to an Open Source server**
|
|
75
|
+
```
|
|
76
|
+
docker run -d \
|
|
77
|
+
-e "PROJECT=https://forms.mysite.com" \
|
|
78
|
+
-e "ADMIN_KEY=CHANGEME" \
|
|
79
|
+
-e "JWT_SECRET=CHANGEME" \
|
|
80
|
+
-e "BASE_URL=https://forms.mysite.com" \
|
|
81
|
+
-e "LOGIN_FORM=https://forms.mysite.com/user/login" \
|
|
82
|
+
-e "PORT=3200" \
|
|
83
|
+
--restart unless-stopped \
|
|
84
|
+
--network formio \
|
|
85
|
+
--name formio-uag \
|
|
86
|
+
-p 3200:3200 \
|
|
87
|
+
formio/uag:rc
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**UAG pointed to an Form.io Enterprise Server**
|
|
91
|
+
```
|
|
92
|
+
docker run -d \
|
|
93
|
+
-e "PROJECT=https://forms.mysite.com/myproject" \
|
|
94
|
+
-e "PROJECT_KEY=CHANGEME" \
|
|
95
|
+
-e "UAG_LICENSE=YOUR-LICENSE" \
|
|
96
|
+
-e "JWT_SECRET=CHANGEME" \
|
|
97
|
+
-e "PORTAL_SECRET=CHANGEME" \
|
|
98
|
+
-e "BASE_URL=https://forms.mysite.com" \
|
|
99
|
+
-e "LOGIN_FORM=https://forms.mysite.com/myproject/user/login" \
|
|
100
|
+
-e "PORT=3200" \
|
|
101
|
+
--restart unless-stopped \
|
|
102
|
+
--network formio \
|
|
103
|
+
--name formio-uag \
|
|
104
|
+
-p 3200:3200 \
|
|
105
|
+
formio/uag:rc
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Docker Compose (Recommended)
|
|
109
|
+
The recommended way to launching the UAG is through Docker Compose. This enables you to orchestrate several of the containers to run within a single instance to provide a more seamless and simple way of managing your deployments. Here is a simple example of how to run both the Form.io UAG + Form.io OSS server on the same instance.
|
|
110
|
+
|
|
111
|
+
docker-compose.yml
|
|
112
|
+
```
|
|
113
|
+
version: "3.8"
|
|
114
|
+
services:
|
|
115
|
+
mongo:
|
|
116
|
+
image: mongo
|
|
117
|
+
restart: always
|
|
118
|
+
volumes:
|
|
119
|
+
- ./data/db:/data/db
|
|
120
|
+
environment:
|
|
121
|
+
- MONGO_INITDB_ROOT_USERNAME
|
|
122
|
+
- MONGO_INITDB_ROOT_PASSWORD
|
|
123
|
+
formio:
|
|
124
|
+
image: formio/formio:rc
|
|
125
|
+
restart: always
|
|
126
|
+
links:
|
|
127
|
+
- mongo
|
|
128
|
+
depends_on:
|
|
129
|
+
- mongo
|
|
130
|
+
environment:
|
|
131
|
+
PORT: 3000
|
|
132
|
+
DEBUG: formio.*
|
|
133
|
+
NODE_CONFIG: '{"mongo": "mongodb://mongo:27017/formio-oss", "jwt": {"secret": "CHANGEME"}, "mongoSecret": "CHANGEME"}'
|
|
134
|
+
ROOT_EMAIL: admin@example.com
|
|
135
|
+
ROOT_PASSWORD: CHANGEME
|
|
136
|
+
ADMIN_KEY: CHANGEME
|
|
137
|
+
ports:
|
|
138
|
+
- "3000:3000"
|
|
139
|
+
formio-uag:
|
|
140
|
+
image: formio/uag:rc
|
|
141
|
+
restart: always
|
|
142
|
+
links:
|
|
143
|
+
- formio
|
|
144
|
+
depends_on:
|
|
145
|
+
- formio
|
|
146
|
+
environment:
|
|
147
|
+
PORT: 3200
|
|
148
|
+
DEBUG: formio.*
|
|
149
|
+
PROJECT: http://formio:3000
|
|
150
|
+
ADMIN_KEY: CHANGEME
|
|
151
|
+
JWT_SECRET: CHANGEME
|
|
152
|
+
JWT_EXPIRE_TIME: 525600
|
|
153
|
+
LOGIN_FORM: http://localhost:3000/employee/login
|
|
154
|
+
BASE_URL: http://localhost:3000
|
|
155
|
+
ports:
|
|
156
|
+
- "3200:3200"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
This can be run by typing the following...
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
docker compose up -d
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Once it is running, you can then navigate to the following to access both the OSS Deployment + UAG Server
|
|
166
|
+
- http://localhost:3000: The Form.io OSS Server
|
|
167
|
+
- http://localhost:3200: The UAG Server
|
|
168
|
+
|
|
169
|
+
In both the Node.js runtime environemnt as well as Docker, the way to control the UAG is thorugh the use of **Environment Variables** and **Modules**.
|
|
170
|
+
|
|
171
|
+
### Environment Variables
|
|
172
|
+
This module can be configured in many ways. One of those ways is through the use of Environment Variables, which are documented as follows.
|
|
173
|
+
|
|
174
|
+
| Variable | Description | Example |
|
|
175
|
+
|----------|-------------|---------|
|
|
176
|
+
| PROJECT | The API Endpoint to either an Enterprise project endpoint, or the OSS server url. | http://localhost:3000 |
|
|
177
|
+
| PROJECT_KEY | (Enterprise Only) Either a Project API Key (for Form.io Enterprise) or the ADMIN_KEY for Community Edition. | CHANGEME |
|
|
178
|
+
| ADMIN_KEY | (OSS Only) Allows you to provide the ADMIN_KEY to install and connect to the OSS Server. | CHANGEME |
|
|
179
|
+
| UAG_LICENSE | The license to run the UAG against a Form.io Enterprise Deployment. | |
|
|
180
|
+
| PORT | The port you wish to run the server on. | 3200 |
|
|
181
|
+
| DEBUG | Variable used to perform debug logs of server activity | formio.* |
|
|
182
|
+
| PORTAL_SECRET | Enterprise Only: Allows you to connect to the UAG from the Form.io Enterprise Portal. | CHANGEME |
|
|
183
|
+
| JWT_SECRET | A secret used to generate and validate JWT tokens generated through the authentication process of the UAG. This does not need to match the JWT_SECRET of the Enterprise Server that it is connected to. | CHANGEME |
|
|
184
|
+
| PORTAL_SECRET | (Enterprise Only) Used to connect the UAG server with the Enterprise Portal | CHANGEME |
|
|
185
|
+
| JWT_EXPIRE_TIME | The expiration for the jwt secret. | 3600 |
|
|
186
|
+
| MONGO | (Enterprise Only) Allows you to connect the UAG directly to a mongo database vs. having to redirect the submissions to the Form.io Submission APIs. | |
|
|
187
|
+
| MONGO_CONFIG | JSON configuration for the Node.js Mongo Driver. | |
|
|
188
|
+
| BASE_URL | The public URL that the UAG is hosted on. This allows for proper OIDC authentication and allows for the authentication callbacks to point to the correct url. | https://ai.onform.io |
|
|
189
|
+
| LOGIN_FORM | The public URL to the Login Form JSON endpoint. | https://mysite.com/project/user/login |
|
|
190
|
+
| CORS | The cors domain, or the JSON configuration to configure the "cors" node.js module cross domain resource sharing. | *.* |
|
|
191
|
+
|
|
192
|
+
## Running on Public Domain
|
|
193
|
+
In order to run the UAG on a public domain, it is very important to provide the proper configurations so that any AI Agent can properly authenticate. There are 3 different "domain" environment variables that matter, and it is important to understand how to configure them depending on your use case:
|
|
194
|
+
|
|
195
|
+
### PROJECT
|
|
196
|
+
The ```PROJECT``` environment variable is used to establish a connetion from the UAG server to the project endpoint (for Enterprise) or OSS base url. This does NOT need to be a public DNS entry, but rather a URL that connects the UAG container to the Server container. The following examples illustrate how this would be configured.
|
|
197
|
+
|
|
198
|
+
#### Local connection to OSS Server
|
|
199
|
+
If you are using a local connection, such as within a Docker Compose file, you can configure the ```PROJECT``` environment variable to point directly to the local url as follows.
|
|
200
|
+
|
|
201
|
+
docker-compose.yml
|
|
202
|
+
```
|
|
203
|
+
version: "3.8"
|
|
204
|
+
services:
|
|
205
|
+
formio:
|
|
206
|
+
image: formio/formio:rc
|
|
207
|
+
restart: always
|
|
208
|
+
environment:
|
|
209
|
+
PORT: 3000
|
|
210
|
+
ADMIN_KEY: CHANGEME
|
|
211
|
+
formio-uag:
|
|
212
|
+
image: formio/uag:rc
|
|
213
|
+
restart: always
|
|
214
|
+
links:
|
|
215
|
+
- formio
|
|
216
|
+
depends_on:
|
|
217
|
+
- formio
|
|
218
|
+
environment:
|
|
219
|
+
PROJECT: http://formio:3000
|
|
220
|
+
ADMIN_KEY: CHANGEME
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
In this example, we have Docker Compose launching the OSS Form.io container with the ADMIN_KEY set for this deployment, the UAG is connected using ```http://formio:3000``` which is the local Docker network name (provided using the "links" property in the docker compose file)
|
|
224
|
+
|
|
225
|
+
#### Local Connection to Enterprise Server Project
|
|
226
|
+
If you are using the Enterprise Form.io server within a local environment to the UAG, then you will need to ensure that the UAG connects to an independent project using the PROJECT_KEY as follows.
|
|
227
|
+
|
|
228
|
+
docker-compose.yml
|
|
229
|
+
```
|
|
230
|
+
version: "3.8"
|
|
231
|
+
services:
|
|
232
|
+
formio-enterprise:
|
|
233
|
+
image: formio/formio-enterprise
|
|
234
|
+
restart: always
|
|
235
|
+
environment:
|
|
236
|
+
PORT: 3000
|
|
237
|
+
formio-uag:
|
|
238
|
+
image: formio/uag:rc
|
|
239
|
+
restart: always
|
|
240
|
+
links:
|
|
241
|
+
- formio-enterprise
|
|
242
|
+
depends_on:
|
|
243
|
+
- formio-enterprise
|
|
244
|
+
environment:
|
|
245
|
+
PROJECT: http://formio-enterprise:3000/myproject
|
|
246
|
+
PROJECT_KEY: CHANGEME
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### Public DNS
|
|
250
|
+
If your project does not reside on the same network as the UAG, you can provide the domain name as the PROJECT as follows.
|
|
251
|
+
|
|
252
|
+
docker-compose.yml: Connected to Enterprise (formio/formio-enterprise)
|
|
253
|
+
```
|
|
254
|
+
version: "3.8"
|
|
255
|
+
services:
|
|
256
|
+
formio-uag:
|
|
257
|
+
image: formio/uag:rc
|
|
258
|
+
restart: always
|
|
259
|
+
environment:
|
|
260
|
+
PROJECT: https://forms.mydomain.com/myproject
|
|
261
|
+
PROJECT_KEY: CHANGEME
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
docker-compose.yml: Connected to Open Source (formio/formio)
|
|
265
|
+
```
|
|
266
|
+
version: "3.8"
|
|
267
|
+
services:
|
|
268
|
+
formio-uag:
|
|
269
|
+
image: formio/uag:rc
|
|
270
|
+
restart: always
|
|
271
|
+
environment:
|
|
272
|
+
PROJECT: https://forms.mydomain.com
|
|
273
|
+
ADMIN_KEY: CHANGEME
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### BASE_URL
|
|
277
|
+
The ```BASE_URL``` is used to communicate to the AI Agent the public domain that is hosting the UAG server. This value is provided within the ```.well-known``` definitions for the OIDC (PKCE) authentication. If this is not correct, then the AI Agent will not be able to authenticate into the UAG.
|
|
278
|
+
|
|
279
|
+
**This needs to be the publically accessible domain that you are hosting your UAG.**
|
|
280
|
+
|
|
281
|
+
For example, ```BASE_URL: https://forms.mysite.com```.
|
|
282
|
+
|
|
283
|
+
### LOGIN_FORM
|
|
284
|
+
This is the publically accessible URL to the Login form of your Project or OSS deployment. This provides the URL that is loaded when the user navigates to ```{{ BASE_URL }}/auth/authorize```. If you navigate to this URL, and the page says that you cannot load the form, then this is because your LOGIN_FORM environment variable is not pointing to the correct form JSON endpoint of your project.
|
|
285
|
+
|
|
286
|
+
For example:
|
|
287
|
+
- Enterprise Example: ```LOGIN_FORM: https://forms.mysite.com/myproject/user/login```
|
|
288
|
+
- OSS Example: ```LOGIN_FORM: https://forms.mysite.com/user/login```
|
|
289
|
+
|
|
290
|
+
## Modules
|
|
291
|
+
One of the more powerful ways to "control" and extend the UAG is through the use of Modules. This allows you to provide custom Resources, Forms, as well as custom actions and configurations to ensure that the UAG behaves exactly as you wish for it to behave for your use case.
|
|
292
|
+
|
|
293
|
+
Extensive documentation for the UAG Module system can be found in the [Modules Readme](./module/Readme.md).
|
|
294
|
+
|
|
295
|
+
## Using with Form.io Enterprise Server
|
|
296
|
+
If you are using the UAG with the Form.io Enterprise Server, you unlock several benefits with regards to managing the Forms and Resources within the UAG. Some of the features that you gain with our Enterprise Server are as follows:
|
|
297
|
+
|
|
298
|
+
- **Form Revisions** - Our form revision system provides a way to keep track of any changes made to any forms, and associate those changes with the submission data that is submitted against those revisions. This feature enables you to ensure that if any form schemas change, that the data submitted for that form correlates with the revision of the form in which it was submitted. In addition to this powerful feature, you can also leverage Form Revisions as a method to "roll-back" any mistakes or regressions caused by form changes. Instead of having to re-train or un-train an AI Agent with any schema, you simply revert to previous revisions and the AI Agent will adjust accordingly.
|
|
299
|
+
- **Submission Revisions** - Submission revisions provides a way to keep track of any data changes that have been made to a submission and provides information on who changed the data. This combined with the power of the UAG provides any system the ability to audit any changes in data made by both AI Agents as well as humans in the workflow processes.
|
|
300
|
+
- **Stage Versions and Deployments** - Stage versions provides a way to create a "tag" version accross all forms and resources within a project. This ensures that you can stamp a point in time where your AI Agent (which may consume many different forms and resources) interfaces with your whole project in a deterministic way. It also provides a much more elegant "roll-back" mechansism where the entire project of forms and resources can be versioned and deployed independently.
|
|
301
|
+
- **Custom Actions** - Through the use of the Developer Portal and remote connections, you can use the Actions UI to manage and configure any custom actions that are configured within your UAG. Once a custom action is registered, via the **Modules** system, you can add that action to a form and configure it using the Form.io Developer Portal.
|
|
302
|
+
|
|
303
|
+
### Running the UAG against the Enterprise Server
|
|
304
|
+
In order to run the UAG against an Enterprise Server, you need to provide a few Environment variables that are different from the OSS runtime of this module. The following environment variables are required to run against an Enterprise Project.
|
|
305
|
+
|
|
306
|
+
| Variable | Description | Example |
|
|
307
|
+
|----------|-------------|---------|
|
|
308
|
+
| PROJECT | For the Enterprise Server, this points to the Project Endpoint you wish to bind the UAG to. | https://mydeployment.com/myproject |
|
|
309
|
+
| PROJECT_KEY | An API Key for that project, provided within the Project Settings | CHANGEME |
|
|
310
|
+
| UAG_LICENSE | This is the licnese provided to you from the Form.io License team. Contact support@form.io to acquire a "temporary" or full license. | |
|
|
311
|
+
| PORTAL_SECRET | This enables you to "connect" your Form.io Developer Portal to the UAG so that you can view any custom actions as well as perform deployments to the UAG. | |
|
|
312
|
+
|
|
313
|
+
Once you have these environment variables in place, you should be able to run the UAG pointed to your Enterprise Project. You can now connect to this UAG from the Developer Portal as follows.
|
|
314
|
+
|
|
315
|
+
### Connecting your Developer Portal to the UAG.
|
|
316
|
+
Once you have the UAG running in your own environment with a PORTAL_SECRET, you will now create a new Stage within your Developer portal. We can call this UAG.
|
|
317
|
+
|
|
318
|
+
<div align="center">
|
|
319
|
+
<img src="./examples/images/uag-create-stage.png" alt="Create UAG Stage" width="600">
|
|
320
|
+
</div>
|
|
321
|
+
|
|
322
|
+
Next, you will click on **Staging** and then connect to your UAG server by providing the PORTAL_SECRET as follows.
|
|
323
|
+
|
|
324
|
+
<div align="center">
|
|
325
|
+
<img src="./examples/images/connect-uag.png" alt="Connect to UAG" width="600">
|
|
326
|
+
</div>
|
|
327
|
+
|
|
328
|
+
Now that the UAG is connected, you can then navigate to any Forms and Resources. These are the forms and resources hosted through the UAG.
|
|
329
|
+
|
|
330
|
+
### Deploying changes to your UAG using Stage Versions
|
|
331
|
+
Next, you will simply use the existing Staging and Deployment system from your Developer portal to "deploy" any changes to your UAG. This will allow you to treat the UAG just like you would treat any other stage within your Enterprise deployment. This will allow you to track and any forms and resource changes using the Tag system, and then deploy new versions as well as "roll-back" to any previous versions if a change is made that does to perform as you would expect within the AI Agent enviornment. This is a stark contrast to what Enterprises must deal with "Trained Agents" where it is much harder to "roll back" any training that an agent has gone through.
|
|
332
|
+
|
|
333
|
+
### Custom Actions
|
|
334
|
+
In addition to managing Tags and Versions within the Developer portal, you can also use the Developer Portal to add Custom Actions to any forms and resources. Within the stage that is connected to the UAG, you can navigate to any Form or Resource, and then click on **Actions**. From there, any actions that show up in the Drop-down list of Actions that you can add to this form, you will see any Custom Actions that are part of your **Module** that you can also attach to your Forms and Resources. From here, you can add custom configurations and settings for each Action instance. It can also be versioned just like any other standard action using the tagging and versioning system.
|
|
335
|
+
|
|
336
|
+
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { AuthRequest, FormInterface, InterpolatedError } from "@formio/appserver";
|
|
2
|
+
import { Component, Submission, DataObject } from "@formio/core";
|
|
3
|
+
import { UAGForm } from "./config";
|
|
4
|
+
import { ParentInfo } from "./tools";
|
|
5
|
+
export type UAGComponentInfo = {
|
|
6
|
+
path: string;
|
|
7
|
+
label: string;
|
|
8
|
+
type: string;
|
|
9
|
+
format: string;
|
|
10
|
+
description: string;
|
|
11
|
+
validation: any;
|
|
12
|
+
options?: {
|
|
13
|
+
label: string;
|
|
14
|
+
value: string;
|
|
15
|
+
}[];
|
|
16
|
+
prompt?: string;
|
|
17
|
+
nested?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type UAGData = Array<{
|
|
20
|
+
label: string;
|
|
21
|
+
value: any;
|
|
22
|
+
path: string;
|
|
23
|
+
prefix?: string;
|
|
24
|
+
}>;
|
|
25
|
+
export type UAGSubmission = {
|
|
26
|
+
_id?: string;
|
|
27
|
+
data: UAGData;
|
|
28
|
+
created?: string | Date;
|
|
29
|
+
modified?: string | Date;
|
|
30
|
+
};
|
|
31
|
+
export type FormFieldError = {
|
|
32
|
+
label: string;
|
|
33
|
+
path: string;
|
|
34
|
+
error: string;
|
|
35
|
+
};
|
|
36
|
+
export type FormFieldInfo = {
|
|
37
|
+
rowIndex: number;
|
|
38
|
+
total: number;
|
|
39
|
+
totalRequired: number;
|
|
40
|
+
totalRequiredCollected: number;
|
|
41
|
+
errors: FormFieldError[];
|
|
42
|
+
required: {
|
|
43
|
+
rules: Record<string, string>;
|
|
44
|
+
components: UAGComponentInfo[];
|
|
45
|
+
};
|
|
46
|
+
optional: {
|
|
47
|
+
rules: Record<string, string>;
|
|
48
|
+
components: UAGComponentInfo[];
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export declare class UAGFormInterface extends FormInterface {
|
|
52
|
+
uag: UAGForm | null;
|
|
53
|
+
getComponentFormat(component: Component): string;
|
|
54
|
+
getComponentInfo(component: Component, path: string): UAGComponentInfo;
|
|
55
|
+
isMultiple(component: Component | undefined): boolean;
|
|
56
|
+
getParentToolDescription(parent: ParentInfo | undefined): string;
|
|
57
|
+
getComponentValueRule(component: Component): string;
|
|
58
|
+
/**
|
|
59
|
+
* Determine if the component is a nested data components. For these components, the UAG treats them as
|
|
60
|
+
* separate data collection units where the agent will explicitely call out to collect data for these components.
|
|
61
|
+
*
|
|
62
|
+
* @import { Component } from "@formio/core";
|
|
63
|
+
* @param component { Component } - The component to check.
|
|
64
|
+
* @returns { boolean } - True if the component is a nested data component, false otherwise.
|
|
65
|
+
*/
|
|
66
|
+
isNestedComponent(component: Component): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Determine if the component is a non-input component that should be skipped when collecting fields.
|
|
69
|
+
*
|
|
70
|
+
* @import { Component } from "@formio/core";
|
|
71
|
+
* @param component { Component } - The component to check.
|
|
72
|
+
* @returns { boolean } - True if the component is an input component, false otherwise.
|
|
73
|
+
*/
|
|
74
|
+
inputComponent(component: Component): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Get the relevant fields from the current form. This will return any non-nested input components whose
|
|
77
|
+
* values have not already been set within the data model. This allows the agent to know what fields still need to be
|
|
78
|
+
* collected from the user, as well as provides a mechanism to break up large forms into smaller chunks of data collection
|
|
79
|
+
* using the 'nested' components (datagrid, editgrid, nested form, etc.).
|
|
80
|
+
*
|
|
81
|
+
* @import { Submission } from "@formio/core";
|
|
82
|
+
* @import { AuthRequest } from "@formio/appserver";
|
|
83
|
+
* @param submission { Submission } - The current submission data model.
|
|
84
|
+
* @param authInfo { AuthRequest } - The current authentication information.
|
|
85
|
+
* @param within { string | string[] } - Optional data path or array of data paths to limit the field extraction within.
|
|
86
|
+
* - If within is an array, then it works like "includes".
|
|
87
|
+
* - If within is a string, then it is a single path to limit components within (non-inclusive).
|
|
88
|
+
* @returns { Promise<FormFieldInfo> } - The extracted form field information.
|
|
89
|
+
*/
|
|
90
|
+
getFields(submission: Submission, authInfo: AuthRequest, within?: string | string[]): Promise<FormFieldInfo>;
|
|
91
|
+
/**
|
|
92
|
+
* Return the component at the specified data path.
|
|
93
|
+
* @param path { string } - The data path of the component to retrieve.
|
|
94
|
+
* @returns { Component | undefined } - The component at the specified path, or undefined if not found.
|
|
95
|
+
*/
|
|
96
|
+
getComponent(path: string): Component | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* Convert a list of InterpolatedErrors into FormFieldErrors.
|
|
99
|
+
* @param errors
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
convertToFormFieldErrors(errors: InterpolatedError[]): FormFieldError[];
|
|
103
|
+
/**
|
|
104
|
+
* Perform a validation process on the collected form data.
|
|
105
|
+
* @param data
|
|
106
|
+
* @param auth
|
|
107
|
+
* @returns
|
|
108
|
+
*/
|
|
109
|
+
validateData(submission: Submission, auth: AuthRequest): Promise<FormFieldError[]>;
|
|
110
|
+
convertToSubmission(data?: Record<string, any>): Submission;
|
|
111
|
+
formatData(data?: DataObject): UAGData;
|
|
112
|
+
formatSubmission(submission: Submission): UAGSubmission;
|
|
113
|
+
}
|