@dudousxd/nestjs-agent-core 0.40.0 → 0.42.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/README.md +7 -0
- package/dist/ag-ui/index.cjs +46 -10
- package/dist/ag-ui/index.cjs.map +1 -1
- package/dist/ag-ui/index.d.cts +9 -3
- package/dist/ag-ui/index.d.ts +9 -3
- package/dist/ag-ui/index.js +46 -10
- package/dist/ag-ui/index.js.map +1 -1
- package/dist/{catalog-CrzetM3_.d.cts → catalog-BKS3Yxo6.d.cts} +2 -0
- package/dist/{catalog-CrzetM3_.d.ts → catalog-BKS3Yxo6.d.ts} +2 -0
- 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.map +1 -1
- package/dist/genui/index.cjs +660 -68
- package/dist/genui/index.cjs.map +1 -1
- package/dist/genui/index.d.cts +5 -5
- package/dist/genui/index.d.ts +5 -5
- package/dist/genui/index.js +654 -68
- package/dist/genui/index.js.map +1 -1
- package/dist/guardrails/index.cjs +3 -1
- package/dist/guardrails/index.cjs.map +1 -1
- package/dist/guardrails/index.d.cts +5 -4
- package/dist/guardrails/index.d.ts +5 -4
- package/dist/guardrails/index.js +3 -1
- package/dist/guardrails/index.js.map +1 -1
- package/dist/index.cjs +1164 -421
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +124 -13
- package/dist/index.d.ts +124 -13
- package/dist/index.js +1156 -421
- package/dist/index.js.map +1 -1
- package/dist/{processors-BR3nICcp.d.ts → processors-BKILjME5.d.ts} +1 -1
- package/dist/{processors-B7nfbU6E.d.cts → processors-DpHBqRuE.d.cts} +1 -1
- package/dist/{stream-events-M0jc7lSW.d.cts → stream-events-C-pj3bVY.d.cts} +92 -4
- package/dist/{stream-events-DAmes2Of.d.ts → stream-events-D92SgfRk.d.ts} +92 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,6 +16,13 @@ provider, a store, a sink) against the SPIs.
|
|
|
16
16
|
import type { ModelProvider, AgentStore, ToolSpec, RolesPolicy } from '@dudousxd/nestjs-agent-core';
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
## Component registries and server rendering
|
|
20
|
+
|
|
21
|
+
Tools support a `present` hook in both functional and decorated class forms. Register custom components per app, share React renderers between web screens and static exports, and generate paginated PNG/PDF tables and charts for your own delivery adapters.
|
|
22
|
+
|
|
23
|
+
See the [component rendering guide](../../docs/component-rendering.md) for complete examples, schemas, text fallbacks, and capture configuration.
|
|
24
|
+
|
|
25
|
+
|
|
19
26
|
## Key types
|
|
20
27
|
|
|
21
28
|
- `ToolSpec` — `{ name, kind: 'read' | 'action' | 'agent', description, inputSchema, roles?, ability?, targetAgent?, detached?, terminal? }`. (`ToolKind` has three further members — `'ask'`, `'skill'` and `'memory'` — which no `ToolSpec` carries: they belong to the built-in tools the loop serves itself rather than from a handler. `ask` settles against a person, `skill` against the turn's journaled catalog, `remember` against the turn's journaled memory digest.) `inputSchema` is a [Standard Schema](https://standardschema.dev) (Zod, Valibot, ArkType); the loop validates via `~standard.validate`, throwing `ToolInputInvalidError` on failure.
|
package/dist/ag-ui/index.cjs
CHANGED
|
@@ -41,15 +41,21 @@ __export(ag_ui_exports, {
|
|
|
41
41
|
module.exports = __toCommonJS(ag_ui_exports);
|
|
42
42
|
|
|
43
43
|
// src/ag-ui/interrupt-id.ts
|
|
44
|
+
var KIND_CODES = {
|
|
45
|
+
approval: "a",
|
|
46
|
+
elicitation: "e",
|
|
47
|
+
proposal: "p"
|
|
48
|
+
};
|
|
44
49
|
var PREFIX = "agora_";
|
|
45
50
|
function encodeInterruptId(address) {
|
|
46
51
|
const compact = [
|
|
47
|
-
address.kind
|
|
52
|
+
KIND_CODES[address.kind],
|
|
48
53
|
address.parked,
|
|
49
54
|
address.stream,
|
|
50
55
|
address.toolCallId,
|
|
51
56
|
address.position
|
|
52
57
|
];
|
|
58
|
+
if (address.kind === "proposal") compact.push(address.proposalId, address.threadId);
|
|
53
59
|
return PREFIX + Buffer.from(JSON.stringify(compact), "utf8").toString("base64url");
|
|
54
60
|
}
|
|
55
61
|
__name(encodeInterruptId, "encodeInterruptId");
|
|
@@ -57,17 +63,21 @@ function decodeInterruptId(id) {
|
|
|
57
63
|
if (typeof id !== "string" || !id.startsWith(PREFIX)) return null;
|
|
58
64
|
try {
|
|
59
65
|
const parsed = JSON.parse(Buffer.from(id.slice(PREFIX.length), "base64url").toString("utf8"));
|
|
60
|
-
if (!Array.isArray(parsed)
|
|
61
|
-
const [kind, parked, stream, toolCallId, position] = parsed;
|
|
62
|
-
if (kind !== "a" && kind !== "e" || typeof parked !== "string" || typeof stream !== "string" || typeof toolCallId !== "string" || typeof position !== "number" || !Number.isSafeInteger(position) || position < 0) {
|
|
66
|
+
if (!Array.isArray(parsed)) return null;
|
|
67
|
+
const [kind, parked, stream, toolCallId, position, proposalId, threadId] = parsed;
|
|
68
|
+
if (parsed.length !== (kind === "p" ? 7 : 5) || kind === "p" && (typeof proposalId !== "string" || typeof threadId !== "string") || kind !== "a" && kind !== "e" && kind !== "p" || typeof parked !== "string" || typeof stream !== "string" || typeof toolCallId !== "string" || typeof position !== "number" || !Number.isSafeInteger(position) || position < 0) {
|
|
63
69
|
return null;
|
|
64
70
|
}
|
|
65
71
|
return {
|
|
66
|
-
kind: kind === "a" ? "approval" : "elicitation",
|
|
72
|
+
kind: kind === "a" ? "approval" : kind === "e" ? "elicitation" : "proposal",
|
|
67
73
|
parked,
|
|
68
74
|
stream,
|
|
69
75
|
toolCallId,
|
|
70
|
-
position
|
|
76
|
+
position,
|
|
77
|
+
...kind === "p" ? {
|
|
78
|
+
proposalId,
|
|
79
|
+
threadId
|
|
80
|
+
} : {}
|
|
71
81
|
};
|
|
72
82
|
} catch {
|
|
73
83
|
return null;
|
|
@@ -91,6 +101,8 @@ var AG_UI_CUSTOM = {
|
|
|
91
101
|
elicitation: "agora.elicitation",
|
|
92
102
|
/** `{ usage, costUsd, reasoningMs }` of one model step. */
|
|
93
103
|
stepUsage: "agora.step-usage",
|
|
104
|
+
/** A proposal decided by a text message or an interrupt resume, with no model run behind it. */
|
|
105
|
+
actionProposalDecision: "agora.action-proposal-decision",
|
|
94
106
|
/** `{ message }` — input material this producer could not use and dropped. */
|
|
95
107
|
warning: "agora.warning"
|
|
96
108
|
};
|
|
@@ -278,6 +290,13 @@ var AgUiEncoder = class {
|
|
|
278
290
|
...event.version !== void 0 ? {
|
|
279
291
|
version: event.version
|
|
280
292
|
} : {},
|
|
293
|
+
// What a client that cannot draw the component shows instead.
|
|
294
|
+
...event.fallbackText !== void 0 ? {
|
|
295
|
+
fallbackText: event.fallbackText
|
|
296
|
+
} : {},
|
|
297
|
+
...event.componentVersions !== void 0 ? {
|
|
298
|
+
componentVersions: event.componentVersions
|
|
299
|
+
} : {},
|
|
281
300
|
...event.toolCallId !== void 0 ? {
|
|
282
301
|
toolCallId: event.toolCallId
|
|
283
302
|
} : {}
|
|
@@ -288,10 +307,14 @@ var AgUiEncoder = class {
|
|
|
288
307
|
const parked = event.runId ?? this.options.streamRunId;
|
|
289
308
|
const toolName = event.toolName ?? call?.name ?? "";
|
|
290
309
|
const input = event.input ?? call?.input ?? null;
|
|
310
|
+
const proposal = event.target?.kind === "proposal" ? event.target : void 0;
|
|
291
311
|
this.pending.set(event.id, {
|
|
292
|
-
kind: "approval",
|
|
312
|
+
kind: proposal !== void 0 ? "proposal" : "approval",
|
|
293
313
|
parked,
|
|
294
314
|
toolCallId: event.id,
|
|
315
|
+
...proposal !== void 0 ? {
|
|
316
|
+
proposalId: proposal.proposalId
|
|
317
|
+
} : {},
|
|
295
318
|
interrupt: {
|
|
296
319
|
reason: "tool_approval",
|
|
297
320
|
message: event.reason ?? (toolName.length > 0 ? `Approve ${toolName}?` : "Approve?"),
|
|
@@ -303,7 +326,10 @@ var AgUiEncoder = class {
|
|
|
303
326
|
metadata: {
|
|
304
327
|
"agora.toolName": toolName,
|
|
305
328
|
"agora.input": input,
|
|
306
|
-
"agora.approver": event.approver
|
|
329
|
+
"agora.approver": event.approver,
|
|
330
|
+
...event.target !== void 0 ? {
|
|
331
|
+
"agora.target": event.target
|
|
332
|
+
} : {}
|
|
307
333
|
}
|
|
308
334
|
}
|
|
309
335
|
});
|
|
@@ -314,6 +340,12 @@ var AgUiEncoder = class {
|
|
|
314
340
|
toolName,
|
|
315
341
|
input,
|
|
316
342
|
approver: event.approver,
|
|
343
|
+
...event.target !== void 0 ? {
|
|
344
|
+
target: event.target
|
|
345
|
+
} : {},
|
|
346
|
+
...event.confirmation !== void 0 ? {
|
|
347
|
+
confirmation: event.confirmation
|
|
348
|
+
} : {},
|
|
317
349
|
...event.expiresAt !== void 0 ? {
|
|
318
350
|
expiresAt: event.expiresAt
|
|
319
351
|
} : {},
|
|
@@ -541,7 +573,11 @@ var AgUiEncoder = class {
|
|
|
541
573
|
parked: entry.parked,
|
|
542
574
|
stream: this.options.streamRunId,
|
|
543
575
|
toolCallId: entry.toolCallId,
|
|
544
|
-
position: this.position
|
|
576
|
+
position: this.position,
|
|
577
|
+
...entry.proposalId !== void 0 ? {
|
|
578
|
+
proposalId: entry.proposalId,
|
|
579
|
+
threadId: this.options.streamThreadId ?? this.options.threadId
|
|
580
|
+
} : {}
|
|
545
581
|
}),
|
|
546
582
|
...entry.interrupt
|
|
547
583
|
}));
|
|
@@ -1092,7 +1128,7 @@ function actionProposalDecisionEvents(input) {
|
|
|
1092
1128
|
},
|
|
1093
1129
|
{
|
|
1094
1130
|
type: "CUSTOM",
|
|
1095
|
-
name:
|
|
1131
|
+
name: AG_UI_CUSTOM.actionProposalDecision,
|
|
1096
1132
|
value: {
|
|
1097
1133
|
threadId: input.threadId,
|
|
1098
1134
|
proposalDecision: input.proposalDecision
|