@formio/uag-js

中文文档
2.0.0发布于 2026/11/13MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 2116

The Form.io UAG for formio.js applications: register it once, and forms tagged "uag" save through the UAG and get Agent Input, without overwriting what the user entered.

原始使用文档
文档目录3 节
  1. AI Document
  2. For components: client
  3. Chat

@formio/uag-js

The Form.io UAG for formio.js applications. Register it once, and forms tagged uag save through the UAG (so their "Agent: Run task" actions run), and those whose task has an input get Agent Input, which fills the form from what the user describes without overwriting what they entered. Every other form, and every other request, goes to Form.io as before. Any uag form can also be rendered as a chat.

npm install @formio/uag-js

It works with formio.js 5 (@formio/js 5.x) and has no dependencies.

import { Formio } from '@formio/js';
import { UAG } from '@formio/uag-js';
import '@formio/uag-js/uag-js.css';

Formio.setProjectUrl('https://forms.example.com/myproject');
Formio.use(UAG('https://uag.example.com'));

Formio.createForm(document.getElementById('claim'), 'https://forms.example.com/myproject/claim');

Without a bundler, load the UAG's own https://uag.example.com/uag-js/uag.use.js (and uag-js.css) after formio.js: it registers itself with that UAG and its modules' components. See Or load it from the UAG.

Requests to the UAG carry the user's Form.io token (x-jwt-token), as formio.js sends it to Form.io; no other token is needed. Routing in the browser is not a security boundary: protect the fields an agent owns on the server, with an agent role, form permissions and uagAuthoritative.

AI Document

The AI Document component (uagdocument) is a UAG module from @formio/uag-extras (npm install @formio/uag-extras@^1), not from this package. A UAG that uses the module adds the component to its /uag-js/uag.use.js; an application with a bundler registers it after this package:

import aiDocument from '@formio/uag-extras/modules/ai-document/client';
Formio.use(UAG('https://uag.example.com'));
Formio.use(aiDocument);

See AI Document.

For components: client

Once the UAG is registered, client (also Formio.uagClient, FormioUAG.client and UAG.client) is the browser API that components of UAG modules build on, stable within a major version: the UAG's URL, the user's token and headers, a form's URL on the UAG, the installed plugins, stream() for module routes, and Markdown rendering.

import { client } from '@formio/uag-js';
await client.ready;
const done = await client.stream(client.formUrl(form) + '/document/process', { path, files }, { onEvent: (name, data) => {} });

Every member, and how stream() resolves and rejects: For module components: client.

Chat

Any form tagged uag can also be rendered as a chat, the way Formio.createForm renders it as a form. A person describes what they need; the chat asks for what is still missing and fills the form behind it, which validates and submits through the UAG once they confirm. Each turn is the form's {form}/agent/chat on the UAG, so there is no model code and no server of your own, and it needs no Agentic Formflow license (the UAG needs an agent engine).

Formio.use(UAG('https://uag.example.com'));

const chat = await Formio.createChat(document.getElementById('help'), 'https://forms.example.com/myproject/service-request', {
  suggestions: ['My internet is down'],
  markdown: (text) => marked.parse(text)   // optional; the output is sanitized
});
chat.on('submitDone', (submission) => console.log('Saved', submission._id));

createChat is also exported (and FormioUAG.createChat with script tags). The chat renders through formio.js templates (uagChat, uagChatMessage, …) you can replace per framework or per chat, translates through i18n, and is themed with --uag-chat-* CSS properties in uag-js.css.

Documentation: JavaScript (formio.js) · Chat widget.

版本与发布记录

@formio/uag-js 共发布 13 个版本,首次发布于 2026/10/30;过去 12 个月发布了 13 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.0.0latest2026/11/132 天前
2.0.0-rc.11rc2026/11/105 天前
2.0.0-rc.102026/11/087 天前
2.0.0-rc.92026/11/079 天前
2.0.0-rc.82026/11/069 天前
2.0.0-rc.72026/11/0610 天前

关于 @formio/uag-js 的常见问题

@formio/uag-js 是什么?

The Form.io UAG for formio.js applications: register it once, and forms tagged "uag" save through the UAG and get Agent Input, without overwriting what the user entered.

如何安装 @formio/uag-js?

在项目目录运行 npm install @formio/uag-js,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@formio/js(>=5)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@formio/uag-js 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@formio/uag-js 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@formio/uag-js 可以商用吗?

@formio/uag-js 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@formio/uag-js 的下载量有多少?

根据 npm 官方下载统计,@formio/uag-js 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,116 次,日均约 71 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@formio/uag-js 还在维护吗?

最新版本 2.0.0 发布于 2026/11/13(2 天前);至今共发布 13 个版本,其中过去 12 个月发布了 13 个;首次发布于 2026/10/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。