@dudousxd/nestjs-agent-core 0.21.0 → 0.23.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 +2 -1
- package/dist/guardrails/index.d.cts +1 -1
- package/dist/guardrails/index.d.ts +1 -1
- package/dist/index.cjs +156 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -3
- package/dist/index.d.ts +53 -3
- package/dist/index.js +152 -21
- package/dist/index.js.map +1 -1
- package/dist/{tool-CwXibnce.d.cts → tool-BdW-LV1J.d.cts} +59 -1
- package/dist/{tool-CwXibnce.d.ts → tool-BdW-LV1J.d.ts} +59 -1
- package/package.json +1 -1
|
@@ -385,6 +385,12 @@ interface AgentUiComponent {
|
|
|
385
385
|
props: Record<string, unknown>;
|
|
386
386
|
/** Schema version of `props`, so a client can keep rendering components persisted by an older server. */
|
|
387
387
|
version?: number;
|
|
388
|
+
/**
|
|
389
|
+
* The tool call that pushed the component (`ctx.emitUi`), when one did. Lets a client place it
|
|
390
|
+
* with that call — a reloaded message puts it right after the call's tool part, where the live
|
|
391
|
+
* stream showed it. Absent for a component pushed outside a tool.
|
|
392
|
+
*/
|
|
393
|
+
toolCallId?: string;
|
|
388
394
|
}
|
|
389
395
|
/**
|
|
390
396
|
* Who has to settle an action tool call, and until when. Metadata only: the call itself is still
|
|
@@ -796,6 +802,17 @@ interface ToolSpec {
|
|
|
796
802
|
* reads the branch back rather than re-deciding it against a registry that may have changed.
|
|
797
803
|
*/
|
|
798
804
|
detached?: boolean;
|
|
805
|
+
/**
|
|
806
|
+
* The turn ends once a call to this tool SUCCEEDS: the loop finishes the step (results persisted
|
|
807
|
+
* and streamed) and makes no further model call. For a tool whose effect IS the answer — pushing
|
|
808
|
+
* a composed UI, handing off — where a model call narrating it would only repeat it. A failed or
|
|
809
|
+
* refused call does not end the turn, so the model can correct it.
|
|
810
|
+
*
|
|
811
|
+
* Settled into the call's `persist:toolcall` checkpoint (like `targetAgent`), so a replay takes
|
|
812
|
+
* the same branch. Ending early skips what a final step would do: follow-ups and the
|
|
813
|
+
* `outputSchema` formatting pass.
|
|
814
|
+
*/
|
|
815
|
+
terminal?: boolean;
|
|
799
816
|
/** Roles allowed to invoke. Undefined → defaults applied by RolesPolicy (e.g. ADMIN-only). */
|
|
800
817
|
roles?: string[];
|
|
801
818
|
/**
|
|
@@ -1181,8 +1198,22 @@ interface StoredMessage {
|
|
|
1181
1198
|
* for one, or on a store that does not record approvals.
|
|
1182
1199
|
*/
|
|
1183
1200
|
approvals?: ToolCallApproval[];
|
|
1201
|
+
/**
|
|
1202
|
+
* The thread owner's rating of this message (`POST <base>/messages/:id/feedback`). Absent when
|
|
1203
|
+
* nobody rated it, or on a store that does not record feedback.
|
|
1204
|
+
*/
|
|
1205
|
+
feedback?: MessageFeedback;
|
|
1184
1206
|
createdAt: string;
|
|
1185
1207
|
}
|
|
1208
|
+
/** A thumbs-up/down on one message, with an optional free-text comment. */
|
|
1209
|
+
type MessageFeedbackValue = 'up' | 'down';
|
|
1210
|
+
/** What {@link StoredMessage.feedback} holds. Not copied when a thread is forked. */
|
|
1211
|
+
interface MessageFeedback {
|
|
1212
|
+
value: MessageFeedbackValue;
|
|
1213
|
+
comment?: string;
|
|
1214
|
+
/** ISO-8601 instant the rating was last set. */
|
|
1215
|
+
updatedAt: string;
|
|
1216
|
+
}
|
|
1186
1217
|
/**
|
|
1187
1218
|
* How one approval stands. `pending` → still parked; `approved` → someone said yes (or a remembered
|
|
1188
1219
|
* approval did); `rejected` → someone said no; `expired` → nobody answered before `expiresAt`.
|
|
@@ -1259,6 +1290,12 @@ interface ToolStepEnvelope {
|
|
|
1259
1290
|
* `AgentRunSteps.tool`) instead of trying to serialize a function.
|
|
1260
1291
|
*/
|
|
1261
1292
|
transientRetry: ToolTransientRetryNumbers | false;
|
|
1293
|
+
/**
|
|
1294
|
+
* The dispatching loop reads the components the tool pushed (`ctx.emitUi`) off the step's result.
|
|
1295
|
+
* A handler that sees it returns {@link wrapToolStepOutput}'s envelope when the tool pushed any —
|
|
1296
|
+
* and ONLY then, so a loop that predates this (and never sets it) always gets the bare output.
|
|
1297
|
+
*/
|
|
1298
|
+
collectUi?: boolean;
|
|
1262
1299
|
}
|
|
1263
1300
|
|
|
1264
1301
|
/**
|
|
@@ -1433,6 +1470,27 @@ interface AiToolCtx {
|
|
|
1433
1470
|
pageContext?: PageContext;
|
|
1434
1471
|
/** Optional host handle (e.g. an ORM EntityManager) the app threads through options. */
|
|
1435
1472
|
host?: unknown;
|
|
1473
|
+
/**
|
|
1474
|
+
* Push a component into the assistant message: streamed live as a `ui` frame and persisted on
|
|
1475
|
+
* the message, so a reload shows it where the live stream did. Resolves to the component's id.
|
|
1476
|
+
*
|
|
1477
|
+
* `id` defaults to `<toolCallId>:ui:<n>` (the n-th push without an `id` in this invocation), so a retried or
|
|
1478
|
+
* re-executed call REPLACES what it pushed before instead of adding a second copy; pass your own
|
|
1479
|
+
* `id` to update one component across pushes (streaming rows into a table). `props` must be
|
|
1480
|
+
* JSON; it is snapshotted when pushed.
|
|
1481
|
+
*
|
|
1482
|
+
* Replay-safe under the durable runner: the pushed components ride the tool step's journaled
|
|
1483
|
+
* result, so a replay neither streams nor persists them again. Present whenever the agent loop
|
|
1484
|
+
* runs the tool (inline, durable, dispatched); absent on surfaces with no conversation to push
|
|
1485
|
+
* into (the MCP server), hence optional — call it as `ctx.emitUi?.(…)` in a tool that is also
|
|
1486
|
+
* served there.
|
|
1487
|
+
*/
|
|
1488
|
+
emitUi?(component: string, props: Record<string, unknown>, options?: {
|
|
1489
|
+
id?: string;
|
|
1490
|
+
version?: number;
|
|
1491
|
+
}): Promise<{
|
|
1492
|
+
id: string;
|
|
1493
|
+
}>;
|
|
1436
1494
|
}
|
|
1437
1495
|
/** A tool implementation. `I` is the parsed (Zod-validated) input. */
|
|
1438
1496
|
interface ToolHandler<I = unknown> {
|
|
@@ -1466,4 +1524,4 @@ interface ToolHandler<I = unknown> {
|
|
|
1466
1524
|
canUse?(actor: Actor): boolean | Promise<boolean>;
|
|
1467
1525
|
}
|
|
1468
1526
|
|
|
1469
|
-
export { type
|
|
1527
|
+
export { type ElicitationInput as $, type Actor as A, type Decision as B, type ToolStepEnvelope as C, type DetachedDelivery as D, type ElicitationRequest as E, ASK_TOOL_DESCRIPTION as F, ASK_TOOL_NAME as G, type HumanReply as H, type InputProcessor as I, type AgentApprovalRequest as J, type AgentApprovalSettlement as K, type LlmStepEnvelope as L, type ModelMessage as M, type AgentCatalogEntry as N, type OutputProcessor as O, type ProcessorContext as P, type QuotaState as Q, type AgentHistoryWindow as R, type StoredMessage as S, type ToolHandler as T, type UsagePurpose as U, type AskToolInput as V, DEFAULT_INCREMENTAL_LOOKBACK_CHARS as W, DEFAULT_INTAKE_PREAMBLE as X, DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS as Y, DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS as Z, ELICITATION_INPUT_TYPES as _, type ToolDefinition as a, type ElicitationInputType as a0, type ElicitationOption as a1, type ElicitationOutcome as a2, type ElicitationQuestion as a3, type ElicitationReply as a4, type ElicitationResult as a5, type HistoryPolicyContext as a6, type HistorySelection as a7, type HistorySummary as a8, type IncrementalGating as a9, normalizeElicitationReply as aA, questionOptions as aB, readElicitationInput as aC, readElicitationQuestions as aD, renderElicitationAnswers as aE, resolveElicitation as aF, resolveToolTransientRetryNumbers as aG, settleElicitation as aH, validateElicitationAnswer as aI, validateElicitationValue as aJ, type InvokeWithTransientRetryOptions as aa, MAX_ASK_QUESTIONS as ab, type MessageFeedbackValue as ac, type MessageRole as ad, OutputRejectedError as ae, type OutputVerdict as af, ProcessorFailedError as ag, type PromptContext as ah, type QuotaView as ai, type ToolCallApprovalStatus as aj, type ToolCatalogEntry as ak, type ToolConfirmation as al, type ToolPresentation as am, type ToolPresentationTone as an, type ToolResultField as ao, type ToolResultView as ap, type ToolStepCtx as aq, type ToolTransientRetryNumbers as ar, type ToolTransientRetryOptions as as, askInputSchema as at, askToolDefinition as au, decodeStreamEvent as av, encodeStreamEvent as aw, invokeWithTransientRetry as ax, isTransientToolError as ay, isTypedQuestion as az, type ToolCallRequest as b, type MessageUsage as c, type AgentUiComponent as d, type AiToolCtx as e, type AgentStreamEvent as f, type ThreadSummary as g, type ThreadDetail as h, type ToolResult as i, type MessageAttachment as j, type MessageFeedback as k, type ToolCallStatus as l, type ToolSpec as m, type AgentRunInput as n, type ToolKind as o, type ToolCallApproval as p, type HistoryPolicy as q, type ProcessedPrompt as r, type ModelAnswer as s, type PageContext as t, type AgentDefinition as u, type AgentDelegation as v, type PromptBuilder as w, type PromptContributor as x, type ToolTransientRetrySetting as y, type AgentIntake as z };
|
|
@@ -385,6 +385,12 @@ interface AgentUiComponent {
|
|
|
385
385
|
props: Record<string, unknown>;
|
|
386
386
|
/** Schema version of `props`, so a client can keep rendering components persisted by an older server. */
|
|
387
387
|
version?: number;
|
|
388
|
+
/**
|
|
389
|
+
* The tool call that pushed the component (`ctx.emitUi`), when one did. Lets a client place it
|
|
390
|
+
* with that call — a reloaded message puts it right after the call's tool part, where the live
|
|
391
|
+
* stream showed it. Absent for a component pushed outside a tool.
|
|
392
|
+
*/
|
|
393
|
+
toolCallId?: string;
|
|
388
394
|
}
|
|
389
395
|
/**
|
|
390
396
|
* Who has to settle an action tool call, and until when. Metadata only: the call itself is still
|
|
@@ -796,6 +802,17 @@ interface ToolSpec {
|
|
|
796
802
|
* reads the branch back rather than re-deciding it against a registry that may have changed.
|
|
797
803
|
*/
|
|
798
804
|
detached?: boolean;
|
|
805
|
+
/**
|
|
806
|
+
* The turn ends once a call to this tool SUCCEEDS: the loop finishes the step (results persisted
|
|
807
|
+
* and streamed) and makes no further model call. For a tool whose effect IS the answer — pushing
|
|
808
|
+
* a composed UI, handing off — where a model call narrating it would only repeat it. A failed or
|
|
809
|
+
* refused call does not end the turn, so the model can correct it.
|
|
810
|
+
*
|
|
811
|
+
* Settled into the call's `persist:toolcall` checkpoint (like `targetAgent`), so a replay takes
|
|
812
|
+
* the same branch. Ending early skips what a final step would do: follow-ups and the
|
|
813
|
+
* `outputSchema` formatting pass.
|
|
814
|
+
*/
|
|
815
|
+
terminal?: boolean;
|
|
799
816
|
/** Roles allowed to invoke. Undefined → defaults applied by RolesPolicy (e.g. ADMIN-only). */
|
|
800
817
|
roles?: string[];
|
|
801
818
|
/**
|
|
@@ -1181,8 +1198,22 @@ interface StoredMessage {
|
|
|
1181
1198
|
* for one, or on a store that does not record approvals.
|
|
1182
1199
|
*/
|
|
1183
1200
|
approvals?: ToolCallApproval[];
|
|
1201
|
+
/**
|
|
1202
|
+
* The thread owner's rating of this message (`POST <base>/messages/:id/feedback`). Absent when
|
|
1203
|
+
* nobody rated it, or on a store that does not record feedback.
|
|
1204
|
+
*/
|
|
1205
|
+
feedback?: MessageFeedback;
|
|
1184
1206
|
createdAt: string;
|
|
1185
1207
|
}
|
|
1208
|
+
/** A thumbs-up/down on one message, with an optional free-text comment. */
|
|
1209
|
+
type MessageFeedbackValue = 'up' | 'down';
|
|
1210
|
+
/** What {@link StoredMessage.feedback} holds. Not copied when a thread is forked. */
|
|
1211
|
+
interface MessageFeedback {
|
|
1212
|
+
value: MessageFeedbackValue;
|
|
1213
|
+
comment?: string;
|
|
1214
|
+
/** ISO-8601 instant the rating was last set. */
|
|
1215
|
+
updatedAt: string;
|
|
1216
|
+
}
|
|
1186
1217
|
/**
|
|
1187
1218
|
* How one approval stands. `pending` → still parked; `approved` → someone said yes (or a remembered
|
|
1188
1219
|
* approval did); `rejected` → someone said no; `expired` → nobody answered before `expiresAt`.
|
|
@@ -1259,6 +1290,12 @@ interface ToolStepEnvelope {
|
|
|
1259
1290
|
* `AgentRunSteps.tool`) instead of trying to serialize a function.
|
|
1260
1291
|
*/
|
|
1261
1292
|
transientRetry: ToolTransientRetryNumbers | false;
|
|
1293
|
+
/**
|
|
1294
|
+
* The dispatching loop reads the components the tool pushed (`ctx.emitUi`) off the step's result.
|
|
1295
|
+
* A handler that sees it returns {@link wrapToolStepOutput}'s envelope when the tool pushed any —
|
|
1296
|
+
* and ONLY then, so a loop that predates this (and never sets it) always gets the bare output.
|
|
1297
|
+
*/
|
|
1298
|
+
collectUi?: boolean;
|
|
1262
1299
|
}
|
|
1263
1300
|
|
|
1264
1301
|
/**
|
|
@@ -1433,6 +1470,27 @@ interface AiToolCtx {
|
|
|
1433
1470
|
pageContext?: PageContext;
|
|
1434
1471
|
/** Optional host handle (e.g. an ORM EntityManager) the app threads through options. */
|
|
1435
1472
|
host?: unknown;
|
|
1473
|
+
/**
|
|
1474
|
+
* Push a component into the assistant message: streamed live as a `ui` frame and persisted on
|
|
1475
|
+
* the message, so a reload shows it where the live stream did. Resolves to the component's id.
|
|
1476
|
+
*
|
|
1477
|
+
* `id` defaults to `<toolCallId>:ui:<n>` (the n-th push without an `id` in this invocation), so a retried or
|
|
1478
|
+
* re-executed call REPLACES what it pushed before instead of adding a second copy; pass your own
|
|
1479
|
+
* `id` to update one component across pushes (streaming rows into a table). `props` must be
|
|
1480
|
+
* JSON; it is snapshotted when pushed.
|
|
1481
|
+
*
|
|
1482
|
+
* Replay-safe under the durable runner: the pushed components ride the tool step's journaled
|
|
1483
|
+
* result, so a replay neither streams nor persists them again. Present whenever the agent loop
|
|
1484
|
+
* runs the tool (inline, durable, dispatched); absent on surfaces with no conversation to push
|
|
1485
|
+
* into (the MCP server), hence optional — call it as `ctx.emitUi?.(…)` in a tool that is also
|
|
1486
|
+
* served there.
|
|
1487
|
+
*/
|
|
1488
|
+
emitUi?(component: string, props: Record<string, unknown>, options?: {
|
|
1489
|
+
id?: string;
|
|
1490
|
+
version?: number;
|
|
1491
|
+
}): Promise<{
|
|
1492
|
+
id: string;
|
|
1493
|
+
}>;
|
|
1436
1494
|
}
|
|
1437
1495
|
/** A tool implementation. `I` is the parsed (Zod-validated) input. */
|
|
1438
1496
|
interface ToolHandler<I = unknown> {
|
|
@@ -1466,4 +1524,4 @@ interface ToolHandler<I = unknown> {
|
|
|
1466
1524
|
canUse?(actor: Actor): boolean | Promise<boolean>;
|
|
1467
1525
|
}
|
|
1468
1526
|
|
|
1469
|
-
export { type
|
|
1527
|
+
export { type ElicitationInput as $, type Actor as A, type Decision as B, type ToolStepEnvelope as C, type DetachedDelivery as D, type ElicitationRequest as E, ASK_TOOL_DESCRIPTION as F, ASK_TOOL_NAME as G, type HumanReply as H, type InputProcessor as I, type AgentApprovalRequest as J, type AgentApprovalSettlement as K, type LlmStepEnvelope as L, type ModelMessage as M, type AgentCatalogEntry as N, type OutputProcessor as O, type ProcessorContext as P, type QuotaState as Q, type AgentHistoryWindow as R, type StoredMessage as S, type ToolHandler as T, type UsagePurpose as U, type AskToolInput as V, DEFAULT_INCREMENTAL_LOOKBACK_CHARS as W, DEFAULT_INTAKE_PREAMBLE as X, DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS as Y, DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS as Z, ELICITATION_INPUT_TYPES as _, type ToolDefinition as a, type ElicitationInputType as a0, type ElicitationOption as a1, type ElicitationOutcome as a2, type ElicitationQuestion as a3, type ElicitationReply as a4, type ElicitationResult as a5, type HistoryPolicyContext as a6, type HistorySelection as a7, type HistorySummary as a8, type IncrementalGating as a9, normalizeElicitationReply as aA, questionOptions as aB, readElicitationInput as aC, readElicitationQuestions as aD, renderElicitationAnswers as aE, resolveElicitation as aF, resolveToolTransientRetryNumbers as aG, settleElicitation as aH, validateElicitationAnswer as aI, validateElicitationValue as aJ, type InvokeWithTransientRetryOptions as aa, MAX_ASK_QUESTIONS as ab, type MessageFeedbackValue as ac, type MessageRole as ad, OutputRejectedError as ae, type OutputVerdict as af, ProcessorFailedError as ag, type PromptContext as ah, type QuotaView as ai, type ToolCallApprovalStatus as aj, type ToolCatalogEntry as ak, type ToolConfirmation as al, type ToolPresentation as am, type ToolPresentationTone as an, type ToolResultField as ao, type ToolResultView as ap, type ToolStepCtx as aq, type ToolTransientRetryNumbers as ar, type ToolTransientRetryOptions as as, askInputSchema as at, askToolDefinition as au, decodeStreamEvent as av, encodeStreamEvent as aw, invokeWithTransientRetry as ax, isTransientToolError as ay, isTypedQuestion as az, type ToolCallRequest as b, type MessageUsage as c, type AgentUiComponent as d, type AiToolCtx as e, type AgentStreamEvent as f, type ThreadSummary as g, type ThreadDetail as h, type ToolResult as i, type MessageAttachment as j, type MessageFeedback as k, type ToolCallStatus as l, type ToolSpec as m, type AgentRunInput as n, type ToolKind as o, type ToolCallApproval as p, type HistoryPolicy as q, type ProcessedPrompt as r, type ModelAnswer as s, type PageContext as t, type AgentDefinition as u, type AgentDelegation as v, type PromptBuilder as w, type PromptContributor as x, type ToolTransientRetrySetting as y, type AgentIntake as z };
|