@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
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { I as InputProcessor, O as OutputProcessor } from '../processors-
|
|
2
|
-
import { a as Actor, b as ToolHandler } from '../stream-events-
|
|
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-
|
|
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-
|
|
2
|
-
import { a as Actor, b as ToolHandler } from '../stream-events-
|
|
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-
|
|
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
|
@@ -25,6 +25,7 @@ __export(src_exports, {
|
|
|
25
25
|
AGENT_ACTOR_RESOLVER: () => AGENT_ACTOR_RESOLVER,
|
|
26
26
|
AGENT_APPROVAL_PORT: () => AGENT_APPROVAL_PORT,
|
|
27
27
|
AGENT_ATTACHMENT_STAGING: () => AGENT_ATTACHMENT_STAGING,
|
|
28
|
+
AGENT_CHANNEL_STORE: () => AGENT_CHANNEL_STORE,
|
|
28
29
|
AGENT_CONFIRM_TOKEN_STORE: () => AGENT_CONFIRM_TOKEN_STORE,
|
|
29
30
|
AGENT_DEPS_FACTORY: () => AGENT_DEPS_FACTORY,
|
|
30
31
|
AGENT_DIAGNOSTIC_EVENTS: () => AGENT_DIAGNOSTIC_EVENTS,
|
|
@@ -79,6 +80,7 @@ __export(src_exports, {
|
|
|
79
80
|
GLOBAL_SCOPE: () => GLOBAL_SCOPE,
|
|
80
81
|
InMemoryActionProposalStore: () => InMemoryActionProposalStore,
|
|
81
82
|
InMemoryAgentStore: () => InMemoryAgentStore,
|
|
83
|
+
InMemoryChannelStore: () => InMemoryChannelStore,
|
|
82
84
|
InMemoryConfirmTokenStore: () => InMemoryConfirmTokenStore,
|
|
83
85
|
MAX_ASK_QUESTIONS: () => MAX_ASK_QUESTIONS,
|
|
84
86
|
OutputRejectedError: () => OutputRejectedError,
|
|
@@ -308,6 +310,7 @@ var AGENT_SKILLS = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skills");
|
|
|
308
310
|
var AGENT_MEMORY = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:memory");
|
|
309
311
|
var AGENT_SKILL_SOURCES = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-sources");
|
|
310
312
|
var AGENT_CONFIRM_TOKEN_STORE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:confirm-token-store");
|
|
313
|
+
var AGENT_CHANNEL_STORE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:channel-store");
|
|
311
314
|
|
|
312
315
|
// src/spi/model-catalog.ts
|
|
313
316
|
function staticModelCatalog(view) {
|
|
@@ -3590,32 +3593,31 @@ function componentToText(catalog, component, props) {
|
|
|
3590
3593
|
const root = props.root;
|
|
3591
3594
|
return root === void 0 ? "" : treeToText(catalog, root);
|
|
3592
3595
|
}
|
|
3593
|
-
|
|
3596
|
+
return ownText(catalog, component, props) ?? "";
|
|
3597
|
+
}
|
|
3598
|
+
__name(componentToText, "componentToText");
|
|
3599
|
+
function ownText(catalog, component, props) {
|
|
3600
|
+
const definition = catalog.get(component);
|
|
3601
|
+
const fallback = definition?.fallbackText;
|
|
3602
|
+
let failed = false;
|
|
3594
3603
|
if (fallback !== void 0) {
|
|
3595
3604
|
try {
|
|
3596
3605
|
const text = fallback(props);
|
|
3597
3606
|
if (typeof text === "string" && text.trim().length > 0) return text;
|
|
3598
3607
|
} catch {
|
|
3608
|
+
failed = true;
|
|
3599
3609
|
}
|
|
3600
3610
|
}
|
|
3611
|
+
if (definition?.children === true && !failed) return void 0;
|
|
3601
3612
|
return jsonBlock(props);
|
|
3602
3613
|
}
|
|
3603
|
-
__name(
|
|
3614
|
+
__name(ownText, "ownText");
|
|
3604
3615
|
function treeToText(catalog, root) {
|
|
3605
3616
|
const out = [];
|
|
3606
3617
|
const visit = /* @__PURE__ */ __name((node, depth) => {
|
|
3607
3618
|
if (depth > 32) return;
|
|
3608
|
-
const
|
|
3609
|
-
if (
|
|
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
|
-
}
|
|
3619
|
+
const text = ownText(catalog, node.type, node.props);
|
|
3620
|
+
if (text !== void 0) out.push(text);
|
|
3619
3621
|
for (const child of node.children ?? []) visit(child, depth + 1);
|
|
3620
3622
|
}, "visit");
|
|
3621
3623
|
visit(root, 0);
|
|
@@ -4198,18 +4200,49 @@ var Chart = defineComponent({
|
|
|
4198
4200
|
"series",
|
|
4199
4201
|
"data"
|
|
4200
4202
|
]),
|
|
4201
|
-
fallbackText: /* @__PURE__ */ __name((props) =>
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4203
|
+
fallbackText: /* @__PURE__ */ __name((props) => chartText(props), "fallbackText")
|
|
4204
|
+
});
|
|
4205
|
+
function chartText(props) {
|
|
4206
|
+
const series = (props.series ?? []).filter((each) => typeof each?.key === "string");
|
|
4207
|
+
const data = props.data ?? [];
|
|
4208
|
+
const unit = props.unit ? ` ${s(props.unit)}` : "";
|
|
4209
|
+
const labelOf = /* @__PURE__ */ __name((each) => s(each.label) || each.key, "labelOf");
|
|
4210
|
+
if (props.type === "line") {
|
|
4211
|
+
const columns = [
|
|
4212
|
+
{
|
|
4213
|
+
key: s(props.xKey),
|
|
4214
|
+
label: s(props.xKey)
|
|
4215
|
+
},
|
|
4216
|
+
...series.map((each) => ({
|
|
4217
|
+
key: each.key,
|
|
4218
|
+
label: `${labelOf(each)}${unit}`
|
|
4219
|
+
}))
|
|
4220
|
+
];
|
|
4221
|
+
return `${heading(props)}${textTable(columns, data, 20)}`;
|
|
4222
|
+
}
|
|
4223
|
+
const max = Math.max(0, ...data.flatMap((point) => series.map((each) => Math.abs(Number(point[each.key]) || 0))));
|
|
4224
|
+
const shown = data.slice(0, 20);
|
|
4225
|
+
const lines = [];
|
|
4226
|
+
if (series.length <= 1) {
|
|
4227
|
+
const key = series[0]?.key ?? "";
|
|
4228
|
+
for (const point of shown) {
|
|
4229
|
+
lines.push(`${s(point[props.xKey]).slice(0, 18).padEnd(18)} ${bar(Number(point[key]) || 0, max)} ${s(point[key])}${unit}`);
|
|
4230
|
+
}
|
|
4231
|
+
} else {
|
|
4232
|
+
const width = Math.min(18, Math.max(...series.map((each) => labelOf(each).length)));
|
|
4233
|
+
for (const point of shown) {
|
|
4234
|
+
lines.push(s(point[props.xKey]).slice(0, 18));
|
|
4235
|
+
for (const each of series) {
|
|
4236
|
+
lines.push(` ${labelOf(each).slice(0, width).padEnd(width)} ${bar(Number(point[each.key]) || 0, max)} ${s(point[each.key])}${unit}`);
|
|
4237
|
+
}
|
|
4238
|
+
}
|
|
4239
|
+
}
|
|
4240
|
+
if (data.length > shown.length) lines.push(`\u2026 ${data.length - shown.length} more points`);
|
|
4241
|
+
return `${heading(props)}\`\`\`
|
|
4209
4242
|
${lines.join("\n")}
|
|
4210
4243
|
\`\`\``;
|
|
4211
|
-
|
|
4212
|
-
|
|
4244
|
+
}
|
|
4245
|
+
__name(chartText, "chartText");
|
|
4213
4246
|
var KpiCards = defineComponent({
|
|
4214
4247
|
name: "KpiCards",
|
|
4215
4248
|
title: "KPI cards",
|
|
@@ -8756,6 +8789,62 @@ var InMemoryConfirmTokenStore = class {
|
|
|
8756
8789
|
}
|
|
8757
8790
|
};
|
|
8758
8791
|
|
|
8792
|
+
// src/channel-store.ts
|
|
8793
|
+
var InMemoryChannelStore = class {
|
|
8794
|
+
static {
|
|
8795
|
+
__name(this, "InMemoryChannelStore");
|
|
8796
|
+
}
|
|
8797
|
+
maxEntries;
|
|
8798
|
+
#entries = /* @__PURE__ */ new Map();
|
|
8799
|
+
constructor(maxEntries = 5e4) {
|
|
8800
|
+
this.maxEntries = maxEntries;
|
|
8801
|
+
}
|
|
8802
|
+
#live(key) {
|
|
8803
|
+
const entry = this.#entries.get(key);
|
|
8804
|
+
if (entry === void 0) return void 0;
|
|
8805
|
+
if (entry.expiresAt > Date.now()) return entry;
|
|
8806
|
+
this.#entries.delete(key);
|
|
8807
|
+
return void 0;
|
|
8808
|
+
}
|
|
8809
|
+
#put(key, value, ttlMs) {
|
|
8810
|
+
const now = Date.now();
|
|
8811
|
+
this.#entries.delete(key);
|
|
8812
|
+
this.#entries.set(key, {
|
|
8813
|
+
value,
|
|
8814
|
+
expiresAt: now + ttlMs
|
|
8815
|
+
});
|
|
8816
|
+
if (this.#entries.size <= this.maxEntries) return;
|
|
8817
|
+
for (const [stored, entry] of this.#entries) {
|
|
8818
|
+
if (this.#entries.size <= this.maxEntries && entry.expiresAt > now) break;
|
|
8819
|
+
this.#entries.delete(stored);
|
|
8820
|
+
}
|
|
8821
|
+
}
|
|
8822
|
+
async claim(key, ttlMs) {
|
|
8823
|
+
if (this.#live(key) !== void 0) return false;
|
|
8824
|
+
this.#put(key, null, ttlMs);
|
|
8825
|
+
return true;
|
|
8826
|
+
}
|
|
8827
|
+
async get(key) {
|
|
8828
|
+
return this.#live(key)?.value ?? null;
|
|
8829
|
+
}
|
|
8830
|
+
async set(key, value, ttlMs) {
|
|
8831
|
+
this.#put(key, value, ttlMs);
|
|
8832
|
+
}
|
|
8833
|
+
async delete(key) {
|
|
8834
|
+
this.#entries.delete(key);
|
|
8835
|
+
}
|
|
8836
|
+
async purgeExpired(now = Date.now()) {
|
|
8837
|
+
let purged = 0;
|
|
8838
|
+
for (const [key, entry] of this.#entries) {
|
|
8839
|
+
if (entry.expiresAt <= now) {
|
|
8840
|
+
this.#entries.delete(key);
|
|
8841
|
+
purged += 1;
|
|
8842
|
+
}
|
|
8843
|
+
}
|
|
8844
|
+
return purged;
|
|
8845
|
+
}
|
|
8846
|
+
};
|
|
8847
|
+
|
|
8759
8848
|
// src/confirmed-tool.ts
|
|
8760
8849
|
var DEFAULT_MESSAGES = {
|
|
8761
8850
|
confirm: 'Nothing was written. Show this preview to the user and ask them to confirm. To commit, call this tool again with the SAME arguments plus "confirm": true and this "confirmToken" (valid for {minutes} minutes).',
|
|
@@ -9655,6 +9744,7 @@ __name(createFunctionalTool, "createFunctionalTool");
|
|
|
9655
9744
|
AGENT_ACTOR_RESOLVER,
|
|
9656
9745
|
AGENT_APPROVAL_PORT,
|
|
9657
9746
|
AGENT_ATTACHMENT_STAGING,
|
|
9747
|
+
AGENT_CHANNEL_STORE,
|
|
9658
9748
|
AGENT_CONFIRM_TOKEN_STORE,
|
|
9659
9749
|
AGENT_DEPS_FACTORY,
|
|
9660
9750
|
AGENT_DIAGNOSTIC_EVENTS,
|
|
@@ -9709,6 +9799,7 @@ __name(createFunctionalTool, "createFunctionalTool");
|
|
|
9709
9799
|
GLOBAL_SCOPE,
|
|
9710
9800
|
InMemoryActionProposalStore,
|
|
9711
9801
|
InMemoryAgentStore,
|
|
9802
|
+
InMemoryChannelStore,
|
|
9712
9803
|
InMemoryConfirmTokenStore,
|
|
9713
9804
|
MAX_ASK_QUESTIONS,
|
|
9714
9805
|
OutputRejectedError,
|