@dudousxd/nestjs-agent-core 0.38.1 → 0.40.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.
@@ -1,5 +1,6 @@
1
- import { A as AgentStreamEvent } from '../stream-events-rpd3d6gh.cjs';
1
+ import { A as AgentStreamEvent, U as UiCapabilities } from '../stream-events-M0jc7lSW.cjs';
2
2
  import '@standard-schema/spec';
3
+ import '../catalog-CrzetM3_.cjs';
3
4
 
4
5
  /**
5
6
  * The slice of AG-UI 1.0 (https://docs.ag-ui.com/spec/1.0) this producer writes and reads. Typed by
@@ -412,6 +413,7 @@ declare function readContext(context: readonly AgUiContext[] | undefined): AgUiC
412
413
  * model: which agent, which model, which persona, and the page context the tools see.
413
414
  */
414
415
  interface ForwardedOptions {
416
+ uiCapabilities?: UiCapabilities;
415
417
  agent?: string;
416
418
  model?: string;
417
419
  persona?: string;
@@ -476,4 +478,12 @@ declare function agUiSse(event: AgUiEvent): string;
476
478
  */
477
479
  declare function agUiFramesFromNdjson(chunks: AsyncIterable<Uint8Array>): AsyncGenerator<AgUiSourceFrame>;
478
480
 
479
- export { AG_UI_CUSTOM, AG_UI_PROTOCOL_VERSION, type AgUiContentPart, type AgUiContext, AgUiEncoder, type AgUiEncoderOptions, type AgUiEvent, type AgUiInterrupt, type AgUiMessage, type AgUiMetadata, type AgUiPartSource, type AgUiResumeEntry, type AgUiRunInput, type AgUiRunOutcome, type AgUiSourceFrame, type AgUiStreamOptions, type AgUiTokenUsage, type ForwardedOptions, type InlineMedia, type InterruptAddress, type ResumeDecision, type ResumePlan, type UserTurn, agUiEvents, agUiFramesFromNdjson, agUiSse, decodeInterruptId, encodeInterruptId, parseRunInput, planResume, readAnswersPayload, readApprovalPayload, readContext, readForwardedProps, readUserTurn };
481
+ /** A decision-only protocol invocation: no model run, stream holder or tool execution is created. */
482
+ declare function actionProposalDecisionEvents(input: {
483
+ threadId: string;
484
+ runId: string;
485
+ text: string;
486
+ proposalDecision: unknown;
487
+ }): AgUiEvent[];
488
+
489
+ export { AG_UI_CUSTOM, AG_UI_PROTOCOL_VERSION, type AgUiContentPart, type AgUiContext, AgUiEncoder, type AgUiEncoderOptions, type AgUiEvent, type AgUiInterrupt, type AgUiMessage, type AgUiMetadata, type AgUiPartSource, type AgUiResumeEntry, type AgUiRunInput, type AgUiRunOutcome, type AgUiSourceFrame, type AgUiStreamOptions, type AgUiTokenUsage, type ForwardedOptions, type InlineMedia, type InterruptAddress, type ResumeDecision, type ResumePlan, type UserTurn, actionProposalDecisionEvents, agUiEvents, agUiFramesFromNdjson, agUiSse, decodeInterruptId, encodeInterruptId, parseRunInput, planResume, readAnswersPayload, readApprovalPayload, readContext, readForwardedProps, readUserTurn };
@@ -1,5 +1,6 @@
1
- import { A as AgentStreamEvent } from '../stream-events-rpd3d6gh.js';
1
+ import { A as AgentStreamEvent, U as UiCapabilities } from '../stream-events-DAmes2Of.js';
2
2
  import '@standard-schema/spec';
3
+ import '../catalog-CrzetM3_.js';
3
4
 
4
5
  /**
5
6
  * The slice of AG-UI 1.0 (https://docs.ag-ui.com/spec/1.0) this producer writes and reads. Typed by
@@ -412,6 +413,7 @@ declare function readContext(context: readonly AgUiContext[] | undefined): AgUiC
412
413
  * model: which agent, which model, which persona, and the page context the tools see.
413
414
  */
414
415
  interface ForwardedOptions {
416
+ uiCapabilities?: UiCapabilities;
415
417
  agent?: string;
416
418
  model?: string;
417
419
  persona?: string;
@@ -476,4 +478,12 @@ declare function agUiSse(event: AgUiEvent): string;
476
478
  */
477
479
  declare function agUiFramesFromNdjson(chunks: AsyncIterable<Uint8Array>): AsyncGenerator<AgUiSourceFrame>;
478
480
 
479
- export { AG_UI_CUSTOM, AG_UI_PROTOCOL_VERSION, type AgUiContentPart, type AgUiContext, AgUiEncoder, type AgUiEncoderOptions, type AgUiEvent, type AgUiInterrupt, type AgUiMessage, type AgUiMetadata, type AgUiPartSource, type AgUiResumeEntry, type AgUiRunInput, type AgUiRunOutcome, type AgUiSourceFrame, type AgUiStreamOptions, type AgUiTokenUsage, type ForwardedOptions, type InlineMedia, type InterruptAddress, type ResumeDecision, type ResumePlan, type UserTurn, agUiEvents, agUiFramesFromNdjson, agUiSse, decodeInterruptId, encodeInterruptId, parseRunInput, planResume, readAnswersPayload, readApprovalPayload, readContext, readForwardedProps, readUserTurn };
481
+ /** A decision-only protocol invocation: no model run, stream holder or tool execution is created. */
482
+ declare function actionProposalDecisionEvents(input: {
483
+ threadId: string;
484
+ runId: string;
485
+ text: string;
486
+ proposalDecision: unknown;
487
+ }): AgUiEvent[];
488
+
489
+ export { AG_UI_CUSTOM, AG_UI_PROTOCOL_VERSION, type AgUiContentPart, type AgUiContext, AgUiEncoder, type AgUiEncoderOptions, type AgUiEvent, type AgUiInterrupt, type AgUiMessage, type AgUiMetadata, type AgUiPartSource, type AgUiResumeEntry, type AgUiRunInput, type AgUiRunOutcome, type AgUiSourceFrame, type AgUiStreamOptions, type AgUiTokenUsage, type ForwardedOptions, type InlineMedia, type InterruptAddress, type ResumeDecision, type ResumePlan, type UserTurn, actionProposalDecisionEvents, agUiEvents, agUiFramesFromNdjson, agUiSse, decodeInterruptId, encodeInterruptId, parseRunInput, planResume, readAnswersPayload, readApprovalPayload, readContext, readForwardedProps, readUserTurn };
@@ -655,6 +655,31 @@ var AgUiEncoder = class {
655
655
  }
656
656
  };
657
657
 
658
+ // src/genui/catalog.ts
659
+ var COMPONENT_NAME = /^[A-Za-z][A-Za-z0-9]{0,63}$/;
660
+
661
+ // src/genui/capabilities.ts
662
+ function validateUiCapabilities(value) {
663
+ if (!record(value) || Object.keys(value).some((key) => key !== "components") || !Array.isArray(value.components)) throw new TypeError("Invalid UI capabilities");
664
+ const seen = /* @__PURE__ */ new Set();
665
+ const components = value.components.map((component) => {
666
+ if (!record(component) || Object.keys(component).some((key) => key !== "name" && key !== "version") || typeof component.name !== "string" || !COMPONENT_NAME.test(component.name) || !Number.isSafeInteger(component.version) || Number(component.version) <= 0 || seen.has(component.name)) throw new TypeError("Invalid UI component capability");
667
+ seen.add(component.name);
668
+ return {
669
+ name: component.name,
670
+ version: Number(component.version)
671
+ };
672
+ });
673
+ return {
674
+ components
675
+ };
676
+ }
677
+ __name(validateUiCapabilities, "validateUiCapabilities");
678
+ function record(value) {
679
+ return typeof value === "object" && value !== null && !Array.isArray(value);
680
+ }
681
+ __name(record, "record");
682
+
658
683
  // src/ag-ui/input.ts
659
684
  function isRecord(value) {
660
685
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -686,6 +711,13 @@ function parseRunInput(body) {
686
711
  if (body.context !== void 0 && !Array.isArray(body.context)) {
687
712
  return "context must be an array";
688
713
  }
714
+ if (isRecord(body.forwardedProps) && Object.hasOwn(body.forwardedProps, "uiCapabilities")) {
715
+ try {
716
+ validateUiCapabilities(body.forwardedProps.uiCapabilities);
717
+ } catch {
718
+ return "forwardedProps.uiCapabilities must be valid UI capabilities";
719
+ }
720
+ }
689
721
  return body;
690
722
  }
691
723
  __name(parseRunInput, "parseRunInput");
@@ -790,6 +822,9 @@ function readForwardedProps(forwarded) {
790
822
  const model = pick("model");
791
823
  const persona = pick("persona");
792
824
  return {
825
+ ...Object.hasOwn(forwarded, "uiCapabilities") ? {
826
+ uiCapabilities: validateUiCapabilities(forwarded.uiCapabilities)
827
+ } : {},
793
828
  ...agent !== void 0 ? {
794
829
  agent
795
830
  } : {},
@@ -1005,10 +1040,52 @@ async function* agUiFramesFromNdjson(chunks) {
1005
1040
  }
1006
1041
  }
1007
1042
  __name(agUiFramesFromNdjson, "agUiFramesFromNdjson");
1043
+
1044
+ // src/ag-ui/proposal-decision.ts
1045
+ function actionProposalDecisionEvents(input) {
1046
+ const messageId = `${input.runId}:proposal-decision`;
1047
+ return [
1048
+ {
1049
+ type: "RUN_STARTED",
1050
+ threadId: input.threadId,
1051
+ runId: input.runId,
1052
+ protocolVersion: AG_UI_PROTOCOL_VERSION
1053
+ },
1054
+ {
1055
+ type: "CUSTOM",
1056
+ name: "aviary.action-proposal-decision",
1057
+ value: {
1058
+ threadId: input.threadId,
1059
+ proposalDecision: input.proposalDecision
1060
+ }
1061
+ },
1062
+ {
1063
+ type: "TEXT_MESSAGE_START",
1064
+ messageId,
1065
+ role: "assistant"
1066
+ },
1067
+ {
1068
+ type: "TEXT_MESSAGE_CONTENT",
1069
+ messageId,
1070
+ delta: input.text
1071
+ },
1072
+ {
1073
+ type: "TEXT_MESSAGE_END",
1074
+ messageId
1075
+ },
1076
+ {
1077
+ type: "RUN_FINISHED",
1078
+ threadId: input.threadId,
1079
+ runId: input.runId
1080
+ }
1081
+ ];
1082
+ }
1083
+ __name(actionProposalDecisionEvents, "actionProposalDecisionEvents");
1008
1084
  export {
1009
1085
  AG_UI_CUSTOM,
1010
1086
  AG_UI_PROTOCOL_VERSION,
1011
1087
  AgUiEncoder,
1088
+ actionProposalDecisionEvents,
1012
1089
  agUiEvents,
1013
1090
  agUiFramesFromNdjson,
1014
1091
  agUiSse,