@formio/uag-grok 0.0.0-stage → 2.0.0-rc.2

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 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 CHANGED
@@ -1,3 +1,61 @@
1
- # Temporary Holding Version
1
+ # @formio/uag-grok
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <sub>[Form.io UAG](https://github.com/formio/uag/blob/main/README.md) &rsaquo; [Engines](https://github.com/formio/uag/blob/main/README.md#engines-and-routing) &rsaquo; this page</sub>
4
+
5
+ The **Grok** agent engine for the [UAG Agent API](https://github.com/formio/uag/blob/main/README.md#agent-api): xAI's models, through xAI's OpenAI-compatible API. It extracts and generates open values (dates, amounts, names, free text) with structured outputs. When a task lists read-only tools in `uagTools`, it researches with them first.
6
+
7
+ It is included in the `formio/uag` Docker image. Enable it by naming it, and set its key and model:
8
+
9
+ ```
10
+ UAG_ENGINES=grok
11
+ XAI_API_KEY=...
12
+ XAI_MODEL=<a Grok model ID>
13
+ ```
14
+
15
+ Its tasks are Agentic Formflow, so the UAG also needs a `LICENSE_KEY` that includes the UAG (see [License](https://github.com/formio/uag/blob/main/README.md#license)).
16
+
17
+ ## Settings
18
+
19
+ | Setting | Variables | Default |
20
+ |---|---|---|
21
+ | `apiKey` | `UAG_ENGINE_<NAME>_API_KEY`, `XAI_API_KEY` | required (secret) |
22
+ | `model` | `UAG_ENGINE_<NAME>_MODEL`, `XAI_MODEL` | required; there is no default |
23
+ | `baseURL` | `UAG_ENGINE_<NAME>_BASE_URL` | `https://api.x.ai/v1` |
24
+ | `structuredOutput` | `UAG_ENGINE_<NAME>_STRUCTURED_OUTPUT` | `json_schema`; `json_object` or `prompt` if a model refuses strict schemas |
25
+
26
+ `<NAME>` is the instance name, upper-cased with `-` as `_`. An instance's own variable wins over the shared one.
27
+
28
+ ## Instances
29
+
30
+ A fast Grok model for routine values next to Claude for the rest:
31
+
32
+ ```
33
+ UAG_ENGINES=jev,fast:grok,claude
34
+ XAI_API_KEY=...
35
+ UAG_ENGINE_FAST_MODEL=<a fast Grok model ID>
36
+ CLAUDE_API_KEY=...
37
+ ```
38
+
39
+ Routing lists, and a field's `uagEngine` property, name the instances, for example `routing.value: ["fast", "claude"]`.
40
+
41
+ ## Choosing a model
42
+
43
+ There is no default model: set `model` to a specific model ID from xAI's documentation, not an alias that moves. Answers differ between models, so compare them on your own labeled examples before switching (`uag-eval` measures decision engines only).
44
+
45
+ ## How it works
46
+
47
+ It is the [OpenAI engine](https://github.com/formio/uag/tree/main/engines/openai)'s agent kind with xAI's endpoint and key built in: one chat completion with a strict JSON schema per extraction, and a function-calling loop over the task's read-only tools for research, ending in the same structured answer. A refusal, a truncated answer or an answer that is not JSON is an engine failure, and the UAG falls back to the next engine.
48
+
49
+ Each field's format (such as `date`) and pattern are written into its description, not sent as schema constraints. Grok enforces constraints strictly, and every field is required in a strict schema, so it would otherwise invent a value that fits the pattern for a field the input does not state. The UAG validates every value either way.
50
+
51
+ Grok has no decision API, and current Grok models return no token probabilities, so this is an agent engine only. Decision fields routed to it are answered as extraction and reported `calibrated: false`.
52
+
53
+ **Data residency:** each request sends xAI the task's criteria, its input (or, without an input, the whole submission except the fields being answered), its `uagContext` values and today's date, and, for a task that researches, what its tools return.
54
+
55
+ ## Using it in your own server
56
+
57
+ ```js
58
+ const server = new UAGServer({ engines: [{ name: 'grok', type: 'grok', options: { model: '<a Grok model ID>' } }] });
59
+ ```
60
+
61
+ License: MIT.
package/index.js ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Grok engine for the UAG Agent API: xAI's models, through xAI's
3
+ * OpenAI-compatible API, for structured extraction with research over
4
+ * read-only tools.
5
+ *
6
+ * UAG_ENGINES=grok XAI_API_KEY=... XAI_MODEL=<a Grok model ID>
7
+ *
8
+ * Grok has no decision API, so this is an agent engine only.
9
+ */
10
+ const { openAICompatible } = require('@formio/uag-openai/compatible');
11
+
12
+ module.exports = openAICompatible({
13
+ type: 'grok',
14
+ description: 'xAI\'s Grok models: structured extraction, with research over read-only tools.',
15
+ baseURL: 'https://api.x.ai/v1',
16
+ apiKey: { env: 'XAI_API_KEY' },
17
+ model: { env: 'XAI_MODEL' },
18
+ structuredOutput: 'json_schema',
19
+ });
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "@formio/uag-grok",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.0.0-rc.2",
4
+ "description": "Grok engine for the Form.io Universal Agent Gateway (UAG): xAI's models, for structured extraction with research over read-only tools.",
5
+ "keywords": [
6
+ "formio",
7
+ "uag",
8
+ "universal-agent-gateway",
9
+ "ai",
10
+ "agents",
11
+ "engine",
12
+ "grok",
13
+ "xai"
14
+ ],
15
+ "license": "MIT",
16
+ "main": "index.js",
17
+ "files": [
18
+ "index.js",
19
+ "README.md"
20
+ ],
21
+ "scripts": {
22
+ "test": "mocha"
23
+ },
24
+ "engines": {
25
+ "node": ">=22.0.0"
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/formio/uag.git",
30
+ "directory": "engines/grok"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "dependencies": {
36
+ "@formio/uag-openai": "^2.0.0-rc.2",
37
+ "@formio/uag-sdk": "^2.0.0-rc.2"
38
+ },
39
+ "devDependencies": {
40
+ "chai": "^6.3.0",
41
+ "mocha": "^12.0.3"
42
+ }
43
+ }