@dudousxd/nestjs-agent-core 0.21.0 → 0.22.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 +41 -3
- package/dist/index.d.ts +41 -3
- package/dist/index.js +152 -21
- package/dist/index.js.map +1 -1
- package/dist/{tool-CwXibnce.d.cts → tool-BQqFt06V.d.cts} +45 -1
- package/dist/{tool-CwXibnce.d.ts → tool-BQqFt06V.d.ts} +45 -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
|
/**
|
|
@@ -1259,6 +1276,12 @@ interface ToolStepEnvelope {
|
|
|
1259
1276
|
* `AgentRunSteps.tool`) instead of trying to serialize a function.
|
|
1260
1277
|
*/
|
|
1261
1278
|
transientRetry: ToolTransientRetryNumbers | false;
|
|
1279
|
+
/**
|
|
1280
|
+
* The dispatching loop reads the components the tool pushed (`ctx.emitUi`) off the step's result.
|
|
1281
|
+
* A handler that sees it returns {@link wrapToolStepOutput}'s envelope when the tool pushed any —
|
|
1282
|
+
* and ONLY then, so a loop that predates this (and never sets it) always gets the bare output.
|
|
1283
|
+
*/
|
|
1284
|
+
collectUi?: boolean;
|
|
1262
1285
|
}
|
|
1263
1286
|
|
|
1264
1287
|
/**
|
|
@@ -1433,6 +1456,27 @@ interface AiToolCtx {
|
|
|
1433
1456
|
pageContext?: PageContext;
|
|
1434
1457
|
/** Optional host handle (e.g. an ORM EntityManager) the app threads through options. */
|
|
1435
1458
|
host?: unknown;
|
|
1459
|
+
/**
|
|
1460
|
+
* Push a component into the assistant message: streamed live as a `ui` frame and persisted on
|
|
1461
|
+
* the message, so a reload shows it where the live stream did. Resolves to the component's id.
|
|
1462
|
+
*
|
|
1463
|
+
* `id` defaults to `<toolCallId>:ui:<n>` (the n-th push without an `id` in this invocation), so a retried or
|
|
1464
|
+
* re-executed call REPLACES what it pushed before instead of adding a second copy; pass your own
|
|
1465
|
+
* `id` to update one component across pushes (streaming rows into a table). `props` must be
|
|
1466
|
+
* JSON; it is snapshotted when pushed.
|
|
1467
|
+
*
|
|
1468
|
+
* Replay-safe under the durable runner: the pushed components ride the tool step's journaled
|
|
1469
|
+
* result, so a replay neither streams nor persists them again. Present whenever the agent loop
|
|
1470
|
+
* runs the tool (inline, durable, dispatched); absent on surfaces with no conversation to push
|
|
1471
|
+
* into (the MCP server), hence optional — call it as `ctx.emitUi?.(…)` in a tool that is also
|
|
1472
|
+
* served there.
|
|
1473
|
+
*/
|
|
1474
|
+
emitUi?(component: string, props: Record<string, unknown>, options?: {
|
|
1475
|
+
id?: string;
|
|
1476
|
+
version?: number;
|
|
1477
|
+
}): Promise<{
|
|
1478
|
+
id: string;
|
|
1479
|
+
}>;
|
|
1436
1480
|
}
|
|
1437
1481
|
/** A tool implementation. `I` is the parsed (Zod-validated) input. */
|
|
1438
1482
|
interface ToolHandler<I = unknown> {
|
|
@@ -1466,4 +1510,4 @@ interface ToolHandler<I = unknown> {
|
|
|
1466
1510
|
canUse?(actor: Actor): boolean | Promise<boolean>;
|
|
1467
1511
|
}
|
|
1468
1512
|
|
|
1469
|
-
export { type ElicitationInputType as $, type Actor as A,
|
|
1513
|
+
export { type ElicitationInputType as $, type Actor as A, type ToolStepEnvelope as B, ASK_TOOL_DESCRIPTION as C, type DetachedDelivery as D, type ElicitationRequest as E, ASK_TOOL_NAME as F, type AgentApprovalRequest as G, type HumanReply as H, type InputProcessor as I, type AgentApprovalSettlement as J, type AgentCatalogEntry as K, type LlmStepEnvelope as L, type ModelMessage as M, type AgentHistoryWindow as N, type OutputProcessor as O, type ProcessorContext as P, type QuotaState as Q, type AskToolInput as R, type StoredMessage as S, type ToolHandler as T, type UsagePurpose as U, DEFAULT_INCREMENTAL_LOOKBACK_CHARS as V, DEFAULT_INTAKE_PREAMBLE as W, DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS as X, DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS as Y, ELICITATION_INPUT_TYPES as Z, type ElicitationInput as _, type ToolDefinition as a, type ElicitationOption as a0, type ElicitationOutcome as a1, type ElicitationQuestion as a2, type ElicitationReply as a3, type ElicitationResult as a4, type HistoryPolicyContext as a5, type HistorySelection as a6, type HistorySummary as a7, type IncrementalGating as a8, type InvokeWithTransientRetryOptions as a9, readElicitationInput as aA, readElicitationQuestions as aB, renderElicitationAnswers as aC, resolveElicitation as aD, resolveToolTransientRetryNumbers as aE, settleElicitation as aF, validateElicitationAnswer as aG, validateElicitationValue as aH, MAX_ASK_QUESTIONS as aa, type MessageRole as ab, OutputRejectedError as ac, type OutputVerdict as ad, ProcessorFailedError as ae, type PromptContext as af, type QuotaView as ag, type ToolCallApprovalStatus as ah, type ToolCatalogEntry as ai, type ToolConfirmation as aj, type ToolPresentation as ak, type ToolPresentationTone as al, type ToolResultField as am, type ToolResultView as an, type ToolStepCtx as ao, type ToolTransientRetryNumbers as ap, type ToolTransientRetryOptions as aq, askInputSchema as ar, askToolDefinition as as, decodeStreamEvent as at, encodeStreamEvent as au, invokeWithTransientRetry as av, isTransientToolError as aw, isTypedQuestion as ax, normalizeElicitationReply as ay, questionOptions 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 ToolCallStatus as k, type ToolSpec as l, type AgentRunInput as m, type ToolKind as n, type ToolCallApproval as o, type HistoryPolicy as p, type ProcessedPrompt as q, type ModelAnswer as r, type PageContext as s, type AgentDefinition as t, type AgentDelegation as u, type PromptBuilder as v, type PromptContributor as w, type ToolTransientRetrySetting as x, type AgentIntake as y, type Decision 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
|
/**
|
|
@@ -1259,6 +1276,12 @@ interface ToolStepEnvelope {
|
|
|
1259
1276
|
* `AgentRunSteps.tool`) instead of trying to serialize a function.
|
|
1260
1277
|
*/
|
|
1261
1278
|
transientRetry: ToolTransientRetryNumbers | false;
|
|
1279
|
+
/**
|
|
1280
|
+
* The dispatching loop reads the components the tool pushed (`ctx.emitUi`) off the step's result.
|
|
1281
|
+
* A handler that sees it returns {@link wrapToolStepOutput}'s envelope when the tool pushed any —
|
|
1282
|
+
* and ONLY then, so a loop that predates this (and never sets it) always gets the bare output.
|
|
1283
|
+
*/
|
|
1284
|
+
collectUi?: boolean;
|
|
1262
1285
|
}
|
|
1263
1286
|
|
|
1264
1287
|
/**
|
|
@@ -1433,6 +1456,27 @@ interface AiToolCtx {
|
|
|
1433
1456
|
pageContext?: PageContext;
|
|
1434
1457
|
/** Optional host handle (e.g. an ORM EntityManager) the app threads through options. */
|
|
1435
1458
|
host?: unknown;
|
|
1459
|
+
/**
|
|
1460
|
+
* Push a component into the assistant message: streamed live as a `ui` frame and persisted on
|
|
1461
|
+
* the message, so a reload shows it where the live stream did. Resolves to the component's id.
|
|
1462
|
+
*
|
|
1463
|
+
* `id` defaults to `<toolCallId>:ui:<n>` (the n-th push without an `id` in this invocation), so a retried or
|
|
1464
|
+
* re-executed call REPLACES what it pushed before instead of adding a second copy; pass your own
|
|
1465
|
+
* `id` to update one component across pushes (streaming rows into a table). `props` must be
|
|
1466
|
+
* JSON; it is snapshotted when pushed.
|
|
1467
|
+
*
|
|
1468
|
+
* Replay-safe under the durable runner: the pushed components ride the tool step's journaled
|
|
1469
|
+
* result, so a replay neither streams nor persists them again. Present whenever the agent loop
|
|
1470
|
+
* runs the tool (inline, durable, dispatched); absent on surfaces with no conversation to push
|
|
1471
|
+
* into (the MCP server), hence optional — call it as `ctx.emitUi?.(…)` in a tool that is also
|
|
1472
|
+
* served there.
|
|
1473
|
+
*/
|
|
1474
|
+
emitUi?(component: string, props: Record<string, unknown>, options?: {
|
|
1475
|
+
id?: string;
|
|
1476
|
+
version?: number;
|
|
1477
|
+
}): Promise<{
|
|
1478
|
+
id: string;
|
|
1479
|
+
}>;
|
|
1436
1480
|
}
|
|
1437
1481
|
/** A tool implementation. `I` is the parsed (Zod-validated) input. */
|
|
1438
1482
|
interface ToolHandler<I = unknown> {
|
|
@@ -1466,4 +1510,4 @@ interface ToolHandler<I = unknown> {
|
|
|
1466
1510
|
canUse?(actor: Actor): boolean | Promise<boolean>;
|
|
1467
1511
|
}
|
|
1468
1512
|
|
|
1469
|
-
export { type ElicitationInputType as $, type Actor as A,
|
|
1513
|
+
export { type ElicitationInputType as $, type Actor as A, type ToolStepEnvelope as B, ASK_TOOL_DESCRIPTION as C, type DetachedDelivery as D, type ElicitationRequest as E, ASK_TOOL_NAME as F, type AgentApprovalRequest as G, type HumanReply as H, type InputProcessor as I, type AgentApprovalSettlement as J, type AgentCatalogEntry as K, type LlmStepEnvelope as L, type ModelMessage as M, type AgentHistoryWindow as N, type OutputProcessor as O, type ProcessorContext as P, type QuotaState as Q, type AskToolInput as R, type StoredMessage as S, type ToolHandler as T, type UsagePurpose as U, DEFAULT_INCREMENTAL_LOOKBACK_CHARS as V, DEFAULT_INTAKE_PREAMBLE as W, DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS as X, DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS as Y, ELICITATION_INPUT_TYPES as Z, type ElicitationInput as _, type ToolDefinition as a, type ElicitationOption as a0, type ElicitationOutcome as a1, type ElicitationQuestion as a2, type ElicitationReply as a3, type ElicitationResult as a4, type HistoryPolicyContext as a5, type HistorySelection as a6, type HistorySummary as a7, type IncrementalGating as a8, type InvokeWithTransientRetryOptions as a9, readElicitationInput as aA, readElicitationQuestions as aB, renderElicitationAnswers as aC, resolveElicitation as aD, resolveToolTransientRetryNumbers as aE, settleElicitation as aF, validateElicitationAnswer as aG, validateElicitationValue as aH, MAX_ASK_QUESTIONS as aa, type MessageRole as ab, OutputRejectedError as ac, type OutputVerdict as ad, ProcessorFailedError as ae, type PromptContext as af, type QuotaView as ag, type ToolCallApprovalStatus as ah, type ToolCatalogEntry as ai, type ToolConfirmation as aj, type ToolPresentation as ak, type ToolPresentationTone as al, type ToolResultField as am, type ToolResultView as an, type ToolStepCtx as ao, type ToolTransientRetryNumbers as ap, type ToolTransientRetryOptions as aq, askInputSchema as ar, askToolDefinition as as, decodeStreamEvent as at, encodeStreamEvent as au, invokeWithTransientRetry as av, isTransientToolError as aw, isTypedQuestion as ax, normalizeElicitationReply as ay, questionOptions 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 ToolCallStatus as k, type ToolSpec as l, type AgentRunInput as m, type ToolKind as n, type ToolCallApproval as o, type HistoryPolicy as p, type ProcessedPrompt as q, type ModelAnswer as r, type PageContext as s, type AgentDefinition as t, type AgentDelegation as u, type PromptBuilder as v, type PromptContributor as w, type ToolTransientRetrySetting as x, type AgentIntake as y, type Decision as z };
|