@dudousxd/nestjs-agent-core 0.42.0 → 0.43.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/dist/ag-ui/index.cjs +66 -12
- package/dist/ag-ui/index.cjs.map +1 -1
- package/dist/ag-ui/index.d.cts +52 -11
- package/dist/ag-ui/index.d.ts +52 -11
- package/dist/ag-ui/index.js +64 -12
- package/dist/ag-ui/index.js.map +1 -1
- package/dist/{catalog-BKS3Yxo6.d.cts → catalog-G8usJpx5.d.cts} +11 -2
- package/dist/{catalog-BKS3Yxo6.d.ts → catalog-G8usJpx5.d.ts} +11 -2
- package/dist/genui/builtins.cjs +41 -10
- package/dist/genui/builtins.cjs.map +1 -1
- package/dist/genui/builtins.d.cts +1 -1
- package/dist/genui/builtins.d.ts +1 -1
- package/dist/genui/builtins.js +41 -10
- package/dist/genui/builtins.js.map +1 -1
- package/dist/genui/index.cjs +71 -34
- package/dist/genui/index.cjs.map +1 -1
- package/dist/genui/index.d.cts +8 -6
- package/dist/genui/index.d.ts +8 -6
- package/dist/genui/index.js +70 -34
- package/dist/genui/index.js.map +1 -1
- package/dist/guardrails/index.d.cts +3 -3
- package/dist/guardrails/index.d.ts +3 -3
- package/dist/index.cjs +114 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -6
- package/dist/index.d.ts +54 -6
- package/dist/index.js +112 -23
- package/dist/index.js.map +1 -1
- package/dist/{processors-DpHBqRuE.d.cts → processors-BANqZT3O.d.cts} +1 -1
- package/dist/{processors-BKILjME5.d.ts → processors-C9mor-73.d.ts} +1 -1
- package/dist/{stream-events-C-pj3bVY.d.cts → stream-events-BfxJAckJ.d.cts} +1 -1
- package/dist/{stream-events-D92SgfRk.d.ts → stream-events-DFa2Do42.d.ts} +1 -1
- package/package.json +1 -1
package/dist/genui/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as Catalog, J as JsonSchema, G as GenuiValidation, b as GenuiIssue } from '../catalog-
|
|
2
|
-
export { A as AjvLike, c as COMPONENT_NAME, d as CatalogOptions, C as ComponentDefinition, e as JsonSchemaValidator, P as PropsSchema, f as ajvValidator, g as builtinJsonSchemaValidator, h as defineCatalog, i as defineComponent, j as
|
|
1
|
+
import { a as Catalog, J as JsonSchema, G as GenuiValidation, b as GenuiIssue } from '../catalog-G8usJpx5.cjs';
|
|
2
|
+
export { A as AjvLike, c as COMPONENT_NAME, d as CatalogOptions, C as ComponentDefinition, e as JsonSchemaValidator, P as PropsSchema, f as ajvValidator, g as builtinJsonSchemaValidator, h as defineCatalog, i as defineComponent, j as flatComponents, k as formatIssues, l as isStandardSchema, t as toJsonSchema, m as toSnakeCase, n as toolNameFor, v as validateProps, o as validatePropsSync } from '../catalog-G8usJpx5.cjs';
|
|
3
3
|
import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
|
|
4
|
-
import { a as Actor, T as ToolSpec, b as ToolHandler, c as ToolPresentation } from '../stream-events-
|
|
5
|
-
export { C as ChartProps, d as ComponentFactory, e as ComponentManifest, f as ComponentPresentation, g as ComponentRegistry, h as ComponentRenderer, P as PreparedUiEmission, i as TableCell, j as TableProps, U as UiCapabilities, k as chart, l as createComponent, m as createComponentRegistry, n as negotiateCatalog, p as prepareUiEmission, s as snapshotComponentPresentation, t as table, v as validatePresentationBatch, o as validateUiCapabilities } from '../stream-events-
|
|
4
|
+
import { a as Actor, T as ToolSpec, b as ToolHandler, c as ToolPresentation } from '../stream-events-BfxJAckJ.cjs';
|
|
5
|
+
export { C as ChartProps, d as ComponentFactory, e as ComponentManifest, f as ComponentPresentation, g as ComponentRegistry, h as ComponentRenderer, P as PreparedUiEmission, i as TableCell, j as TableProps, U as UiCapabilities, k as chart, l as createComponent, m as createComponentRegistry, n as negotiateCatalog, p as prepareUiEmission, s as snapshotComponentPresentation, t as table, v as validatePresentationBatch, o as validateUiCapabilities } from '../stream-events-BfxJAckJ.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* One node of a composed UI: a catalog component, its props, and — for components declared with
|
|
@@ -62,7 +62,8 @@ declare function treeToFlatSpec(root: GenuiElement): FlatSpec;
|
|
|
62
62
|
* Plain text (Slack mrkdwn compatible) for a pushed component: its definition's `fallbackText`, or
|
|
63
63
|
* the props as a JSON block when the catalog has no text for it. A tree frame
|
|
64
64
|
* ({@link GENUI_TREE_COMPONENT}) renders node by node. Never throws — a fallback that fails prints
|
|
65
|
-
* the JSON instead.
|
|
65
|
+
* the JSON instead. A layout component (`children: true`) whose text comes out empty writes
|
|
66
|
+
* nothing: it has nothing of its own to say, and its props (`direction`, `gap`) are not content.
|
|
66
67
|
*/
|
|
67
68
|
declare function componentToText(catalog: Catalog, component: string, props: Record<string, unknown>): string;
|
|
68
69
|
/** Plain text for a composed tree: each node's text, depth-first, blank-line free. */
|
|
@@ -117,7 +118,8 @@ type ResolveGenuiCatalog = (scope: GenuiCatalogScope) => Catalog | Promise<Catal
|
|
|
117
118
|
interface GenuiToolsOptions {
|
|
118
119
|
/**
|
|
119
120
|
* `per-component` (default): one tool per model-facing component, `ui__show_<snake>`, whose input
|
|
120
|
-
* IS the component's props
|
|
121
|
+
* IS the component's props — except layout components (`children: true`), which a flat input
|
|
122
|
+
* cannot fill. `tree`: a single tool whose input is a nested
|
|
121
123
|
* `{ type, props, children }` tree composed from the catalog (json-render's nested shape).
|
|
122
124
|
*/
|
|
123
125
|
mode?: 'per-component' | 'tree';
|
package/dist/genui/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as Catalog, J as JsonSchema, G as GenuiValidation, b as GenuiIssue } from '../catalog-
|
|
2
|
-
export { A as AjvLike, c as COMPONENT_NAME, d as CatalogOptions, C as ComponentDefinition, e as JsonSchemaValidator, P as PropsSchema, f as ajvValidator, g as builtinJsonSchemaValidator, h as defineCatalog, i as defineComponent, j as
|
|
1
|
+
import { a as Catalog, J as JsonSchema, G as GenuiValidation, b as GenuiIssue } from '../catalog-G8usJpx5.js';
|
|
2
|
+
export { A as AjvLike, c as COMPONENT_NAME, d as CatalogOptions, C as ComponentDefinition, e as JsonSchemaValidator, P as PropsSchema, f as ajvValidator, g as builtinJsonSchemaValidator, h as defineCatalog, i as defineComponent, j as flatComponents, k as formatIssues, l as isStandardSchema, t as toJsonSchema, m as toSnakeCase, n as toolNameFor, v as validateProps, o as validatePropsSync } from '../catalog-G8usJpx5.js';
|
|
3
3
|
import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
|
|
4
|
-
import { a as Actor, T as ToolSpec, b as ToolHandler, c as ToolPresentation } from '../stream-events-
|
|
5
|
-
export { C as ChartProps, d as ComponentFactory, e as ComponentManifest, f as ComponentPresentation, g as ComponentRegistry, h as ComponentRenderer, P as PreparedUiEmission, i as TableCell, j as TableProps, U as UiCapabilities, k as chart, l as createComponent, m as createComponentRegistry, n as negotiateCatalog, p as prepareUiEmission, s as snapshotComponentPresentation, t as table, v as validatePresentationBatch, o as validateUiCapabilities } from '../stream-events-
|
|
4
|
+
import { a as Actor, T as ToolSpec, b as ToolHandler, c as ToolPresentation } from '../stream-events-DFa2Do42.js';
|
|
5
|
+
export { C as ChartProps, d as ComponentFactory, e as ComponentManifest, f as ComponentPresentation, g as ComponentRegistry, h as ComponentRenderer, P as PreparedUiEmission, i as TableCell, j as TableProps, U as UiCapabilities, k as chart, l as createComponent, m as createComponentRegistry, n as negotiateCatalog, p as prepareUiEmission, s as snapshotComponentPresentation, t as table, v as validatePresentationBatch, o as validateUiCapabilities } from '../stream-events-DFa2Do42.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* One node of a composed UI: a catalog component, its props, and — for components declared with
|
|
@@ -62,7 +62,8 @@ declare function treeToFlatSpec(root: GenuiElement): FlatSpec;
|
|
|
62
62
|
* Plain text (Slack mrkdwn compatible) for a pushed component: its definition's `fallbackText`, or
|
|
63
63
|
* the props as a JSON block when the catalog has no text for it. A tree frame
|
|
64
64
|
* ({@link GENUI_TREE_COMPONENT}) renders node by node. Never throws — a fallback that fails prints
|
|
65
|
-
* the JSON instead.
|
|
65
|
+
* the JSON instead. A layout component (`children: true`) whose text comes out empty writes
|
|
66
|
+
* nothing: it has nothing of its own to say, and its props (`direction`, `gap`) are not content.
|
|
66
67
|
*/
|
|
67
68
|
declare function componentToText(catalog: Catalog, component: string, props: Record<string, unknown>): string;
|
|
68
69
|
/** Plain text for a composed tree: each node's text, depth-first, blank-line free. */
|
|
@@ -117,7 +118,8 @@ type ResolveGenuiCatalog = (scope: GenuiCatalogScope) => Catalog | Promise<Catal
|
|
|
117
118
|
interface GenuiToolsOptions {
|
|
118
119
|
/**
|
|
119
120
|
* `per-component` (default): one tool per model-facing component, `ui__show_<snake>`, whose input
|
|
120
|
-
* IS the component's props
|
|
121
|
+
* IS the component's props — except layout components (`children: true`), which a flat input
|
|
122
|
+
* cannot fill. `tree`: a single tool whose input is a nested
|
|
121
123
|
* `{ type, props, children }` tree composed from the catalog (json-render's nested shape).
|
|
122
124
|
*/
|
|
123
125
|
mode?: 'per-component' | 'tree';
|
package/dist/genui/index.js
CHANGED
|
@@ -358,6 +358,10 @@ function defineComponent(definition) {
|
|
|
358
358
|
return definition;
|
|
359
359
|
}
|
|
360
360
|
__name(defineComponent, "defineComponent");
|
|
361
|
+
function flatComponents(catalog) {
|
|
362
|
+
return catalog.modelComponents().filter((component) => component.children !== true);
|
|
363
|
+
}
|
|
364
|
+
__name(flatComponents, "flatComponents");
|
|
361
365
|
function defineCatalog(components, options = {}) {
|
|
362
366
|
const byName = /* @__PURE__ */ new Map();
|
|
363
367
|
for (const component of components) {
|
|
@@ -660,32 +664,31 @@ function componentToText(catalog, component, props) {
|
|
|
660
664
|
const root = props.root;
|
|
661
665
|
return root === void 0 ? "" : treeToText(catalog, root);
|
|
662
666
|
}
|
|
663
|
-
|
|
667
|
+
return ownText(catalog, component, props) ?? "";
|
|
668
|
+
}
|
|
669
|
+
__name(componentToText, "componentToText");
|
|
670
|
+
function ownText(catalog, component, props) {
|
|
671
|
+
const definition = catalog.get(component);
|
|
672
|
+
const fallback = definition?.fallbackText;
|
|
673
|
+
let failed = false;
|
|
664
674
|
if (fallback !== void 0) {
|
|
665
675
|
try {
|
|
666
676
|
const text = fallback(props);
|
|
667
677
|
if (typeof text === "string" && text.trim().length > 0) return text;
|
|
668
678
|
} catch {
|
|
679
|
+
failed = true;
|
|
669
680
|
}
|
|
670
681
|
}
|
|
682
|
+
if (definition?.children === true && !failed) return void 0;
|
|
671
683
|
return jsonBlock(props);
|
|
672
684
|
}
|
|
673
|
-
__name(
|
|
685
|
+
__name(ownText, "ownText");
|
|
674
686
|
function treeToText(catalog, root) {
|
|
675
687
|
const out = [];
|
|
676
688
|
const visit = /* @__PURE__ */ __name((node, depth) => {
|
|
677
689
|
if (depth > 32) return;
|
|
678
|
-
const
|
|
679
|
-
if (
|
|
680
|
-
try {
|
|
681
|
-
const text = definition.fallbackText(node.props);
|
|
682
|
-
out.push(typeof text === "string" && text.trim().length > 0 ? text : jsonBlock(node.props));
|
|
683
|
-
} catch {
|
|
684
|
-
out.push(jsonBlock(node.props));
|
|
685
|
-
}
|
|
686
|
-
} else if (definition?.children !== true) {
|
|
687
|
-
out.push(jsonBlock(node.props));
|
|
688
|
-
}
|
|
690
|
+
const text = ownText(catalog, node.type, node.props);
|
|
691
|
+
if (text !== void 0) out.push(text);
|
|
689
692
|
for (const child of node.children ?? []) visit(child, depth + 1);
|
|
690
693
|
}, "visit");
|
|
691
694
|
visit(root, 0);
|
|
@@ -710,7 +713,8 @@ function catalogToModelText(catalog, options = {}) {
|
|
|
710
713
|
} else {
|
|
711
714
|
lines.push("Components you can show (one tool each):");
|
|
712
715
|
}
|
|
713
|
-
|
|
716
|
+
const components = mode === "tree" ? catalog.modelComponents() : flatComponents(catalog);
|
|
717
|
+
for (const component of components) {
|
|
714
718
|
const schema = toJsonSchema(component.props);
|
|
715
719
|
const head = mode === "per-component" ? `- ${component.name} (tool \`${toolNameFor(component.name, options.namePrefix)}\`)` : `- ${component.name}`;
|
|
716
720
|
lines.push(`${head}: ${component.description}`);
|
|
@@ -867,7 +871,7 @@ var GENUI_SHOW_TOOL = "ui__show";
|
|
|
867
871
|
function genuiTools(catalog, options = {}) {
|
|
868
872
|
const tools = options.mode === "tree" ? [
|
|
869
873
|
treeTool(catalog, options)
|
|
870
|
-
] : catalog
|
|
874
|
+
] : flatComponents(catalog).map((component) => componentTool(catalog, component, options));
|
|
871
875
|
if (options.showTool !== void 0 && options.showTool !== false) {
|
|
872
876
|
tools.push(showTool(catalog, options));
|
|
873
877
|
}
|
|
@@ -921,7 +925,7 @@ function componentTool(catalog, component, options) {
|
|
|
921
925
|
const handler = {
|
|
922
926
|
async execute(input, ctx) {
|
|
923
927
|
const resolved = await catalogFor(catalog, options, scopeOf(ctx));
|
|
924
|
-
const definition =
|
|
928
|
+
const definition = flatComponent(resolved, component.name);
|
|
925
929
|
if (definition === void 0) {
|
|
926
930
|
throw new Error(`component "${component.name}" is not available here`);
|
|
927
931
|
}
|
|
@@ -934,7 +938,7 @@ function componentTool(catalog, component, options) {
|
|
|
934
938
|
};
|
|
935
939
|
handler.describe = async (scope) => {
|
|
936
940
|
const resolved = negotiateCatalog(await catalogFor(catalog, options, scopeOf(scope)), scope.uiCapabilities);
|
|
937
|
-
const definition =
|
|
941
|
+
const definition = flatComponent(resolved, component.name);
|
|
938
942
|
if (definition === void 0) {
|
|
939
943
|
return {
|
|
940
944
|
available: false,
|
|
@@ -1025,7 +1029,7 @@ function showToolJsonSchema(catalog) {
|
|
|
1025
1029
|
properties: {
|
|
1026
1030
|
component: {
|
|
1027
1031
|
type: "string",
|
|
1028
|
-
enum: catalog
|
|
1032
|
+
enum: flatComponents(catalog).map((component) => component.name),
|
|
1029
1033
|
description: "Component name from the catalog"
|
|
1030
1034
|
},
|
|
1031
1035
|
props: {
|
|
@@ -1066,9 +1070,9 @@ async function validateShow(catalog, input, phase = "input") {
|
|
|
1066
1070
|
]
|
|
1067
1071
|
};
|
|
1068
1072
|
}
|
|
1069
|
-
const definition =
|
|
1073
|
+
const definition = flatComponent(catalog, component);
|
|
1070
1074
|
if (definition === void 0) {
|
|
1071
|
-
const allowed = catalog
|
|
1075
|
+
const allowed = flatComponents(catalog).map((each) => each.name).join(", ");
|
|
1072
1076
|
return {
|
|
1073
1077
|
ok: false,
|
|
1074
1078
|
issues: [
|
|
@@ -1131,7 +1135,7 @@ function showTool(catalog, options) {
|
|
|
1131
1135
|
handler.describe = async (scope) => {
|
|
1132
1136
|
const resolved = negotiateCatalog(await catalogFor(catalog, options, scopeOf(scope)), scope.uiCapabilities);
|
|
1133
1137
|
return {
|
|
1134
|
-
available: resolved
|
|
1138
|
+
available: flatComponents(resolved).length > 0,
|
|
1135
1139
|
description: describeFor(resolved),
|
|
1136
1140
|
inputSchema: permissiveSchema(showToolJsonSchema(resolved))
|
|
1137
1141
|
};
|
|
@@ -1159,11 +1163,11 @@ function showTool(catalog, options) {
|
|
|
1159
1163
|
};
|
|
1160
1164
|
}
|
|
1161
1165
|
__name(showTool, "showTool");
|
|
1162
|
-
function
|
|
1166
|
+
function flatComponent(catalog, name) {
|
|
1163
1167
|
const definition = catalog.get(name);
|
|
1164
|
-
return definition === void 0 || definition.internal === true ? void 0 : definition;
|
|
1168
|
+
return definition === void 0 || definition.internal === true || definition.children === true ? void 0 : definition;
|
|
1165
1169
|
}
|
|
1166
|
-
__name(
|
|
1170
|
+
__name(flatComponent, "flatComponent");
|
|
1167
1171
|
async function push(ctx, component, props, version) {
|
|
1168
1172
|
const { id } = await ctx.emitUi(component, props, version !== void 0 ? {
|
|
1169
1173
|
version
|
|
@@ -1408,18 +1412,49 @@ var Chart = defineComponent({
|
|
|
1408
1412
|
"series",
|
|
1409
1413
|
"data"
|
|
1410
1414
|
]),
|
|
1411
|
-
fallbackText: /* @__PURE__ */ __name((props) =>
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1415
|
+
fallbackText: /* @__PURE__ */ __name((props) => chartText(props), "fallbackText")
|
|
1416
|
+
});
|
|
1417
|
+
function chartText(props) {
|
|
1418
|
+
const series = (props.series ?? []).filter((each) => typeof each?.key === "string");
|
|
1419
|
+
const data = props.data ?? [];
|
|
1420
|
+
const unit = props.unit ? ` ${s(props.unit)}` : "";
|
|
1421
|
+
const labelOf = /* @__PURE__ */ __name((each) => s(each.label) || each.key, "labelOf");
|
|
1422
|
+
if (props.type === "line") {
|
|
1423
|
+
const columns = [
|
|
1424
|
+
{
|
|
1425
|
+
key: s(props.xKey),
|
|
1426
|
+
label: s(props.xKey)
|
|
1427
|
+
},
|
|
1428
|
+
...series.map((each) => ({
|
|
1429
|
+
key: each.key,
|
|
1430
|
+
label: `${labelOf(each)}${unit}`
|
|
1431
|
+
}))
|
|
1432
|
+
];
|
|
1433
|
+
return `${heading(props)}${textTable(columns, data, 20)}`;
|
|
1434
|
+
}
|
|
1435
|
+
const max = Math.max(0, ...data.flatMap((point) => series.map((each) => Math.abs(Number(point[each.key]) || 0))));
|
|
1436
|
+
const shown = data.slice(0, 20);
|
|
1437
|
+
const lines = [];
|
|
1438
|
+
if (series.length <= 1) {
|
|
1439
|
+
const key = series[0]?.key ?? "";
|
|
1440
|
+
for (const point of shown) {
|
|
1441
|
+
lines.push(`${s(point[props.xKey]).slice(0, 18).padEnd(18)} ${bar(Number(point[key]) || 0, max)} ${s(point[key])}${unit}`);
|
|
1442
|
+
}
|
|
1443
|
+
} else {
|
|
1444
|
+
const width = Math.min(18, Math.max(...series.map((each) => labelOf(each).length)));
|
|
1445
|
+
for (const point of shown) {
|
|
1446
|
+
lines.push(s(point[props.xKey]).slice(0, 18));
|
|
1447
|
+
for (const each of series) {
|
|
1448
|
+
lines.push(` ${labelOf(each).slice(0, width).padEnd(width)} ${bar(Number(point[each.key]) || 0, max)} ${s(point[each.key])}${unit}`);
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
if (data.length > shown.length) lines.push(`\u2026 ${data.length - shown.length} more points`);
|
|
1453
|
+
return `${heading(props)}\`\`\`
|
|
1419
1454
|
${lines.join("\n")}
|
|
1420
1455
|
\`\`\``;
|
|
1421
|
-
|
|
1422
|
-
|
|
1456
|
+
}
|
|
1457
|
+
__name(chartText, "chartText");
|
|
1423
1458
|
var KpiCards = defineComponent({
|
|
1424
1459
|
name: "KpiCards",
|
|
1425
1460
|
title: "KPI cards",
|
|
@@ -1814,6 +1849,7 @@ export {
|
|
|
1814
1849
|
defineCatalog,
|
|
1815
1850
|
defineComponent,
|
|
1816
1851
|
fillTemplate,
|
|
1852
|
+
flatComponents,
|
|
1817
1853
|
formatIssues,
|
|
1818
1854
|
genuiTools,
|
|
1819
1855
|
getPath,
|