@dudousxd/nestjs-agent-core 0.40.0 → 0.41.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 +1161 -421
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +118 -13
- package/dist/index.d.ts +118 -13
- package/dist/index.js +1153 -421
- package/dist/index.js.map +1 -1
- package/dist/{processors-B7nfbU6E.d.cts → processors-BXM-MNga.d.cts} +1 -1
- package/dist/{processors-BR3nICcp.d.ts → processors-ByDr5POu.d.ts} +1 -1
- package/dist/{stream-events-DAmes2Of.d.ts → stream-events-BGKLD6RX.d.ts} +73 -4
- package/dist/{stream-events-M0jc7lSW.d.cts → stream-events-CF-6-Y6L.d.cts} +73 -4
- package/package.json +1 -1
package/dist/ag-ui/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as AgentStreamEvent, U as UiCapabilities } from '../stream-events-
|
|
1
|
+
import { A as AgentStreamEvent, U as UiCapabilities } from '../stream-events-BGKLD6RX.js';
|
|
2
2
|
import '@standard-schema/spec';
|
|
3
|
-
import '../catalog-
|
|
3
|
+
import '../catalog-BKS3Yxo6.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The slice of AG-UI 1.0 (https://docs.ag-ui.com/spec/1.0) this producer writes and reads. Typed by
|
|
@@ -199,6 +199,8 @@ declare const AG_UI_CUSTOM: {
|
|
|
199
199
|
readonly elicitation: "agora.elicitation";
|
|
200
200
|
/** `{ usage, costUsd, reasoningMs }` of one model step. */
|
|
201
201
|
readonly stepUsage: "agora.step-usage";
|
|
202
|
+
/** A proposal decided by a text message or an interrupt resume, with no model run behind it. */
|
|
203
|
+
readonly actionProposalDecision: "agora.action-proposal-decision";
|
|
202
204
|
/** `{ message }` — input material this producer could not use and dropped. */
|
|
203
205
|
readonly warning: "agora.warning";
|
|
204
206
|
};
|
|
@@ -361,7 +363,8 @@ declare class AgUiEncoder {
|
|
|
361
363
|
* the native approve/answer routes do.
|
|
362
364
|
*/
|
|
363
365
|
interface InterruptAddress {
|
|
364
|
-
|
|
366
|
+
/** `proposal` — an independent proposal's approval, decided through the proposal service. */
|
|
367
|
+
kind: 'approval' | 'elicitation' | 'proposal';
|
|
365
368
|
/** The run to settle the call on. */
|
|
366
369
|
parked: string;
|
|
367
370
|
/** The run whose buffered stream the resume re-attaches to. */
|
|
@@ -369,6 +372,9 @@ interface InterruptAddress {
|
|
|
369
372
|
toolCallId: string;
|
|
370
373
|
/** Frames of `stream` already delivered when the run was reported interrupted. */
|
|
371
374
|
position: number;
|
|
375
|
+
/** `proposal` only: the proposal and the library thread it belongs to. */
|
|
376
|
+
proposalId?: string;
|
|
377
|
+
threadId?: string;
|
|
372
378
|
}
|
|
373
379
|
declare function encodeInterruptId(address: InterruptAddress): string;
|
|
374
380
|
/** The address an id names, or `null` for an id this producer did not mint. */
|
package/dist/ag-ui/index.js
CHANGED
|
@@ -2,15 +2,21 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/ag-ui/interrupt-id.ts
|
|
5
|
+
var KIND_CODES = {
|
|
6
|
+
approval: "a",
|
|
7
|
+
elicitation: "e",
|
|
8
|
+
proposal: "p"
|
|
9
|
+
};
|
|
5
10
|
var PREFIX = "agora_";
|
|
6
11
|
function encodeInterruptId(address) {
|
|
7
12
|
const compact = [
|
|
8
|
-
address.kind
|
|
13
|
+
KIND_CODES[address.kind],
|
|
9
14
|
address.parked,
|
|
10
15
|
address.stream,
|
|
11
16
|
address.toolCallId,
|
|
12
17
|
address.position
|
|
13
18
|
];
|
|
19
|
+
if (address.kind === "proposal") compact.push(address.proposalId, address.threadId);
|
|
14
20
|
return PREFIX + Buffer.from(JSON.stringify(compact), "utf8").toString("base64url");
|
|
15
21
|
}
|
|
16
22
|
__name(encodeInterruptId, "encodeInterruptId");
|
|
@@ -18,17 +24,21 @@ function decodeInterruptId(id) {
|
|
|
18
24
|
if (typeof id !== "string" || !id.startsWith(PREFIX)) return null;
|
|
19
25
|
try {
|
|
20
26
|
const parsed = JSON.parse(Buffer.from(id.slice(PREFIX.length), "base64url").toString("utf8"));
|
|
21
|
-
if (!Array.isArray(parsed)
|
|
22
|
-
const [kind, parked, stream, toolCallId, position] = parsed;
|
|
23
|
-
if (kind !== "a" && kind !== "e" || typeof parked !== "string" || typeof stream !== "string" || typeof toolCallId !== "string" || typeof position !== "number" || !Number.isSafeInteger(position) || position < 0) {
|
|
27
|
+
if (!Array.isArray(parsed)) return null;
|
|
28
|
+
const [kind, parked, stream, toolCallId, position, proposalId, threadId] = parsed;
|
|
29
|
+
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) {
|
|
24
30
|
return null;
|
|
25
31
|
}
|
|
26
32
|
return {
|
|
27
|
-
kind: kind === "a" ? "approval" : "elicitation",
|
|
33
|
+
kind: kind === "a" ? "approval" : kind === "e" ? "elicitation" : "proposal",
|
|
28
34
|
parked,
|
|
29
35
|
stream,
|
|
30
36
|
toolCallId,
|
|
31
|
-
position
|
|
37
|
+
position,
|
|
38
|
+
...kind === "p" ? {
|
|
39
|
+
proposalId,
|
|
40
|
+
threadId
|
|
41
|
+
} : {}
|
|
32
42
|
};
|
|
33
43
|
} catch {
|
|
34
44
|
return null;
|
|
@@ -52,6 +62,8 @@ var AG_UI_CUSTOM = {
|
|
|
52
62
|
elicitation: "agora.elicitation",
|
|
53
63
|
/** `{ usage, costUsd, reasoningMs }` of one model step. */
|
|
54
64
|
stepUsage: "agora.step-usage",
|
|
65
|
+
/** A proposal decided by a text message or an interrupt resume, with no model run behind it. */
|
|
66
|
+
actionProposalDecision: "agora.action-proposal-decision",
|
|
55
67
|
/** `{ message }` — input material this producer could not use and dropped. */
|
|
56
68
|
warning: "agora.warning"
|
|
57
69
|
};
|
|
@@ -239,6 +251,13 @@ var AgUiEncoder = class {
|
|
|
239
251
|
...event.version !== void 0 ? {
|
|
240
252
|
version: event.version
|
|
241
253
|
} : {},
|
|
254
|
+
// What a client that cannot draw the component shows instead.
|
|
255
|
+
...event.fallbackText !== void 0 ? {
|
|
256
|
+
fallbackText: event.fallbackText
|
|
257
|
+
} : {},
|
|
258
|
+
...event.componentVersions !== void 0 ? {
|
|
259
|
+
componentVersions: event.componentVersions
|
|
260
|
+
} : {},
|
|
242
261
|
...event.toolCallId !== void 0 ? {
|
|
243
262
|
toolCallId: event.toolCallId
|
|
244
263
|
} : {}
|
|
@@ -249,10 +268,14 @@ var AgUiEncoder = class {
|
|
|
249
268
|
const parked = event.runId ?? this.options.streamRunId;
|
|
250
269
|
const toolName = event.toolName ?? call?.name ?? "";
|
|
251
270
|
const input = event.input ?? call?.input ?? null;
|
|
271
|
+
const proposal = event.target?.kind === "proposal" ? event.target : void 0;
|
|
252
272
|
this.pending.set(event.id, {
|
|
253
|
-
kind: "approval",
|
|
273
|
+
kind: proposal !== void 0 ? "proposal" : "approval",
|
|
254
274
|
parked,
|
|
255
275
|
toolCallId: event.id,
|
|
276
|
+
...proposal !== void 0 ? {
|
|
277
|
+
proposalId: proposal.proposalId
|
|
278
|
+
} : {},
|
|
256
279
|
interrupt: {
|
|
257
280
|
reason: "tool_approval",
|
|
258
281
|
message: event.reason ?? (toolName.length > 0 ? `Approve ${toolName}?` : "Approve?"),
|
|
@@ -264,7 +287,10 @@ var AgUiEncoder = class {
|
|
|
264
287
|
metadata: {
|
|
265
288
|
"agora.toolName": toolName,
|
|
266
289
|
"agora.input": input,
|
|
267
|
-
"agora.approver": event.approver
|
|
290
|
+
"agora.approver": event.approver,
|
|
291
|
+
...event.target !== void 0 ? {
|
|
292
|
+
"agora.target": event.target
|
|
293
|
+
} : {}
|
|
268
294
|
}
|
|
269
295
|
}
|
|
270
296
|
});
|
|
@@ -275,6 +301,12 @@ var AgUiEncoder = class {
|
|
|
275
301
|
toolName,
|
|
276
302
|
input,
|
|
277
303
|
approver: event.approver,
|
|
304
|
+
...event.target !== void 0 ? {
|
|
305
|
+
target: event.target
|
|
306
|
+
} : {},
|
|
307
|
+
...event.confirmation !== void 0 ? {
|
|
308
|
+
confirmation: event.confirmation
|
|
309
|
+
} : {},
|
|
278
310
|
...event.expiresAt !== void 0 ? {
|
|
279
311
|
expiresAt: event.expiresAt
|
|
280
312
|
} : {},
|
|
@@ -502,7 +534,11 @@ var AgUiEncoder = class {
|
|
|
502
534
|
parked: entry.parked,
|
|
503
535
|
stream: this.options.streamRunId,
|
|
504
536
|
toolCallId: entry.toolCallId,
|
|
505
|
-
position: this.position
|
|
537
|
+
position: this.position,
|
|
538
|
+
...entry.proposalId !== void 0 ? {
|
|
539
|
+
proposalId: entry.proposalId,
|
|
540
|
+
threadId: this.options.streamThreadId ?? this.options.threadId
|
|
541
|
+
} : {}
|
|
506
542
|
}),
|
|
507
543
|
...entry.interrupt
|
|
508
544
|
}));
|
|
@@ -1053,7 +1089,7 @@ function actionProposalDecisionEvents(input) {
|
|
|
1053
1089
|
},
|
|
1054
1090
|
{
|
|
1055
1091
|
type: "CUSTOM",
|
|
1056
|
-
name:
|
|
1092
|
+
name: AG_UI_CUSTOM.actionProposalDecision,
|
|
1057
1093
|
value: {
|
|
1058
1094
|
threadId: input.threadId,
|
|
1059
1095
|
proposalDecision: input.proposalDecision
|