@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.
Files changed (36) hide show
  1. package/README.md +7 -0
  2. package/dist/ag-ui/index.cjs +46 -10
  3. package/dist/ag-ui/index.cjs.map +1 -1
  4. package/dist/ag-ui/index.d.cts +9 -3
  5. package/dist/ag-ui/index.d.ts +9 -3
  6. package/dist/ag-ui/index.js +46 -10
  7. package/dist/ag-ui/index.js.map +1 -1
  8. package/dist/{catalog-CrzetM3_.d.cts → catalog-BKS3Yxo6.d.cts} +2 -0
  9. package/dist/{catalog-CrzetM3_.d.ts → catalog-BKS3Yxo6.d.ts} +2 -0
  10. package/dist/genui/builtins.cjs.map +1 -1
  11. package/dist/genui/builtins.d.cts +1 -1
  12. package/dist/genui/builtins.d.ts +1 -1
  13. package/dist/genui/builtins.js.map +1 -1
  14. package/dist/genui/index.cjs +660 -68
  15. package/dist/genui/index.cjs.map +1 -1
  16. package/dist/genui/index.d.cts +5 -5
  17. package/dist/genui/index.d.ts +5 -5
  18. package/dist/genui/index.js +654 -68
  19. package/dist/genui/index.js.map +1 -1
  20. package/dist/guardrails/index.cjs +3 -1
  21. package/dist/guardrails/index.cjs.map +1 -1
  22. package/dist/guardrails/index.d.cts +5 -4
  23. package/dist/guardrails/index.d.ts +5 -4
  24. package/dist/guardrails/index.js +3 -1
  25. package/dist/guardrails/index.js.map +1 -1
  26. package/dist/index.cjs +1164 -421
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +124 -13
  29. package/dist/index.d.ts +124 -13
  30. package/dist/index.js +1156 -421
  31. package/dist/index.js.map +1 -1
  32. package/dist/{processors-BR3nICcp.d.ts → processors-BKILjME5.d.ts} +1 -1
  33. package/dist/{processors-B7nfbU6E.d.cts → processors-DpHBqRuE.d.cts} +1 -1
  34. package/dist/{stream-events-M0jc7lSW.d.cts → stream-events-C-pj3bVY.d.cts} +92 -4
  35. package/dist/{stream-events-DAmes2Of.d.ts → stream-events-D92SgfRk.d.ts} +92 -4
  36. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
- import { A as AgentStreamEvent, U as UiCapabilities } from '../stream-events-DAmes2Of.js';
1
+ import { A as AgentStreamEvent, U as UiCapabilities } from '../stream-events-D92SgfRk.js';
2
2
  import '@standard-schema/spec';
3
- import '../catalog-CrzetM3_.js';
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
- kind: 'approval' | 'elicitation';
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. */
@@ -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 === "approval" ? "a" : "e",
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) || parsed.length !== 5) return null;
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: "aviary.action-proposal-decision",
1092
+ name: AG_UI_CUSTOM.actionProposalDecision,
1057
1093
  value: {
1058
1094
  threadId: input.threadId,
1059
1095
  proposalDecision: input.proposalDecision