@formio/uag-sdk 2.0.0-rc.7 → 2.0.0-rc.9
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/README.md +3 -2
- package/loader.d.ts +12 -0
- package/loader.js +47 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @formio/uag-sdk
|
|
2
2
|
|
|
3
|
-
<sub>[Form.io UAG](https://github.com/formio/uag/blob/
|
|
3
|
+
<sub>[Form.io UAG](https://github.com/formio/uag/blob/v2.0.0-rc.8/README.md) › [Engines](https://github.com/formio/uag/blob/v2.0.0-rc.8/README.md#engines-and-routing) › this page</sub>
|
|
4
4
|
|
|
5
5
|
Build engine packages for the Form.io Universal Agent Gateway (UAG). This package contains:
|
|
6
6
|
|
|
@@ -154,8 +154,9 @@ The check creates an instance and calls it. Pass options, such as a fake client,
|
|
|
154
154
|
- the definition and the engine have the contract's shape;
|
|
155
155
|
- the engine uses the instance name and the `model` option;
|
|
156
156
|
- `extract` returns only the fields it was asked about, or `decide` only the questions it was asked;
|
|
157
|
+
- `accepts`, when set, lists only `text` and `pdf`; `generate`, when present, returns text, its model and a valid `stopReason`;
|
|
157
158
|
- research stops at `maxIterations`, and reports every tool call it made;
|
|
158
|
-
- an aborted signal stops the engine, including during research
|
|
159
|
+
- an aborted signal stops the engine, including during research and `generate`.
|
|
159
160
|
|
|
160
161
|
A research round is the calls a model makes together; calls made one after another count as separate rounds.
|
|
161
162
|
|
package/loader.d.ts
CHANGED
|
@@ -53,3 +53,15 @@ export declare function createEngine(definition: EngineTypeDefinition, options:
|
|
|
53
53
|
|
|
54
54
|
/** Resolve, configure and create each instance. Any problem stops loading, with the instance named. */
|
|
55
55
|
export declare function loadEngines(instances: EngineInstanceSpec[], options?: LoadOptions): Promise<LoadedEngine[]>;
|
|
56
|
+
|
|
57
|
+
/** One instance planned but not created: what creating it takes, and how a failure to start reads. */
|
|
58
|
+
export type PlannedEngine = Omit<LoadedEngine, 'engine'> & {
|
|
59
|
+
name: string;
|
|
60
|
+
kinds: ('decision' | 'agent')[];
|
|
61
|
+
definition: EngineTypeDefinition;
|
|
62
|
+
args: { name: string; settings: Record<string, any>; options: Record<string, any>; config: Record<string, any>; requireSetting(key: string): any };
|
|
63
|
+
failure(err: unknown): string;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** Resolve and configure each instance without creating it, for a host that creates engines elsewhere. */
|
|
67
|
+
export declare function planEngines(instances: EngineInstanceSpec[], options?: LoadOptions): PlannedEngine[];
|
package/loader.js
CHANGED
|
@@ -223,4 +223,50 @@ async function loadEngines(instances, { types = {}, paths = [], env = process.en
|
|
|
223
223
|
return loaded;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
|
|
226
|
+
/**
|
|
227
|
+
* Plan the given instances without creating them: resolve each type and its
|
|
228
|
+
* settings, and describe how each is created and how a failure to start reads
|
|
229
|
+
* (with secrets left out). For a host that has engines created elsewhere, such
|
|
230
|
+
* as Agentic Formflow's `startEngines`, which creates and wraps them.
|
|
231
|
+
*/
|
|
232
|
+
function planEngines(instances, { types = {}, paths = [], env = process.env, config = {}, apiVersion = ENGINE_API_VERSION } = {}) {
|
|
233
|
+
const resolved = instances.map((instance) => {
|
|
234
|
+
const found = resolveType(instance.type, { types, paths, apiVersion });
|
|
235
|
+
const name = instance.name || found.definition.name;
|
|
236
|
+
checkName(name);
|
|
237
|
+
return { ...found, name, options: instance.options || {} };
|
|
238
|
+
});
|
|
239
|
+
checkUnique(resolved);
|
|
240
|
+
checkVariables(resolved);
|
|
241
|
+
return resolved.map(({ definition, name, options, package: pkg, version }) => {
|
|
242
|
+
const label = `The "${name}" engine (type "${definition.name}")`;
|
|
243
|
+
const settings = resolveSettings(definition, name, options, env);
|
|
244
|
+
const secrets = secretValues(definition, settings, options);
|
|
245
|
+
return {
|
|
246
|
+
name,
|
|
247
|
+
type: definition.name,
|
|
248
|
+
title: definition.title,
|
|
249
|
+
kinds: [...definition.kinds],
|
|
250
|
+
...(definition.version && { typeVersion: definition.version }),
|
|
251
|
+
...(pkg && { package: pkg }),
|
|
252
|
+
...(version && { version }),
|
|
253
|
+
definition,
|
|
254
|
+
args: {
|
|
255
|
+
name,
|
|
256
|
+
settings,
|
|
257
|
+
options,
|
|
258
|
+
config,
|
|
259
|
+
requireSetting: (key) => {
|
|
260
|
+
if (settings[key] === undefined) throw missingSetting(definition, name, key);
|
|
261
|
+
return settings[key];
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
failure: (err) => {
|
|
265
|
+
const message = redact(errorText(err), secrets);
|
|
266
|
+
return err instanceof EngineConfigError || (err && err.name === 'EngineConfigError') ? message : `${label} failed to start: ${message}`;
|
|
267
|
+
},
|
|
268
|
+
};
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
module.exports = { enginePaths, packageCandidates, resolveType, createEngine, loadEngines, planEngines };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formio/uag-sdk",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.9",
|
|
4
4
|
"description": "Build engine packages for the Form.io Universal Agent Gateway (UAG): the engine contract, defineEngine, settings and instance resolution, the engine loader, and a conformance check.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"formio",
|