@dudousxd/nestjs-agent 1.21.0 → 1.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 +7 -0
- package/dist/{chat-queue.service-XG9RQCjU.d.ts → chat-queue.service-CTyX_yNr.d.ts} +33 -2
- package/dist/{chat-queue.service-CGsR40Ct.d.cts → chat-queue.service-Dx9OsjcF.d.cts} +33 -2
- package/dist/durable/index.cjs +334 -237
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +1 -1
- package/dist/durable/index.d.ts +1 -1
- package/dist/durable/index.js +122 -25
- package/dist/durable/index.js.map +1 -1
- package/dist/genui/index.cjs +1 -0
- package/dist/genui/index.cjs.map +1 -1
- package/dist/genui/index.js +1 -0
- package/dist/genui/index.js.map +1 -1
- package/dist/index.cjs +404 -250
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -14
- package/dist/index.d.ts +43 -14
- package/dist/index.js +185 -32
- package/dist/index.js.map +1 -1
- package/dist/sink-redis/index.cjs +7 -2
- package/dist/sink-redis/index.cjs.map +1 -1
- package/dist/sink-redis/index.d.cts +6 -3
- package/dist/sink-redis/index.d.ts +6 -3
- package/dist/sink-redis/index.js +7 -2
- package/dist/sink-redis/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -10,6 +10,13 @@ via signals).
|
|
|
10
10
|
This is the NestJS module — it re-exports the entire `@dudousxd/nestjs-agent-core` surface, so you
|
|
11
11
|
import tools, types, and the module from one place.
|
|
12
12
|
|
|
13
|
+
## Component registries and server rendering
|
|
14
|
+
|
|
15
|
+
Tools support a `present` hook in both functional and decorated class forms. Register custom components per app, share React renderers between web screens and static exports, and generate paginated PNG/PDF tables and charts for your own delivery adapters.
|
|
16
|
+
|
|
17
|
+
See the [component rendering guide](../../docs/component-rendering.md) for complete examples, schemas, text fallbacks, and capture configuration.
|
|
18
|
+
|
|
19
|
+
|
|
13
20
|
## Install
|
|
14
21
|
|
|
15
22
|
```bash
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ResolveToolUiCatalog, ModelProvider, AgentStore, ToolRegistry, RolesPolicy, ApprovalPolicy, QuotaStore, TokenStreamSink, PromptBuilder, PromptContributor, Persona, ToolTransientRetrySetting, Retriever, AgentPricingStore, HistoryPolicy, InputProcessor, OutputProcessor, AgentIntake, SkillsConfig, MemoryConfig, ToolSpec, ToolHandler, QuotaProvider, QuotaQuery, QuotaReport, ActionApprovalMode, BackgroundActorResolver, ModelCatalog, EmptyRoles, ActorResolver, AgentHistoryWindow, SkillProvider, ScopeResolver, MemoryProvider, AgentRegistry, PersonaCatalogEntry, ActionProposal, Actor, AttachmentStagingStore, ChatQueueStore, ChatQueueState, AgentRunner, AgentRunInput, AgentStreamEvent, QueuePauseReason } from '@dudousxd/nestjs-agent-core';
|
|
1
|
+
import { ResolveToolUiCatalog, ModelProvider, AgentStore, ToolRegistry, RolesPolicy, ApprovalPolicy, QuotaStore, TokenStreamSink, PromptBuilder, PromptContributor, Persona, ToolTransientRetrySetting, Retriever, AgentPricingStore, HistoryPolicy, InputProcessor, OutputProcessor, AgentIntake, SkillsConfig, MemoryConfig, ToolSpec, ToolHandler, createFunctionalTool, QuotaProvider, QuotaQuery, QuotaReport, ActionApprovalMode, BackgroundActorResolver, TextActionProposalConfig, ModelCatalog, EmptyRoles, ActorResolver, AgentHistoryWindow, SkillProvider, ScopeResolver, MemoryProvider, AgentRegistry, PersonaCatalogEntry, ActionProposal, Actor, AttachmentStagingStore, ChatQueueStore, ChatQueueState, AgentRunner, AgentRunInput, AgentStreamEvent, QueuePauseReason } from '@dudousxd/nestjs-agent-core';
|
|
2
2
|
import { Catalog } from '@dudousxd/nestjs-agent-core/genui';
|
|
3
3
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
4
4
|
import { Provider, FactoryProvider, Type, CanActivate, ModuleMetadata, InjectionToken, OptionalFactoryDependency } from '@nestjs/common';
|
|
@@ -98,6 +98,8 @@ declare function provideAgentTool(factory: (...deps: never[]) => FunctionalTool,
|
|
|
98
98
|
* factory's result is branded element by element; `AiToolDiscoveryService` registers each.
|
|
99
99
|
*/
|
|
100
100
|
declare function provideAgentTools(factory: (...deps: never[]) => readonly FunctionalTool[] | Promise<readonly FunctionalTool[]>, inject?: FactoryProvider['inject']): Provider;
|
|
101
|
+
/** Author a functional tool with inferred Standard Schema input and domain output. */
|
|
102
|
+
declare const defineTool: typeof createFunctionalTool;
|
|
101
103
|
|
|
102
104
|
/** Ceilings for a {@link LedgerQuotaProvider} window. Either, both, or neither. */
|
|
103
105
|
interface QuotaWindowLimits {
|
|
@@ -244,13 +246,42 @@ interface AgentMemoryOptions {
|
|
|
244
246
|
maxFactChars?: number;
|
|
245
247
|
}
|
|
246
248
|
interface AgentModuleOptions {
|
|
249
|
+
/**
|
|
250
|
+
* How an `action` tool waits for its approval. `'blocking'` (default): the turn parks on the
|
|
251
|
+
* decision and resumes when it lands. `'independent'`: the call is recorded as an action proposal
|
|
252
|
+
* and answered at once with a receipt (`{ proposalId, status: 'pending', executed: false }`), the
|
|
253
|
+
* turn finishes, and a background worker runs the action once it is approved — decided through
|
|
254
|
+
* `POST <base>/threads/:threadId/action-proposals/:proposalId/approve|reject`, the approval port or
|
|
255
|
+
* a text command. Needs `backgroundActorResolver` and a store with the proposal capabilities
|
|
256
|
+
* (both checked at boot). See `docs/independent-approvals.md`.
|
|
257
|
+
*/
|
|
247
258
|
actionApprovalMode?: ActionApprovalMode;
|
|
259
|
+
/**
|
|
260
|
+
* Resolves the CURRENT actor (id, tenant, roles) for a proposal's recorded `actorRef`/`tenantRef`
|
|
261
|
+
* when the worker runs it — there is no request to read an identity from. Return `null` for an
|
|
262
|
+
* actor that no longer exists or no longer belongs to the tenant; the action then fails rather
|
|
263
|
+
* than running. Required under `actionApprovalMode: 'independent'`.
|
|
264
|
+
*/
|
|
248
265
|
backgroundActorResolver?: BackgroundActorResolver;
|
|
266
|
+
/**
|
|
267
|
+
* Tuning for the worker that runs approved proposals under `actionApprovalMode: 'independent'`
|
|
268
|
+
* (started with the module unless `surface: 'http'`). `pollIntervalMs` — how often it looks for
|
|
269
|
+
* queued work, default 1000; `leaseMs` — how long a claim holds before another worker may recover
|
|
270
|
+
* it, default 30000; `maxConcurrency` — proposals claimed per poll, default 1. All positive
|
|
271
|
+
* integers, and `pollIntervalMs` must stay below a third of `leaseMs`.
|
|
272
|
+
*/
|
|
249
273
|
actionProposalWorker?: {
|
|
250
274
|
pollIntervalMs?: number;
|
|
251
275
|
leaseMs?: number;
|
|
252
276
|
maxConcurrency?: number;
|
|
253
277
|
};
|
|
278
|
+
/**
|
|
279
|
+
* The words a chat message must consist of to approve or reject a proposal by text, and what the
|
|
280
|
+
* agent answers. English by default (`yes`/`confirm`/`approve`, `no`/`cancel`/`reject`, …); pass
|
|
281
|
+
* `ptBrActionProposalText` from `@dudousxd/nestjs-agent-core` for Portuguese, or your own — either
|
|
282
|
+
* part replaces the default it names, field by field.
|
|
283
|
+
*/
|
|
284
|
+
actionProposalText?: TextActionProposalConfig;
|
|
254
285
|
/**
|
|
255
286
|
* The LLM provider — `aiSdkModel(openai('gpt-5-mini'))`, or `aiSdkModels({ … })` for a model
|
|
256
287
|
* picker (its catalog is used when `models` is omitted). The only required option.
|
|
@@ -729,4 +760,4 @@ declare class ChatQueueService {
|
|
|
729
760
|
private freshAttachments;
|
|
730
761
|
}
|
|
731
762
|
|
|
732
|
-
export { AgentDepsFactory as A, ChatQueueService as C, type FunctionalTool as F, LedgerQuotaProvider as L, type QueuePlan as Q, type AgentSurface as a, type AgentModuleOptions as b, type AgentModuleAsyncOptions as c, type AgentProtocolAdapter as d, type AgentSkillsOptions as e, AGENT_TOOL_BRAND as f, type AgentAttachmentsOptions as g, type AgentDeps as h, type AgentMemoryOptions as i, type QueueSettleOutcome as j, type QueuedTurn as k, type QueuedTurnStarter as l, type QuotaLimits as m, type QuotaWindowLimits as n,
|
|
763
|
+
export { AgentDepsFactory as A, ChatQueueService as C, type FunctionalTool as F, LedgerQuotaProvider as L, type QueuePlan as Q, type AgentSurface as a, type AgentModuleOptions as b, type AgentModuleAsyncOptions as c, type AgentProtocolAdapter as d, type AgentSkillsOptions as e, AGENT_TOOL_BRAND as f, type AgentAttachmentsOptions as g, type AgentDeps as h, type AgentMemoryOptions as i, type QueueSettleOutcome as j, type QueuedTurn as k, type QueuedTurnStarter as l, type QuotaLimits as m, type QuotaWindowLimits as n, defineTool as o, delegateToolName as p, provideAgentTool as q, provideAgentTools as r, utcDay as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ResolveToolUiCatalog, ModelProvider, AgentStore, ToolRegistry, RolesPolicy, ApprovalPolicy, QuotaStore, TokenStreamSink, PromptBuilder, PromptContributor, Persona, ToolTransientRetrySetting, Retriever, AgentPricingStore, HistoryPolicy, InputProcessor, OutputProcessor, AgentIntake, SkillsConfig, MemoryConfig, ToolSpec, ToolHandler, QuotaProvider, QuotaQuery, QuotaReport, ActionApprovalMode, BackgroundActorResolver, ModelCatalog, EmptyRoles, ActorResolver, AgentHistoryWindow, SkillProvider, ScopeResolver, MemoryProvider, AgentRegistry, PersonaCatalogEntry, ActionProposal, Actor, AttachmentStagingStore, ChatQueueStore, ChatQueueState, AgentRunner, AgentRunInput, AgentStreamEvent, QueuePauseReason } from '@dudousxd/nestjs-agent-core';
|
|
1
|
+
import { ResolveToolUiCatalog, ModelProvider, AgentStore, ToolRegistry, RolesPolicy, ApprovalPolicy, QuotaStore, TokenStreamSink, PromptBuilder, PromptContributor, Persona, ToolTransientRetrySetting, Retriever, AgentPricingStore, HistoryPolicy, InputProcessor, OutputProcessor, AgentIntake, SkillsConfig, MemoryConfig, ToolSpec, ToolHandler, createFunctionalTool, QuotaProvider, QuotaQuery, QuotaReport, ActionApprovalMode, BackgroundActorResolver, TextActionProposalConfig, ModelCatalog, EmptyRoles, ActorResolver, AgentHistoryWindow, SkillProvider, ScopeResolver, MemoryProvider, AgentRegistry, PersonaCatalogEntry, ActionProposal, Actor, AttachmentStagingStore, ChatQueueStore, ChatQueueState, AgentRunner, AgentRunInput, AgentStreamEvent, QueuePauseReason } from '@dudousxd/nestjs-agent-core';
|
|
2
2
|
import { Catalog } from '@dudousxd/nestjs-agent-core/genui';
|
|
3
3
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
4
4
|
import { Provider, FactoryProvider, Type, CanActivate, ModuleMetadata, InjectionToken, OptionalFactoryDependency } from '@nestjs/common';
|
|
@@ -98,6 +98,8 @@ declare function provideAgentTool(factory: (...deps: never[]) => FunctionalTool,
|
|
|
98
98
|
* factory's result is branded element by element; `AiToolDiscoveryService` registers each.
|
|
99
99
|
*/
|
|
100
100
|
declare function provideAgentTools(factory: (...deps: never[]) => readonly FunctionalTool[] | Promise<readonly FunctionalTool[]>, inject?: FactoryProvider['inject']): Provider;
|
|
101
|
+
/** Author a functional tool with inferred Standard Schema input and domain output. */
|
|
102
|
+
declare const defineTool: typeof createFunctionalTool;
|
|
101
103
|
|
|
102
104
|
/** Ceilings for a {@link LedgerQuotaProvider} window. Either, both, or neither. */
|
|
103
105
|
interface QuotaWindowLimits {
|
|
@@ -244,13 +246,42 @@ interface AgentMemoryOptions {
|
|
|
244
246
|
maxFactChars?: number;
|
|
245
247
|
}
|
|
246
248
|
interface AgentModuleOptions {
|
|
249
|
+
/**
|
|
250
|
+
* How an `action` tool waits for its approval. `'blocking'` (default): the turn parks on the
|
|
251
|
+
* decision and resumes when it lands. `'independent'`: the call is recorded as an action proposal
|
|
252
|
+
* and answered at once with a receipt (`{ proposalId, status: 'pending', executed: false }`), the
|
|
253
|
+
* turn finishes, and a background worker runs the action once it is approved — decided through
|
|
254
|
+
* `POST <base>/threads/:threadId/action-proposals/:proposalId/approve|reject`, the approval port or
|
|
255
|
+
* a text command. Needs `backgroundActorResolver` and a store with the proposal capabilities
|
|
256
|
+
* (both checked at boot). See `docs/independent-approvals.md`.
|
|
257
|
+
*/
|
|
247
258
|
actionApprovalMode?: ActionApprovalMode;
|
|
259
|
+
/**
|
|
260
|
+
* Resolves the CURRENT actor (id, tenant, roles) for a proposal's recorded `actorRef`/`tenantRef`
|
|
261
|
+
* when the worker runs it — there is no request to read an identity from. Return `null` for an
|
|
262
|
+
* actor that no longer exists or no longer belongs to the tenant; the action then fails rather
|
|
263
|
+
* than running. Required under `actionApprovalMode: 'independent'`.
|
|
264
|
+
*/
|
|
248
265
|
backgroundActorResolver?: BackgroundActorResolver;
|
|
266
|
+
/**
|
|
267
|
+
* Tuning for the worker that runs approved proposals under `actionApprovalMode: 'independent'`
|
|
268
|
+
* (started with the module unless `surface: 'http'`). `pollIntervalMs` — how often it looks for
|
|
269
|
+
* queued work, default 1000; `leaseMs` — how long a claim holds before another worker may recover
|
|
270
|
+
* it, default 30000; `maxConcurrency` — proposals claimed per poll, default 1. All positive
|
|
271
|
+
* integers, and `pollIntervalMs` must stay below a third of `leaseMs`.
|
|
272
|
+
*/
|
|
249
273
|
actionProposalWorker?: {
|
|
250
274
|
pollIntervalMs?: number;
|
|
251
275
|
leaseMs?: number;
|
|
252
276
|
maxConcurrency?: number;
|
|
253
277
|
};
|
|
278
|
+
/**
|
|
279
|
+
* The words a chat message must consist of to approve or reject a proposal by text, and what the
|
|
280
|
+
* agent answers. English by default (`yes`/`confirm`/`approve`, `no`/`cancel`/`reject`, …); pass
|
|
281
|
+
* `ptBrActionProposalText` from `@dudousxd/nestjs-agent-core` for Portuguese, or your own — either
|
|
282
|
+
* part replaces the default it names, field by field.
|
|
283
|
+
*/
|
|
284
|
+
actionProposalText?: TextActionProposalConfig;
|
|
254
285
|
/**
|
|
255
286
|
* The LLM provider — `aiSdkModel(openai('gpt-5-mini'))`, or `aiSdkModels({ … })` for a model
|
|
256
287
|
* picker (its catalog is used when `models` is omitted). The only required option.
|
|
@@ -729,4 +760,4 @@ declare class ChatQueueService {
|
|
|
729
760
|
private freshAttachments;
|
|
730
761
|
}
|
|
731
762
|
|
|
732
|
-
export { AgentDepsFactory as A, ChatQueueService as C, type FunctionalTool as F, LedgerQuotaProvider as L, type QueuePlan as Q, type AgentSurface as a, type AgentModuleOptions as b, type AgentModuleAsyncOptions as c, type AgentProtocolAdapter as d, type AgentSkillsOptions as e, AGENT_TOOL_BRAND as f, type AgentAttachmentsOptions as g, type AgentDeps as h, type AgentMemoryOptions as i, type QueueSettleOutcome as j, type QueuedTurn as k, type QueuedTurnStarter as l, type QuotaLimits as m, type QuotaWindowLimits as n,
|
|
763
|
+
export { AgentDepsFactory as A, ChatQueueService as C, type FunctionalTool as F, LedgerQuotaProvider as L, type QueuePlan as Q, type AgentSurface as a, type AgentModuleOptions as b, type AgentModuleAsyncOptions as c, type AgentProtocolAdapter as d, type AgentSkillsOptions as e, AGENT_TOOL_BRAND as f, type AgentAttachmentsOptions as g, type AgentDeps as h, type AgentMemoryOptions as i, type QueueSettleOutcome as j, type QueuedTurn as k, type QueuedTurnStarter as l, type QuotaLimits as m, type QuotaWindowLimits as n, defineTool as o, delegateToolName as p, provideAgentTool as q, provideAgentTools as r, utcDay as u };
|