@dudousxd/nestjs-agent-core 0.41.0 → 0.42.1

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.
@@ -1,7 +1,7 @@
1
- import { I as InputProcessor, O as OutputProcessor } from '../processors-BXM-MNga.cjs';
2
- import { a as Actor, b as ToolHandler } from '../stream-events-CF-6-Y6L.cjs';
1
+ import { I as InputProcessor, O as OutputProcessor } from '../processors-BANqZT3O.cjs';
2
+ import { a as Actor, b as ToolHandler } from '../stream-events-BfxJAckJ.cjs';
3
3
  import '@standard-schema/spec';
4
- import '../catalog-BKS3Yxo6.cjs';
4
+ import '../catalog-G8usJpx5.cjs';
5
5
 
6
6
  /**
7
7
  * Guardrails: detectors that look at text on its way to or from a model — prompts, answers, tool
@@ -1,7 +1,7 @@
1
- import { I as InputProcessor, O as OutputProcessor } from '../processors-ByDr5POu.js';
2
- import { a as Actor, b as ToolHandler } from '../stream-events-BGKLD6RX.js';
1
+ import { I as InputProcessor, O as OutputProcessor } from '../processors-C9mor-73.js';
2
+ import { a as Actor, b as ToolHandler } from '../stream-events-DFa2Do42.js';
3
3
  import '@standard-schema/spec';
4
- import '../catalog-BKS3Yxo6.js';
4
+ import '../catalog-G8usJpx5.js';
5
5
 
6
6
  /**
7
7
  * Guardrails: detectors that look at text on its way to or from a model — prompts, answers, tool
package/dist/index.cjs CHANGED
@@ -3590,32 +3590,31 @@ function componentToText(catalog, component, props) {
3590
3590
  const root = props.root;
3591
3591
  return root === void 0 ? "" : treeToText(catalog, root);
3592
3592
  }
3593
- const fallback = catalog.get(component)?.fallbackText;
3593
+ return ownText(catalog, component, props) ?? "";
3594
+ }
3595
+ __name(componentToText, "componentToText");
3596
+ function ownText(catalog, component, props) {
3597
+ const definition = catalog.get(component);
3598
+ const fallback = definition?.fallbackText;
3599
+ let failed = false;
3594
3600
  if (fallback !== void 0) {
3595
3601
  try {
3596
3602
  const text = fallback(props);
3597
3603
  if (typeof text === "string" && text.trim().length > 0) return text;
3598
3604
  } catch {
3605
+ failed = true;
3599
3606
  }
3600
3607
  }
3608
+ if (definition?.children === true && !failed) return void 0;
3601
3609
  return jsonBlock(props);
3602
3610
  }
3603
- __name(componentToText, "componentToText");
3611
+ __name(ownText, "ownText");
3604
3612
  function treeToText(catalog, root) {
3605
3613
  const out = [];
3606
3614
  const visit = /* @__PURE__ */ __name((node, depth) => {
3607
3615
  if (depth > 32) return;
3608
- const definition = catalog.get(node.type);
3609
- if (definition?.fallbackText !== void 0) {
3610
- try {
3611
- const text = definition.fallbackText(node.props);
3612
- out.push(typeof text === "string" && text.trim().length > 0 ? text : jsonBlock(node.props));
3613
- } catch {
3614
- out.push(jsonBlock(node.props));
3615
- }
3616
- } else if (definition?.children !== true) {
3617
- out.push(jsonBlock(node.props));
3618
- }
3616
+ const text = ownText(catalog, node.type, node.props);
3617
+ if (text !== void 0) out.push(text);
3619
3618
  for (const child of node.children ?? []) visit(child, depth + 1);
3620
3619
  }, "visit");
3621
3620
  visit(root, 0);
@@ -4198,18 +4197,49 @@ var Chart = defineComponent({
4198
4197
  "series",
4199
4198
  "data"
4200
4199
  ]),
4201
- fallbackText: /* @__PURE__ */ __name((props) => {
4202
- const series = props.series ?? [];
4203
- const data = props.data ?? [];
4204
- const first = series[0]?.key ?? "";
4205
- const max = Math.max(0, ...data.map((point) => Math.abs(Number(point[first]) || 0)));
4206
- const unit = props.unit ? ` ${s(props.unit)}` : "";
4207
- const lines = data.slice(0, 20).map((point) => `${s(point[props.xKey]).slice(0, 18).padEnd(18)} ${bar(Number(point[first]) || 0, max)} ${s(point[first])}${unit}`);
4208
- return `${heading(props)}\`\`\`
4200
+ fallbackText: /* @__PURE__ */ __name((props) => chartText(props), "fallbackText")
4201
+ });
4202
+ function chartText(props) {
4203
+ const series = (props.series ?? []).filter((each) => typeof each?.key === "string");
4204
+ const data = props.data ?? [];
4205
+ const unit = props.unit ? ` ${s(props.unit)}` : "";
4206
+ const labelOf = /* @__PURE__ */ __name((each) => s(each.label) || each.key, "labelOf");
4207
+ if (props.type === "line") {
4208
+ const columns = [
4209
+ {
4210
+ key: s(props.xKey),
4211
+ label: s(props.xKey)
4212
+ },
4213
+ ...series.map((each) => ({
4214
+ key: each.key,
4215
+ label: `${labelOf(each)}${unit}`
4216
+ }))
4217
+ ];
4218
+ return `${heading(props)}${textTable(columns, data, 20)}`;
4219
+ }
4220
+ const max = Math.max(0, ...data.flatMap((point) => series.map((each) => Math.abs(Number(point[each.key]) || 0))));
4221
+ const shown = data.slice(0, 20);
4222
+ const lines = [];
4223
+ if (series.length <= 1) {
4224
+ const key = series[0]?.key ?? "";
4225
+ for (const point of shown) {
4226
+ lines.push(`${s(point[props.xKey]).slice(0, 18).padEnd(18)} ${bar(Number(point[key]) || 0, max)} ${s(point[key])}${unit}`);
4227
+ }
4228
+ } else {
4229
+ const width = Math.min(18, Math.max(...series.map((each) => labelOf(each).length)));
4230
+ for (const point of shown) {
4231
+ lines.push(s(point[props.xKey]).slice(0, 18));
4232
+ for (const each of series) {
4233
+ lines.push(` ${labelOf(each).slice(0, width).padEnd(width)} ${bar(Number(point[each.key]) || 0, max)} ${s(point[each.key])}${unit}`);
4234
+ }
4235
+ }
4236
+ }
4237
+ if (data.length > shown.length) lines.push(`\u2026 ${data.length - shown.length} more points`);
4238
+ return `${heading(props)}\`\`\`
4209
4239
  ${lines.join("\n")}
4210
4240
  \`\`\``;
4211
- }, "fallbackText")
4212
- });
4241
+ }
4242
+ __name(chartText, "chartText");
4213
4243
  var KpiCards = defineComponent({
4214
4244
  name: "KpiCards",
4215
4245
  title: "KPI cards",
@@ -8031,6 +8061,9 @@ var InMemoryAgentStore = class extends InMemoryActionProposalStore {
8031
8061
  ...input.uiCapabilities !== void 0 ? {
8032
8062
  uiCapabilities: input.uiCapabilities
8033
8063
  } : {},
8064
+ ...input.hostContext !== void 0 ? {
8065
+ hostContext: input.hostContext
8066
+ } : {},
8034
8067
  ...input.interrupt === true ? {
8035
8068
  interrupt: true
8036
8069
  } : {},