@dudousxd/nestjs-agent-core 0.18.0 → 0.19.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 +1 -0
- package/dist/guardrails/index.d.cts +1 -1
- package/dist/guardrails/index.d.ts +1 -1
- package/dist/index.cjs +14 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/dist/{tool-CHIw-aTx.d.cts → tool-Q2rmGeaG.d.cts} +94 -1
- package/dist/{tool-CHIw-aTx.d.ts → tool-Q2rmGeaG.d.ts} +94 -1
- package/package.json +1 -1
|
@@ -454,6 +454,94 @@ declare function encodeStreamEvent(event: AgentStreamEvent): Uint8Array;
|
|
|
454
454
|
*/
|
|
455
455
|
declare function decodeStreamEvent(line: string): AgentStreamEvent | null;
|
|
456
456
|
|
|
457
|
+
/**
|
|
458
|
+
* How a person-facing surface talks about a tool WITHOUT ever naming it. Declared on the server,
|
|
459
|
+
* beside the tool's input schema, because whoever changes the input is the one who has to re-word
|
|
460
|
+
* the sentence that mentions it — and a client that shipped its own name-to-sentence map would go
|
|
461
|
+
* stale the moment a tool was renamed. A tool name is an identifier, never copy.
|
|
462
|
+
*
|
|
463
|
+
* `running` / `done` (and `confirm.title`, `confirm.detail`, `result.text`) are templates:
|
|
464
|
+
* `{dotted.path}` placeholders are filled from the call's INPUT (or, for `result`, its OUTPUT), so one
|
|
465
|
+
* declaration covers every call the tool will ever receive and replays identically from history.
|
|
466
|
+
* A placeholder with nothing behind it collapses along with the space before it.
|
|
467
|
+
*/
|
|
468
|
+
interface ToolPresentation {
|
|
469
|
+
/** Noun phrase, for counts and headings: "Database query", "Knowledge base". */
|
|
470
|
+
label: string;
|
|
471
|
+
/** Present progressive, while the call is in flight: "Reading {bucket}". */
|
|
472
|
+
running: string;
|
|
473
|
+
/** Settled, once the output is in: "Read {bucket}". */
|
|
474
|
+
done: string;
|
|
475
|
+
/** A key into the client's own glyph map (`database`, `search`, …). Unknown keys fall back to a generic glyph there. */
|
|
476
|
+
icon?: string;
|
|
477
|
+
/** One line naming what the tool reaches, for when the activity line is opened. */
|
|
478
|
+
detail?: string;
|
|
479
|
+
/** `destructive` earns the warning treatment on an approval prompt. */
|
|
480
|
+
tone?: ToolPresentationTone;
|
|
481
|
+
/** What a person is being asked to allow when an `action` call parks for approval. */
|
|
482
|
+
confirm?: ToolConfirmation;
|
|
483
|
+
/** How the call's OUTPUT reads as content. */
|
|
484
|
+
result?: ToolResultView;
|
|
485
|
+
}
|
|
486
|
+
type ToolPresentationTone = 'neutral' | 'destructive';
|
|
487
|
+
interface ToolConfirmation {
|
|
488
|
+
/** "Delete {count} files?" */
|
|
489
|
+
title: string;
|
|
490
|
+
/** The button: "Delete". */
|
|
491
|
+
verb: string;
|
|
492
|
+
/** A sentence under the title, when the title alone does not say what changes. */
|
|
493
|
+
detail?: string;
|
|
494
|
+
}
|
|
495
|
+
/** A value read out of a tool's output by dotted path, with the words to put next to it. */
|
|
496
|
+
interface ToolResultField {
|
|
497
|
+
path: string;
|
|
498
|
+
label: string;
|
|
499
|
+
unit?: string;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* How a tool's output reads as content. Every variant names dotted paths into the output rather
|
|
503
|
+
* than shapes, so a renderer never has to recognise which tool it is drawing: it receives
|
|
504
|
+
* `{ view, output }` and draws it.
|
|
505
|
+
*/
|
|
506
|
+
type ToolResultView =
|
|
507
|
+
/** A row of labelled readings — one result, several facets. */
|
|
508
|
+
{
|
|
509
|
+
kind: 'metrics';
|
|
510
|
+
fields: ToolResultField[];
|
|
511
|
+
}
|
|
512
|
+
/** `rows` is a path to an array; each column's `path` is read WITHIN a row. */
|
|
513
|
+
| {
|
|
514
|
+
kind: 'table';
|
|
515
|
+
columns: ToolResultField[];
|
|
516
|
+
rows: string;
|
|
517
|
+
empty?: string;
|
|
518
|
+
}
|
|
519
|
+
/** `lines` is a path to an array of strings, drawn as a log tail. */
|
|
520
|
+
| {
|
|
521
|
+
kind: 'log';
|
|
522
|
+
lines: string;
|
|
523
|
+
}
|
|
524
|
+
/** One sentence, templated over the output. */
|
|
525
|
+
| {
|
|
526
|
+
kind: 'note';
|
|
527
|
+
text: string;
|
|
528
|
+
}
|
|
529
|
+
/** The output is drawn somewhere else on the screen already (a pushed component, a side panel). */
|
|
530
|
+
| {
|
|
531
|
+
kind: 'elsewhere';
|
|
532
|
+
};
|
|
533
|
+
/**
|
|
534
|
+
* One tool as `GET <base>/tools` reports it: the tools THIS actor may be offered by the chosen agent,
|
|
535
|
+
* with how each is spoken about. `presentation` is absent for a tool that declared none — a client
|
|
536
|
+
* then narrates it generically rather than falling back to its name.
|
|
537
|
+
*/
|
|
538
|
+
interface ToolCatalogEntry {
|
|
539
|
+
/** The wire name tool parts carry (`tool-<name>`) — the key a client looks a call up by. */
|
|
540
|
+
name: string;
|
|
541
|
+
kind: ToolKind;
|
|
542
|
+
presentation?: ToolPresentation;
|
|
543
|
+
}
|
|
544
|
+
|
|
457
545
|
/**
|
|
458
546
|
* Transient tool-error classification + the retry loop that wraps a tool's own invocation. A
|
|
459
547
|
* classified-transient error (a DB deadlock, a lock-wait timeout, a serialization failure) means
|
|
@@ -573,6 +661,11 @@ interface ToolSpec {
|
|
|
573
661
|
name: string;
|
|
574
662
|
kind: ToolKind;
|
|
575
663
|
description: string;
|
|
664
|
+
/**
|
|
665
|
+
* How a person-facing surface talks about this tool (see {@link ToolPresentation}). Never shown
|
|
666
|
+
* to the model; served to clients by `GET <base>/tools`.
|
|
667
|
+
*/
|
|
668
|
+
presentation?: ToolPresentation;
|
|
576
669
|
/**
|
|
577
670
|
* Input schema as a [Standard Schema](https://standardschema.dev) — validation-agnostic, so
|
|
578
671
|
* Zod, Valibot, or ArkType all work. The loop validates input via `~standard.validate` before
|
|
@@ -1212,4 +1305,4 @@ interface ToolHandler<I = unknown> {
|
|
|
1212
1305
|
canUse?(actor: Actor): boolean | Promise<boolean>;
|
|
1213
1306
|
}
|
|
1214
1307
|
|
|
1215
|
-
export { type HistoryPolicyContext as $, type Actor as A, type AgentApprovalRequest as B, type AgentCatalogEntry as C, type DetachedDelivery as D, type ElicitationRequest as E, type AgentHistoryWindow as F, type AgentStreamEvent as G, type HumanReply as H, type InputProcessor as I, type AskToolInput as J, DEFAULT_INCREMENTAL_LOOKBACK_CHARS as K, type LlmStepEnvelope as L, type ModelMessage as M, DEFAULT_INTAKE_PREAMBLE as N, type OutputProcessor as O, type ProcessorContext as P, type QuotaState as Q, DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS as R, type StoredMessage as S, type ToolHandler as T, type UsagePurpose as U, DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS as V, type ElicitationOption as W, type ElicitationOutcome as X, type ElicitationQuestion as Y, type ElicitationReply as Z, type ElicitationResult as _, type ToolDefinition as a, type HistorySelection as a0, type HistorySummary as a1, type IncrementalGating as a2, type InvokeWithTransientRetryOptions as a3, MAX_ASK_QUESTIONS as a4, type MessageRole as a5, OutputRejectedError as a6, type OutputVerdict as a7, ProcessorFailedError as a8, type PromptContext as a9, type QuotaView as aa, type
|
|
1308
|
+
export { type HistoryPolicyContext as $, type Actor as A, type AgentApprovalRequest as B, type AgentCatalogEntry as C, type DetachedDelivery as D, type ElicitationRequest as E, type AgentHistoryWindow as F, type AgentStreamEvent as G, type HumanReply as H, type InputProcessor as I, type AskToolInput as J, DEFAULT_INCREMENTAL_LOOKBACK_CHARS as K, type LlmStepEnvelope as L, type ModelMessage as M, DEFAULT_INTAKE_PREAMBLE as N, type OutputProcessor as O, type ProcessorContext as P, type QuotaState as Q, DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS as R, type StoredMessage as S, type ToolHandler as T, type UsagePurpose as U, DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS as V, type ElicitationOption as W, type ElicitationOutcome as X, type ElicitationQuestion as Y, type ElicitationReply as Z, type ElicitationResult as _, type ToolDefinition as a, type HistorySelection as a0, type HistorySummary as a1, type IncrementalGating as a2, type InvokeWithTransientRetryOptions as a3, MAX_ASK_QUESTIONS as a4, type MessageRole as a5, OutputRejectedError as a6, type OutputVerdict as a7, ProcessorFailedError as a8, type PromptContext as a9, type QuotaView as aa, type ToolCatalogEntry as ab, type ToolConfirmation as ac, type ToolKind as ad, type ToolPresentation as ae, type ToolPresentationTone as af, type ToolResultField as ag, type ToolResultView as ah, type ToolStepCtx as ai, type ToolTransientRetryNumbers as aj, type ToolTransientRetryOptions as ak, askInputSchema as al, askToolDefinition as am, decodeStreamEvent as an, encodeStreamEvent as ao, invokeWithTransientRetry as ap, isTransientToolError as aq, normalizeElicitationReply as ar, renderElicitationAnswers as as, resolveElicitation as at, resolveToolTransientRetryNumbers as au, settleElicitation as av, type ToolCallRequest as b, type MessageUsage as c, type AgentUiComponent as d, type ThreadSummary as e, type ThreadDetail as f, type ToolResult as g, type MessageAttachment as h, type ToolCallStatus as i, type ToolSpec as j, type AgentRunInput as k, type HistoryPolicy as l, type ProcessedPrompt as m, type ModelAnswer as n, type PageContext as o, type AgentDefinition as p, type AgentDelegation as q, type AiToolCtx as r, type PromptBuilder as s, type PromptContributor as t, type ToolTransientRetrySetting as u, type AgentIntake as v, type Decision as w, type ToolStepEnvelope as x, ASK_TOOL_DESCRIPTION as y, ASK_TOOL_NAME as z };
|
|
@@ -454,6 +454,94 @@ declare function encodeStreamEvent(event: AgentStreamEvent): Uint8Array;
|
|
|
454
454
|
*/
|
|
455
455
|
declare function decodeStreamEvent(line: string): AgentStreamEvent | null;
|
|
456
456
|
|
|
457
|
+
/**
|
|
458
|
+
* How a person-facing surface talks about a tool WITHOUT ever naming it. Declared on the server,
|
|
459
|
+
* beside the tool's input schema, because whoever changes the input is the one who has to re-word
|
|
460
|
+
* the sentence that mentions it — and a client that shipped its own name-to-sentence map would go
|
|
461
|
+
* stale the moment a tool was renamed. A tool name is an identifier, never copy.
|
|
462
|
+
*
|
|
463
|
+
* `running` / `done` (and `confirm.title`, `confirm.detail`, `result.text`) are templates:
|
|
464
|
+
* `{dotted.path}` placeholders are filled from the call's INPUT (or, for `result`, its OUTPUT), so one
|
|
465
|
+
* declaration covers every call the tool will ever receive and replays identically from history.
|
|
466
|
+
* A placeholder with nothing behind it collapses along with the space before it.
|
|
467
|
+
*/
|
|
468
|
+
interface ToolPresentation {
|
|
469
|
+
/** Noun phrase, for counts and headings: "Database query", "Knowledge base". */
|
|
470
|
+
label: string;
|
|
471
|
+
/** Present progressive, while the call is in flight: "Reading {bucket}". */
|
|
472
|
+
running: string;
|
|
473
|
+
/** Settled, once the output is in: "Read {bucket}". */
|
|
474
|
+
done: string;
|
|
475
|
+
/** A key into the client's own glyph map (`database`, `search`, …). Unknown keys fall back to a generic glyph there. */
|
|
476
|
+
icon?: string;
|
|
477
|
+
/** One line naming what the tool reaches, for when the activity line is opened. */
|
|
478
|
+
detail?: string;
|
|
479
|
+
/** `destructive` earns the warning treatment on an approval prompt. */
|
|
480
|
+
tone?: ToolPresentationTone;
|
|
481
|
+
/** What a person is being asked to allow when an `action` call parks for approval. */
|
|
482
|
+
confirm?: ToolConfirmation;
|
|
483
|
+
/** How the call's OUTPUT reads as content. */
|
|
484
|
+
result?: ToolResultView;
|
|
485
|
+
}
|
|
486
|
+
type ToolPresentationTone = 'neutral' | 'destructive';
|
|
487
|
+
interface ToolConfirmation {
|
|
488
|
+
/** "Delete {count} files?" */
|
|
489
|
+
title: string;
|
|
490
|
+
/** The button: "Delete". */
|
|
491
|
+
verb: string;
|
|
492
|
+
/** A sentence under the title, when the title alone does not say what changes. */
|
|
493
|
+
detail?: string;
|
|
494
|
+
}
|
|
495
|
+
/** A value read out of a tool's output by dotted path, with the words to put next to it. */
|
|
496
|
+
interface ToolResultField {
|
|
497
|
+
path: string;
|
|
498
|
+
label: string;
|
|
499
|
+
unit?: string;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* How a tool's output reads as content. Every variant names dotted paths into the output rather
|
|
503
|
+
* than shapes, so a renderer never has to recognise which tool it is drawing: it receives
|
|
504
|
+
* `{ view, output }` and draws it.
|
|
505
|
+
*/
|
|
506
|
+
type ToolResultView =
|
|
507
|
+
/** A row of labelled readings — one result, several facets. */
|
|
508
|
+
{
|
|
509
|
+
kind: 'metrics';
|
|
510
|
+
fields: ToolResultField[];
|
|
511
|
+
}
|
|
512
|
+
/** `rows` is a path to an array; each column's `path` is read WITHIN a row. */
|
|
513
|
+
| {
|
|
514
|
+
kind: 'table';
|
|
515
|
+
columns: ToolResultField[];
|
|
516
|
+
rows: string;
|
|
517
|
+
empty?: string;
|
|
518
|
+
}
|
|
519
|
+
/** `lines` is a path to an array of strings, drawn as a log tail. */
|
|
520
|
+
| {
|
|
521
|
+
kind: 'log';
|
|
522
|
+
lines: string;
|
|
523
|
+
}
|
|
524
|
+
/** One sentence, templated over the output. */
|
|
525
|
+
| {
|
|
526
|
+
kind: 'note';
|
|
527
|
+
text: string;
|
|
528
|
+
}
|
|
529
|
+
/** The output is drawn somewhere else on the screen already (a pushed component, a side panel). */
|
|
530
|
+
| {
|
|
531
|
+
kind: 'elsewhere';
|
|
532
|
+
};
|
|
533
|
+
/**
|
|
534
|
+
* One tool as `GET <base>/tools` reports it: the tools THIS actor may be offered by the chosen agent,
|
|
535
|
+
* with how each is spoken about. `presentation` is absent for a tool that declared none — a client
|
|
536
|
+
* then narrates it generically rather than falling back to its name.
|
|
537
|
+
*/
|
|
538
|
+
interface ToolCatalogEntry {
|
|
539
|
+
/** The wire name tool parts carry (`tool-<name>`) — the key a client looks a call up by. */
|
|
540
|
+
name: string;
|
|
541
|
+
kind: ToolKind;
|
|
542
|
+
presentation?: ToolPresentation;
|
|
543
|
+
}
|
|
544
|
+
|
|
457
545
|
/**
|
|
458
546
|
* Transient tool-error classification + the retry loop that wraps a tool's own invocation. A
|
|
459
547
|
* classified-transient error (a DB deadlock, a lock-wait timeout, a serialization failure) means
|
|
@@ -573,6 +661,11 @@ interface ToolSpec {
|
|
|
573
661
|
name: string;
|
|
574
662
|
kind: ToolKind;
|
|
575
663
|
description: string;
|
|
664
|
+
/**
|
|
665
|
+
* How a person-facing surface talks about this tool (see {@link ToolPresentation}). Never shown
|
|
666
|
+
* to the model; served to clients by `GET <base>/tools`.
|
|
667
|
+
*/
|
|
668
|
+
presentation?: ToolPresentation;
|
|
576
669
|
/**
|
|
577
670
|
* Input schema as a [Standard Schema](https://standardschema.dev) — validation-agnostic, so
|
|
578
671
|
* Zod, Valibot, or ArkType all work. The loop validates input via `~standard.validate` before
|
|
@@ -1212,4 +1305,4 @@ interface ToolHandler<I = unknown> {
|
|
|
1212
1305
|
canUse?(actor: Actor): boolean | Promise<boolean>;
|
|
1213
1306
|
}
|
|
1214
1307
|
|
|
1215
|
-
export { type HistoryPolicyContext as $, type Actor as A, type AgentApprovalRequest as B, type AgentCatalogEntry as C, type DetachedDelivery as D, type ElicitationRequest as E, type AgentHistoryWindow as F, type AgentStreamEvent as G, type HumanReply as H, type InputProcessor as I, type AskToolInput as J, DEFAULT_INCREMENTAL_LOOKBACK_CHARS as K, type LlmStepEnvelope as L, type ModelMessage as M, DEFAULT_INTAKE_PREAMBLE as N, type OutputProcessor as O, type ProcessorContext as P, type QuotaState as Q, DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS as R, type StoredMessage as S, type ToolHandler as T, type UsagePurpose as U, DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS as V, type ElicitationOption as W, type ElicitationOutcome as X, type ElicitationQuestion as Y, type ElicitationReply as Z, type ElicitationResult as _, type ToolDefinition as a, type HistorySelection as a0, type HistorySummary as a1, type IncrementalGating as a2, type InvokeWithTransientRetryOptions as a3, MAX_ASK_QUESTIONS as a4, type MessageRole as a5, OutputRejectedError as a6, type OutputVerdict as a7, ProcessorFailedError as a8, type PromptContext as a9, type QuotaView as aa, type
|
|
1308
|
+
export { type HistoryPolicyContext as $, type Actor as A, type AgentApprovalRequest as B, type AgentCatalogEntry as C, type DetachedDelivery as D, type ElicitationRequest as E, type AgentHistoryWindow as F, type AgentStreamEvent as G, type HumanReply as H, type InputProcessor as I, type AskToolInput as J, DEFAULT_INCREMENTAL_LOOKBACK_CHARS as K, type LlmStepEnvelope as L, type ModelMessage as M, DEFAULT_INTAKE_PREAMBLE as N, type OutputProcessor as O, type ProcessorContext as P, type QuotaState as Q, DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS as R, type StoredMessage as S, type ToolHandler as T, type UsagePurpose as U, DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS as V, type ElicitationOption as W, type ElicitationOutcome as X, type ElicitationQuestion as Y, type ElicitationReply as Z, type ElicitationResult as _, type ToolDefinition as a, type HistorySelection as a0, type HistorySummary as a1, type IncrementalGating as a2, type InvokeWithTransientRetryOptions as a3, MAX_ASK_QUESTIONS as a4, type MessageRole as a5, OutputRejectedError as a6, type OutputVerdict as a7, ProcessorFailedError as a8, type PromptContext as a9, type QuotaView as aa, type ToolCatalogEntry as ab, type ToolConfirmation as ac, type ToolKind as ad, type ToolPresentation as ae, type ToolPresentationTone as af, type ToolResultField as ag, type ToolResultView as ah, type ToolStepCtx as ai, type ToolTransientRetryNumbers as aj, type ToolTransientRetryOptions as ak, askInputSchema as al, askToolDefinition as am, decodeStreamEvent as an, encodeStreamEvent as ao, invokeWithTransientRetry as ap, isTransientToolError as aq, normalizeElicitationReply as ar, renderElicitationAnswers as as, resolveElicitation as at, resolveToolTransientRetryNumbers as au, settleElicitation as av, type ToolCallRequest as b, type MessageUsage as c, type AgentUiComponent as d, type ThreadSummary as e, type ThreadDetail as f, type ToolResult as g, type MessageAttachment as h, type ToolCallStatus as i, type ToolSpec as j, type AgentRunInput as k, type HistoryPolicy as l, type ProcessedPrompt as m, type ModelAnswer as n, type PageContext as o, type AgentDefinition as p, type AgentDelegation as q, type AiToolCtx as r, type PromptBuilder as s, type PromptContributor as t, type ToolTransientRetrySetting as u, type AgentIntake as v, type Decision as w, type ToolStepEnvelope as x, ASK_TOOL_DESCRIPTION as y, ASK_TOOL_NAME as z };
|