@dudousxd/nestjs-agent 1.21.0 → 1.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/dist/index.d.cts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { DynamicModule, Type, OnApplicationBootstrap, OnModuleInit, ConflictException, OnModuleDestroy } from '@nestjs/common';
2
- import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, C as ChatQueueService, d as AgentProtocolAdapter, e as AgentSkillsOptions } from './chat-queue.service-CGsR40Ct.cjs';
3
- export { f as AGENT_TOOL_BRAND, g as AgentAttachmentsOptions, h as AgentDeps, i as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QueuePlan, j as QueueSettleOutcome, k as QueuedTurn, l as QueuedTurnStarter, m as QuotaLimits, n as QuotaWindowLimits, o as delegateToolName, p as provideAgentTool, q as provideAgentTools, u as utcDay } from './chat-queue.service-CGsR40Ct.cjs';
2
+ import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, C as ChatQueueService, d as AgentProtocolAdapter, e as AgentSkillsOptions } from './chat-queue.service-D1z3WjFI.cjs';
3
+ export { f as AGENT_TOOL_BRAND, g as AgentAttachmentsOptions, h as AgentDeps, i as AgentEngine, j as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QueuePlan, k as QueueSettleOutcome, l as QueuedTurn, m as QueuedTurnStarter, n as QuotaLimits, o as QuotaWindowLimits, p as defineTool, q as delegateToolName, r as provideAgentTool, s as provideAgentTools, u as utcDay } from './chat-queue.service-D1z3WjFI.cjs';
4
4
  import * as _dudousxd_nestjs_agent_core from '@dudousxd/nestjs-agent-core';
5
- import { AgentStore, Actor, ListActionProposals, ActionProposalMutationResult, AgentRunner, AttachmentStagingStore, ModelCatalog, QuotaProvider, QuotaReport, ModelCatalogView, AttachmentRef, PageContext, ChatQueueState, HumanReply, ThreadSummary, ThreadDetail, UpdateThreadInput, MessageFeedbackValue, MessageFeedback, StagedAttachment, ActorResolver, AgentApprovalPort, MessageAttachment, AgentAttachmentConfig, AgentClientConfig, ToolSpec, ToolPresentation, AgentHistoryWindow, AgentIntake, Persona, SkillContext, ToolRegistry, AgentRegistry, PromptContributor, SkillsConfig, SkillCatalogEntry, ToolCatalogEntry, MemoryConfig, MemoryDigestEntry, SkillProvider, AgentRunInput, AgentRunStartOptions, TokenStreamSink, SinkWriter } from '@dudousxd/nestjs-agent-core';
5
+ import { AgentStore, Actor, ListActionProposals, ActionProposalMutationView, AgentRunner, AttachmentStagingStore, ModelCatalog, QuotaProvider, QuotaReport, ModelCatalogView, AgentHostContext, AttachmentRef, PageContext, ChatQueueState, HumanReply, ThreadSummary, ThreadDetail, UpdateThreadInput, MessageFeedbackValue, MessageFeedback, StagedAttachment, ActorResolver, AgentApprovalPort, MessageAttachment, AgentAttachmentConfig, AgentClientConfig, ToolSpec, ToolPresentation, AgentHistoryWindow, AgentIntake, Persona, SkillContext, ToolRegistry, AgentRegistry, PromptContributor, SkillsConfig, SkillCatalogEntry, ToolCatalogEntry, MemoryConfig, MemoryDigestEntry, SkillProvider, AgentRunInput, AgentRunStartOptions, TokenStreamSink, SinkWriter } from '@dudousxd/nestjs-agent-core';
6
6
  export * from '@dudousxd/nestjs-agent-core';
7
+ export { FunctionalToolDefinition } from '@dudousxd/nestjs-agent-core';
7
8
  import { Request, Response } from 'express';
8
9
  import { UiCapabilities } from '@dudousxd/nestjs-agent-core/genui';
9
10
  import { StandardSchemaV1 } from '@standard-schema/spec';
@@ -18,7 +19,10 @@ declare class AgentModule {
18
19
  declare class ActionProposalService {
19
20
  private readonly store;
20
21
  private readonly options;
21
- constructor(store: AgentStore, options: Pick<AgentModuleOptions, 'approvalPolicy'>);
22
+ constructor(store: AgentStore, options: Pick<AgentModuleOptions, 'approvalPolicy' | 'actionProposalText'>);
23
+ /** The words a text decision is made of, and what the agent answers — English unless configured. */
24
+ private readonly vocabulary;
25
+ private readonly replies;
22
26
  private capability;
23
27
  private scope;
24
28
  private mayDecide;
@@ -27,20 +31,20 @@ declare class ActionProposalService {
27
31
  createdAt: number;
28
32
  id: string;
29
33
  };
30
- items: _dudousxd_nestjs_agent_core.ActionProposal[];
34
+ items: _dudousxd_nestjs_agent_core.ActionProposalView[];
31
35
  }>;
32
- list(threadId: string, actor: Actor): Promise<_dudousxd_nestjs_agent_core.ActionProposal[]>;
36
+ list(threadId: string, actor: Actor): Promise<_dudousxd_nestjs_agent_core.ActionProposalView[]>;
33
37
  decide(threadId: string, proposalId: string, actor: Actor, command: {
34
38
  decision: 'approved' | 'rejected';
35
39
  remember?: boolean;
36
40
  reason?: string;
37
41
  via?: string;
38
- }): Promise<ActionProposalMutationResult>;
42
+ }): Promise<ActionProposalMutationView>;
39
43
  handleTextDecision(threadId: string, actor: Actor, text: string): Promise<{
40
44
  status: "unmatched";
41
45
  } | {
42
46
  threadId: string;
43
- proposalDecision: ActionProposalMutationResult;
47
+ proposalDecision: ActionProposalMutationView;
44
48
  text: string;
45
49
  } | {
46
50
  threadId: string;
@@ -51,6 +55,8 @@ declare class ActionProposalService {
51
55
  text: string;
52
56
  }>;
53
57
  private textReceipt;
58
+ /** The configured reply to a decision the store answered with `result`. */
59
+ reply(result: ActionProposalMutationView, decision: 'approved' | 'rejected'): string;
54
60
  }
55
61
 
56
62
  /**
@@ -90,6 +96,14 @@ interface ChatParams {
90
96
  uiCapabilities?: UiCapabilities;
91
97
  actor: Actor;
92
98
  message: string;
99
+ /** The host's own facts about this send — see `AgentRunInput.hostContext`. */
100
+ hostContext?: AgentHostContext;
101
+ /**
102
+ * The HOST already decided this actor may write this thread — a chat-app thread several people
103
+ * share, where anyone in it may continue the conversation. Skips the thread-ownership check of a
104
+ * send; never set it from a request's own claim.
105
+ */
106
+ authorized?: boolean;
93
107
  threadId?: string;
94
108
  agentName?: string;
95
109
  /**
@@ -152,11 +166,25 @@ declare class AgentService {
152
166
  private readonly queue?;
153
167
  private readonly proposals?;
154
168
  constructor(runner: AgentRunner, store: AgentStore, deps: AgentDepsFactory, staging?: AttachmentStagingStore | undefined, models?: ModelCatalog | undefined, quotaProvider?: QuotaProvider | undefined, options?: Pick<AgentModuleOptions, "quota" | "actionApprovalMode"> | undefined, queue?: ChatQueueService | undefined, proposals?: ActionProposalService | undefined);
169
+ /**
170
+ * Decide one independent proposal through the scoped proposal service — what the native
171
+ * `action-proposals/:id/approve|reject` routes call — and the reply to show for it. `404` when
172
+ * proposals are not on, `403`/`404` when this actor may not decide it.
173
+ */
174
+ decideActionProposal(actor: Actor, threadId: string, proposalId: string, command: {
175
+ decision: 'approved' | 'rejected';
176
+ remember?: boolean;
177
+ reason?: string;
178
+ via: string;
179
+ }): Promise<{
180
+ proposalDecision: ActionProposalMutationView;
181
+ text: string;
182
+ }>;
155
183
  handleTextDecision(threadId: string, actor: Actor, text: string): Promise<{
156
184
  status: "unmatched";
157
185
  } | {
158
186
  threadId: string;
159
- proposalDecision: _dudousxd_nestjs_agent_core.ActionProposalMutationResult;
187
+ proposalDecision: ActionProposalMutationView;
160
188
  text: string;
161
189
  } | {
162
190
  threadId: string;
@@ -520,6 +548,15 @@ declare class AgUiRunHandler {
520
548
  * bad entry settles nothing.
521
549
  */
522
550
  private settle;
551
+ /**
552
+ * Decide independent proposals through the proposal service — the call the native
553
+ * `action-proposals/:id/approve|reject` routes make — never by signalling the origin run, which
554
+ * is not waiting. Every payload is checked before the first decision; a refusal is the service's
555
+ * own `403`/`404`.
556
+ */
557
+ private decideProposals;
558
+ /** Answer with a complete list of events, no run behind them. */
559
+ private writeEvents;
523
560
  /**
524
561
  * Pipe a run to the client as AG-UI 1.0 over SSE: one event per `data:` line, from `RUN_STARTED`
525
562
  * to the run's terminal event. It ends when the run stops to ask — the library run stays parked,
@@ -565,7 +602,7 @@ declare class AgentApprovalPortAdapter implements AgentApprovalPort {
565
602
  }, opts?: {
566
603
  remember?: boolean;
567
604
  decidedVia?: string;
568
- }): Promise<_dudousxd_nestjs_agent_core.ActionProposalMutationResult>;
605
+ }): Promise<_dudousxd_nestjs_agent_core.ActionProposalMutationView>;
569
606
  rejectActionProposal(actor: Actor, target: {
570
607
  kind: 'proposal';
571
608
  threadId: string;
@@ -573,7 +610,7 @@ declare class AgentApprovalPortAdapter implements AgentApprovalPort {
573
610
  }, opts?: {
574
611
  reason?: string;
575
612
  decidedVia?: string;
576
- }): Promise<_dudousxd_nestjs_agent_core.ActionProposalMutationResult>;
613
+ }): Promise<_dudousxd_nestjs_agent_core.ActionProposalMutationView>;
577
614
  approve(toolCallId: string, opts?: {
578
615
  executedByRef?: string;
579
616
  remember?: boolean;
@@ -1420,9 +1457,9 @@ declare class ActionProposalController {
1420
1457
  private readonly proposals;
1421
1458
  private readonly actors;
1422
1459
  constructor(proposals: ActionProposalService, actors: ActorResolver);
1423
- list(threadId: string, request: Request, cursor: unknown, response: Response): Promise<_dudousxd_nestjs_agent_core.ActionProposal[]>;
1424
- approve(threadId: string, proposalId: string, request: Request, body: unknown): Promise<_dudousxd_nestjs_agent_core.ActionProposalMutationResult>;
1425
- reject(threadId: string, proposalId: string, request: Request, body: unknown): Promise<_dudousxd_nestjs_agent_core.ActionProposalMutationResult>;
1460
+ list(threadId: string, request: Request, cursor: unknown, response: Response): Promise<_dudousxd_nestjs_agent_core.ActionProposalView[]>;
1461
+ approve(threadId: string, proposalId: string, request: Request, body: unknown): Promise<_dudousxd_nestjs_agent_core.ActionProposalMutationView>;
1462
+ reject(threadId: string, proposalId: string, request: Request, body: unknown): Promise<_dudousxd_nestjs_agent_core.ActionProposalMutationView>;
1426
1463
  }
1427
1464
 
1428
1465
  declare class ActionProposalWorkerService implements OnModuleInit, OnModuleDestroy {
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { DynamicModule, Type, OnApplicationBootstrap, OnModuleInit, ConflictException, OnModuleDestroy } from '@nestjs/common';
2
- import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, C as ChatQueueService, d as AgentProtocolAdapter, e as AgentSkillsOptions } from './chat-queue.service-XG9RQCjU.js';
3
- export { f as AGENT_TOOL_BRAND, g as AgentAttachmentsOptions, h as AgentDeps, i as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QueuePlan, j as QueueSettleOutcome, k as QueuedTurn, l as QueuedTurnStarter, m as QuotaLimits, n as QuotaWindowLimits, o as delegateToolName, p as provideAgentTool, q as provideAgentTools, u as utcDay } from './chat-queue.service-XG9RQCjU.js';
2
+ import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, C as ChatQueueService, d as AgentProtocolAdapter, e as AgentSkillsOptions } from './chat-queue.service-CwxJDrBM.js';
3
+ export { f as AGENT_TOOL_BRAND, g as AgentAttachmentsOptions, h as AgentDeps, i as AgentEngine, j as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QueuePlan, k as QueueSettleOutcome, l as QueuedTurn, m as QueuedTurnStarter, n as QuotaLimits, o as QuotaWindowLimits, p as defineTool, q as delegateToolName, r as provideAgentTool, s as provideAgentTools, u as utcDay } from './chat-queue.service-CwxJDrBM.js';
4
4
  import * as _dudousxd_nestjs_agent_core from '@dudousxd/nestjs-agent-core';
5
- import { AgentStore, Actor, ListActionProposals, ActionProposalMutationResult, AgentRunner, AttachmentStagingStore, ModelCatalog, QuotaProvider, QuotaReport, ModelCatalogView, AttachmentRef, PageContext, ChatQueueState, HumanReply, ThreadSummary, ThreadDetail, UpdateThreadInput, MessageFeedbackValue, MessageFeedback, StagedAttachment, ActorResolver, AgentApprovalPort, MessageAttachment, AgentAttachmentConfig, AgentClientConfig, ToolSpec, ToolPresentation, AgentHistoryWindow, AgentIntake, Persona, SkillContext, ToolRegistry, AgentRegistry, PromptContributor, SkillsConfig, SkillCatalogEntry, ToolCatalogEntry, MemoryConfig, MemoryDigestEntry, SkillProvider, AgentRunInput, AgentRunStartOptions, TokenStreamSink, SinkWriter } from '@dudousxd/nestjs-agent-core';
5
+ import { AgentStore, Actor, ListActionProposals, ActionProposalMutationView, AgentRunner, AttachmentStagingStore, ModelCatalog, QuotaProvider, QuotaReport, ModelCatalogView, AgentHostContext, AttachmentRef, PageContext, ChatQueueState, HumanReply, ThreadSummary, ThreadDetail, UpdateThreadInput, MessageFeedbackValue, MessageFeedback, StagedAttachment, ActorResolver, AgentApprovalPort, MessageAttachment, AgentAttachmentConfig, AgentClientConfig, ToolSpec, ToolPresentation, AgentHistoryWindow, AgentIntake, Persona, SkillContext, ToolRegistry, AgentRegistry, PromptContributor, SkillsConfig, SkillCatalogEntry, ToolCatalogEntry, MemoryConfig, MemoryDigestEntry, SkillProvider, AgentRunInput, AgentRunStartOptions, TokenStreamSink, SinkWriter } from '@dudousxd/nestjs-agent-core';
6
6
  export * from '@dudousxd/nestjs-agent-core';
7
+ export { FunctionalToolDefinition } from '@dudousxd/nestjs-agent-core';
7
8
  import { Request, Response } from 'express';
8
9
  import { UiCapabilities } from '@dudousxd/nestjs-agent-core/genui';
9
10
  import { StandardSchemaV1 } from '@standard-schema/spec';
@@ -18,7 +19,10 @@ declare class AgentModule {
18
19
  declare class ActionProposalService {
19
20
  private readonly store;
20
21
  private readonly options;
21
- constructor(store: AgentStore, options: Pick<AgentModuleOptions, 'approvalPolicy'>);
22
+ constructor(store: AgentStore, options: Pick<AgentModuleOptions, 'approvalPolicy' | 'actionProposalText'>);
23
+ /** The words a text decision is made of, and what the agent answers — English unless configured. */
24
+ private readonly vocabulary;
25
+ private readonly replies;
22
26
  private capability;
23
27
  private scope;
24
28
  private mayDecide;
@@ -27,20 +31,20 @@ declare class ActionProposalService {
27
31
  createdAt: number;
28
32
  id: string;
29
33
  };
30
- items: _dudousxd_nestjs_agent_core.ActionProposal[];
34
+ items: _dudousxd_nestjs_agent_core.ActionProposalView[];
31
35
  }>;
32
- list(threadId: string, actor: Actor): Promise<_dudousxd_nestjs_agent_core.ActionProposal[]>;
36
+ list(threadId: string, actor: Actor): Promise<_dudousxd_nestjs_agent_core.ActionProposalView[]>;
33
37
  decide(threadId: string, proposalId: string, actor: Actor, command: {
34
38
  decision: 'approved' | 'rejected';
35
39
  remember?: boolean;
36
40
  reason?: string;
37
41
  via?: string;
38
- }): Promise<ActionProposalMutationResult>;
42
+ }): Promise<ActionProposalMutationView>;
39
43
  handleTextDecision(threadId: string, actor: Actor, text: string): Promise<{
40
44
  status: "unmatched";
41
45
  } | {
42
46
  threadId: string;
43
- proposalDecision: ActionProposalMutationResult;
47
+ proposalDecision: ActionProposalMutationView;
44
48
  text: string;
45
49
  } | {
46
50
  threadId: string;
@@ -51,6 +55,8 @@ declare class ActionProposalService {
51
55
  text: string;
52
56
  }>;
53
57
  private textReceipt;
58
+ /** The configured reply to a decision the store answered with `result`. */
59
+ reply(result: ActionProposalMutationView, decision: 'approved' | 'rejected'): string;
54
60
  }
55
61
 
56
62
  /**
@@ -90,6 +96,14 @@ interface ChatParams {
90
96
  uiCapabilities?: UiCapabilities;
91
97
  actor: Actor;
92
98
  message: string;
99
+ /** The host's own facts about this send — see `AgentRunInput.hostContext`. */
100
+ hostContext?: AgentHostContext;
101
+ /**
102
+ * The HOST already decided this actor may write this thread — a chat-app thread several people
103
+ * share, where anyone in it may continue the conversation. Skips the thread-ownership check of a
104
+ * send; never set it from a request's own claim.
105
+ */
106
+ authorized?: boolean;
93
107
  threadId?: string;
94
108
  agentName?: string;
95
109
  /**
@@ -152,11 +166,25 @@ declare class AgentService {
152
166
  private readonly queue?;
153
167
  private readonly proposals?;
154
168
  constructor(runner: AgentRunner, store: AgentStore, deps: AgentDepsFactory, staging?: AttachmentStagingStore | undefined, models?: ModelCatalog | undefined, quotaProvider?: QuotaProvider | undefined, options?: Pick<AgentModuleOptions, "quota" | "actionApprovalMode"> | undefined, queue?: ChatQueueService | undefined, proposals?: ActionProposalService | undefined);
169
+ /**
170
+ * Decide one independent proposal through the scoped proposal service — what the native
171
+ * `action-proposals/:id/approve|reject` routes call — and the reply to show for it. `404` when
172
+ * proposals are not on, `403`/`404` when this actor may not decide it.
173
+ */
174
+ decideActionProposal(actor: Actor, threadId: string, proposalId: string, command: {
175
+ decision: 'approved' | 'rejected';
176
+ remember?: boolean;
177
+ reason?: string;
178
+ via: string;
179
+ }): Promise<{
180
+ proposalDecision: ActionProposalMutationView;
181
+ text: string;
182
+ }>;
155
183
  handleTextDecision(threadId: string, actor: Actor, text: string): Promise<{
156
184
  status: "unmatched";
157
185
  } | {
158
186
  threadId: string;
159
- proposalDecision: _dudousxd_nestjs_agent_core.ActionProposalMutationResult;
187
+ proposalDecision: ActionProposalMutationView;
160
188
  text: string;
161
189
  } | {
162
190
  threadId: string;
@@ -520,6 +548,15 @@ declare class AgUiRunHandler {
520
548
  * bad entry settles nothing.
521
549
  */
522
550
  private settle;
551
+ /**
552
+ * Decide independent proposals through the proposal service — the call the native
553
+ * `action-proposals/:id/approve|reject` routes make — never by signalling the origin run, which
554
+ * is not waiting. Every payload is checked before the first decision; a refusal is the service's
555
+ * own `403`/`404`.
556
+ */
557
+ private decideProposals;
558
+ /** Answer with a complete list of events, no run behind them. */
559
+ private writeEvents;
523
560
  /**
524
561
  * Pipe a run to the client as AG-UI 1.0 over SSE: one event per `data:` line, from `RUN_STARTED`
525
562
  * to the run's terminal event. It ends when the run stops to ask — the library run stays parked,
@@ -565,7 +602,7 @@ declare class AgentApprovalPortAdapter implements AgentApprovalPort {
565
602
  }, opts?: {
566
603
  remember?: boolean;
567
604
  decidedVia?: string;
568
- }): Promise<_dudousxd_nestjs_agent_core.ActionProposalMutationResult>;
605
+ }): Promise<_dudousxd_nestjs_agent_core.ActionProposalMutationView>;
569
606
  rejectActionProposal(actor: Actor, target: {
570
607
  kind: 'proposal';
571
608
  threadId: string;
@@ -573,7 +610,7 @@ declare class AgentApprovalPortAdapter implements AgentApprovalPort {
573
610
  }, opts?: {
574
611
  reason?: string;
575
612
  decidedVia?: string;
576
- }): Promise<_dudousxd_nestjs_agent_core.ActionProposalMutationResult>;
613
+ }): Promise<_dudousxd_nestjs_agent_core.ActionProposalMutationView>;
577
614
  approve(toolCallId: string, opts?: {
578
615
  executedByRef?: string;
579
616
  remember?: boolean;
@@ -1420,9 +1457,9 @@ declare class ActionProposalController {
1420
1457
  private readonly proposals;
1421
1458
  private readonly actors;
1422
1459
  constructor(proposals: ActionProposalService, actors: ActorResolver);
1423
- list(threadId: string, request: Request, cursor: unknown, response: Response): Promise<_dudousxd_nestjs_agent_core.ActionProposal[]>;
1424
- approve(threadId: string, proposalId: string, request: Request, body: unknown): Promise<_dudousxd_nestjs_agent_core.ActionProposalMutationResult>;
1425
- reject(threadId: string, proposalId: string, request: Request, body: unknown): Promise<_dudousxd_nestjs_agent_core.ActionProposalMutationResult>;
1460
+ list(threadId: string, request: Request, cursor: unknown, response: Response): Promise<_dudousxd_nestjs_agent_core.ActionProposalView[]>;
1461
+ approve(threadId: string, proposalId: string, request: Request, body: unknown): Promise<_dudousxd_nestjs_agent_core.ActionProposalMutationView>;
1462
+ reject(threadId: string, proposalId: string, request: Request, body: unknown): Promise<_dudousxd_nestjs_agent_core.ActionProposalMutationView>;
1426
1463
  }
1427
1464
 
1428
1465
  declare class ActionProposalWorkerService implements OnModuleInit, OnModuleDestroy {