@dudousxd/nestjs-agent 1.5.0 → 1.7.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,7 +1,7 @@
1
1
  import { DynamicModule, OnModuleInit, Type, OnApplicationBootstrap } from '@nestjs/common';
2
- import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, d as AgentSkillsOptions } from './agent-deps.factory-CUyVPsa1.cjs';
3
- export { e as AGENT_TOOL_BRAND, f as AgentAttachmentsOptions, g as AgentDeps, h as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, i as delegateToolName, p as provideAgentTool, u as utcDay } from './agent-deps.factory-CUyVPsa1.cjs';
4
- import { AgentRunner, AgentStore, QuotaStore, AttachmentStagingStore, Actor, AttachmentRef, PageContext, HumanReply, ThreadSummary, ThreadDetail, UpdateThreadInput, StagedAttachment, QuotaView, AgentApprovalPort, ActorResolver, MessageAttachment, ToolPresentation, AgentHistoryWindow, AgentIntake, SkillContext, ToolRegistry, AgentRegistry, PromptContributor, SkillsConfig, SkillCatalogEntry, ToolCatalogEntry, MemoryConfig, MemoryDigestEntry, SkillProvider, AgentRunInput, TokenStreamSink, SinkWriter, QuotaState } from '@dudousxd/nestjs-agent-core';
2
+ import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, d as AgentSkillsOptions } from './agent-deps.factory-CiC5Va9J.cjs';
3
+ export { e as AGENT_TOOL_BRAND, f as AgentAttachmentsOptions, g as AgentDeps, h as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, i as delegateToolName, p as provideAgentTool, u as utcDay } from './agent-deps.factory-CiC5Va9J.cjs';
4
+ import { AgentRunner, AgentStore, QuotaStore, AttachmentStagingStore, ModelCatalog, Actor, ModelCatalogView, AttachmentRef, PageContext, HumanReply, ThreadSummary, ThreadDetail, UpdateThreadInput, MessageFeedbackValue, MessageFeedback, StagedAttachment, QuotaView, AgentApprovalPort, ActorResolver, MessageAttachment, ToolPresentation, AgentHistoryWindow, AgentIntake, SkillContext, ToolRegistry, AgentRegistry, PromptContributor, SkillsConfig, SkillCatalogEntry, ToolCatalogEntry, MemoryConfig, MemoryDigestEntry, SkillProvider, AgentRunInput, TokenStreamSink, SinkWriter, QuotaState } from '@dudousxd/nestjs-agent-core';
5
5
  export * from '@dudousxd/nestjs-agent-core';
6
6
  import { Request } from 'express';
7
7
  import { StandardSchemaV1 } from '@standard-schema/spec';
@@ -26,6 +26,11 @@ interface ChatParams {
26
26
  pageContext?: PageContext;
27
27
  /** Re-run the last exchange instead of adding a new message. Requires an existing `threadId`. */
28
28
  regenerate?: boolean;
29
+ /**
30
+ * Run this turn on a catalog model instead of the thread's pinned one (or the provider default).
31
+ * Refused (400) unless the bound `ModelCatalog` lists it as available to this actor and agent.
32
+ */
33
+ model?: string;
29
34
  /**
30
35
  * When creating a thread (no `threadId`), start it transient — a scratch conversation hidden from
31
36
  * the thread list until the caller promotes it. Ignored when `threadId` is set.
@@ -42,6 +47,10 @@ interface ChatParams {
42
47
  interface ThreadDefaultAgentReader {
43
48
  defaultAgentForThread(threadId: string): Promise<string | null>;
44
49
  }
50
+ /** Like {@link ThreadDefaultAgentReader}, for the thread's pinned model. */
51
+ interface ThreadModelReader {
52
+ modelForThread(threadId: string): Promise<string | null>;
53
+ }
45
54
  /** The orchestration facade the controllers call. */
46
55
  declare class AgentService {
47
56
  private readonly runner;
@@ -49,7 +58,22 @@ declare class AgentService {
49
58
  private readonly deps;
50
59
  private readonly quota;
51
60
  private readonly staging?;
52
- constructor(runner: AgentRunner, store: AgentStore, deps: AgentDepsFactory, quota: QuotaStore | undefined, staging?: AttachmentStagingStore | undefined);
61
+ private readonly models?;
62
+ constructor(runner: AgentRunner, store: AgentStore, deps: AgentDepsFactory, quota: QuotaStore | undefined, staging?: AttachmentStagingStore | undefined, models?: ModelCatalog | undefined);
63
+ /**
64
+ * The models `actor` may pick for `agent` (`GET <base>/models`). An empty catalog when none is
65
+ * bound, so a picker simply has nothing to offer.
66
+ */
67
+ listModels(actor: Actor, agent?: string): Promise<ModelCatalogView>;
68
+ /**
69
+ * `model` if the catalog offers it to this actor and agent right now, else a 400 naming why. The
70
+ * one gate every model choice passes — a send's own, and a thread's pinned one at the moment it is
71
+ * pinned and again at every turn that runs on it (availability can change in between).
72
+ */
73
+ private assertModelAllowed;
74
+ /** The model a turn runs on: the send's own, else the thread's pinned one, else none. */
75
+ private resolveModel;
76
+ private threadModel;
53
77
  chat(params: ChatParams): Promise<{
54
78
  runId: string;
55
79
  threadId: string;
@@ -152,6 +176,15 @@ declare class AgentService {
152
176
  * thread-scoped mutations.
153
177
  */
154
178
  truncateThreadFrom(actor: Actor, threadId: string, messageId: string): Promise<void>;
179
+ /**
180
+ * Rate a message in one of `actor`'s threads: `'up'`/`'down'` with an optional comment, or `null`
181
+ * to clear the rating. Answers `404` for an unknown message, `403` for another actor's, and `501`
182
+ * on a store without `threadOfMessage` + `setMessageFeedback`.
183
+ */
184
+ setMessageFeedback(actor: Actor, messageId: string, input: {
185
+ value: MessageFeedbackValue | null;
186
+ comment?: string;
187
+ }): Promise<MessageFeedback | null>;
155
188
  /**
156
189
  * Every file this actor has staged, newest first — across threads, including uploads that were
157
190
  * never sent, which nothing else on this surface can see.
@@ -668,6 +701,35 @@ declare class SkillsController {
668
701
  threadId?: string): Promise<SkillCatalogEntry[]>;
669
702
  }
670
703
 
704
+ interface FeedbackBody {
705
+ /** `null` clears the rating. */
706
+ value: MessageFeedbackValue | null;
707
+ comment?: string;
708
+ }
709
+ declare class MessagesController {
710
+ private readonly agent;
711
+ private readonly actorResolver;
712
+ constructor(agent: AgentService, actorResolver: ActorResolver);
713
+ /**
714
+ * Rate a message: `{ value: 'up' | 'down' | null, comment? }`. Answers the stored rating
715
+ * (`{ feedback: null }` once cleared). Only the thread's owner may rate its messages.
716
+ */
717
+ feedback(req: Request, id: string, body: FeedbackBody): Promise<{
718
+ feedback: MessageFeedback | null;
719
+ }>;
720
+ }
721
+
722
+ declare class ModelsController {
723
+ private readonly agent;
724
+ private readonly actorResolver;
725
+ constructor(agent: AgentService, actorResolver: ActorResolver);
726
+ /**
727
+ * The models the caller may pick for `agent` (the default agent when omitted), grouped by
728
+ * provider, with badges and availability — the bound `ModelCatalog`'s answer, or an empty one.
729
+ */
730
+ list(req: Request, agent?: string): Promise<ModelCatalogView>;
731
+ }
732
+
671
733
  /**
672
734
  * The tools THIS caller can reach through an agent, with how a chat surface should talk about each
673
735
  * one (`@AiTool({ presentation })`) — so a client narrates "Querying orders" instead of printing
@@ -871,4 +933,4 @@ declare class HeaderActorResolver implements ActorResolver {
871
933
  resolve(req: unknown): Actor;
872
934
  }
873
935
 
874
- export { AGENT_METADATA, AI_TOOL_METADATA, ATTACHMENT_PAGE_SIZE, Agent, AgentApprovalPortAdapter, AgentDepsFactory, AgentDiscoveryService, AgentModule, AgentModuleAsyncOptions, AgentModuleOptions, type AgentOptions, AgentService, AgentSkillsOptions, AiTool, AiToolDiscoveryService, type AiToolOptions, AttachmentsController, type ChatParams, DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, DEFAULT_MAX_ATTACHMENT_BYTES, type DeclaredSkill, HeaderActorResolver, InProcessTokenStreamSink, InlineAgentRunner, LedgerQuotaStore, MemoriesController, SKILL_METADATA, SYSTEM_PROMPT_CONTRIBUTOR_METADATA, SYSTEM_PROMPT_METADATA, Skill, type SkillBody, SkillDiscoveryService, type SkillOptions, SkillsController, SystemPrompt, SystemPromptContributor, type ThreadDefaultAgentReader, ToolsController, declaredSkillProvider, readAgentMetadata, readAiToolMetadata, readSkillMetadata, resolveSkillsConfig, skillScope };
936
+ export { AGENT_METADATA, AI_TOOL_METADATA, ATTACHMENT_PAGE_SIZE, Agent, AgentApprovalPortAdapter, AgentDepsFactory, AgentDiscoveryService, AgentModule, AgentModuleAsyncOptions, AgentModuleOptions, type AgentOptions, AgentService, AgentSkillsOptions, AiTool, AiToolDiscoveryService, type AiToolOptions, AttachmentsController, type ChatParams, DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, DEFAULT_MAX_ATTACHMENT_BYTES, type DeclaredSkill, HeaderActorResolver, InProcessTokenStreamSink, InlineAgentRunner, LedgerQuotaStore, MemoriesController, MessagesController, ModelsController, SKILL_METADATA, SYSTEM_PROMPT_CONTRIBUTOR_METADATA, SYSTEM_PROMPT_METADATA, Skill, type SkillBody, SkillDiscoveryService, type SkillOptions, SkillsController, SystemPrompt, SystemPromptContributor, type ThreadDefaultAgentReader, type ThreadModelReader, ToolsController, declaredSkillProvider, readAgentMetadata, readAiToolMetadata, readSkillMetadata, resolveSkillsConfig, skillScope };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { DynamicModule, OnModuleInit, Type, OnApplicationBootstrap } from '@nestjs/common';
2
- import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, d as AgentSkillsOptions } from './agent-deps.factory-CUyVPsa1.js';
3
- export { e as AGENT_TOOL_BRAND, f as AgentAttachmentsOptions, g as AgentDeps, h as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, i as delegateToolName, p as provideAgentTool, u as utcDay } from './agent-deps.factory-CUyVPsa1.js';
4
- import { AgentRunner, AgentStore, QuotaStore, AttachmentStagingStore, Actor, AttachmentRef, PageContext, HumanReply, ThreadSummary, ThreadDetail, UpdateThreadInput, StagedAttachment, QuotaView, AgentApprovalPort, ActorResolver, MessageAttachment, ToolPresentation, AgentHistoryWindow, AgentIntake, SkillContext, ToolRegistry, AgentRegistry, PromptContributor, SkillsConfig, SkillCatalogEntry, ToolCatalogEntry, MemoryConfig, MemoryDigestEntry, SkillProvider, AgentRunInput, TokenStreamSink, SinkWriter, QuotaState } from '@dudousxd/nestjs-agent-core';
2
+ import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, d as AgentSkillsOptions } from './agent-deps.factory-CiC5Va9J.js';
3
+ export { e as AGENT_TOOL_BRAND, f as AgentAttachmentsOptions, g as AgentDeps, h as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, i as delegateToolName, p as provideAgentTool, u as utcDay } from './agent-deps.factory-CiC5Va9J.js';
4
+ import { AgentRunner, AgentStore, QuotaStore, AttachmentStagingStore, ModelCatalog, Actor, ModelCatalogView, AttachmentRef, PageContext, HumanReply, ThreadSummary, ThreadDetail, UpdateThreadInput, MessageFeedbackValue, MessageFeedback, StagedAttachment, QuotaView, AgentApprovalPort, ActorResolver, MessageAttachment, ToolPresentation, AgentHistoryWindow, AgentIntake, SkillContext, ToolRegistry, AgentRegistry, PromptContributor, SkillsConfig, SkillCatalogEntry, ToolCatalogEntry, MemoryConfig, MemoryDigestEntry, SkillProvider, AgentRunInput, TokenStreamSink, SinkWriter, QuotaState } from '@dudousxd/nestjs-agent-core';
5
5
  export * from '@dudousxd/nestjs-agent-core';
6
6
  import { Request } from 'express';
7
7
  import { StandardSchemaV1 } from '@standard-schema/spec';
@@ -26,6 +26,11 @@ interface ChatParams {
26
26
  pageContext?: PageContext;
27
27
  /** Re-run the last exchange instead of adding a new message. Requires an existing `threadId`. */
28
28
  regenerate?: boolean;
29
+ /**
30
+ * Run this turn on a catalog model instead of the thread's pinned one (or the provider default).
31
+ * Refused (400) unless the bound `ModelCatalog` lists it as available to this actor and agent.
32
+ */
33
+ model?: string;
29
34
  /**
30
35
  * When creating a thread (no `threadId`), start it transient — a scratch conversation hidden from
31
36
  * the thread list until the caller promotes it. Ignored when `threadId` is set.
@@ -42,6 +47,10 @@ interface ChatParams {
42
47
  interface ThreadDefaultAgentReader {
43
48
  defaultAgentForThread(threadId: string): Promise<string | null>;
44
49
  }
50
+ /** Like {@link ThreadDefaultAgentReader}, for the thread's pinned model. */
51
+ interface ThreadModelReader {
52
+ modelForThread(threadId: string): Promise<string | null>;
53
+ }
45
54
  /** The orchestration facade the controllers call. */
46
55
  declare class AgentService {
47
56
  private readonly runner;
@@ -49,7 +58,22 @@ declare class AgentService {
49
58
  private readonly deps;
50
59
  private readonly quota;
51
60
  private readonly staging?;
52
- constructor(runner: AgentRunner, store: AgentStore, deps: AgentDepsFactory, quota: QuotaStore | undefined, staging?: AttachmentStagingStore | undefined);
61
+ private readonly models?;
62
+ constructor(runner: AgentRunner, store: AgentStore, deps: AgentDepsFactory, quota: QuotaStore | undefined, staging?: AttachmentStagingStore | undefined, models?: ModelCatalog | undefined);
63
+ /**
64
+ * The models `actor` may pick for `agent` (`GET <base>/models`). An empty catalog when none is
65
+ * bound, so a picker simply has nothing to offer.
66
+ */
67
+ listModels(actor: Actor, agent?: string): Promise<ModelCatalogView>;
68
+ /**
69
+ * `model` if the catalog offers it to this actor and agent right now, else a 400 naming why. The
70
+ * one gate every model choice passes — a send's own, and a thread's pinned one at the moment it is
71
+ * pinned and again at every turn that runs on it (availability can change in between).
72
+ */
73
+ private assertModelAllowed;
74
+ /** The model a turn runs on: the send's own, else the thread's pinned one, else none. */
75
+ private resolveModel;
76
+ private threadModel;
53
77
  chat(params: ChatParams): Promise<{
54
78
  runId: string;
55
79
  threadId: string;
@@ -152,6 +176,15 @@ declare class AgentService {
152
176
  * thread-scoped mutations.
153
177
  */
154
178
  truncateThreadFrom(actor: Actor, threadId: string, messageId: string): Promise<void>;
179
+ /**
180
+ * Rate a message in one of `actor`'s threads: `'up'`/`'down'` with an optional comment, or `null`
181
+ * to clear the rating. Answers `404` for an unknown message, `403` for another actor's, and `501`
182
+ * on a store without `threadOfMessage` + `setMessageFeedback`.
183
+ */
184
+ setMessageFeedback(actor: Actor, messageId: string, input: {
185
+ value: MessageFeedbackValue | null;
186
+ comment?: string;
187
+ }): Promise<MessageFeedback | null>;
155
188
  /**
156
189
  * Every file this actor has staged, newest first — across threads, including uploads that were
157
190
  * never sent, which nothing else on this surface can see.
@@ -668,6 +701,35 @@ declare class SkillsController {
668
701
  threadId?: string): Promise<SkillCatalogEntry[]>;
669
702
  }
670
703
 
704
+ interface FeedbackBody {
705
+ /** `null` clears the rating. */
706
+ value: MessageFeedbackValue | null;
707
+ comment?: string;
708
+ }
709
+ declare class MessagesController {
710
+ private readonly agent;
711
+ private readonly actorResolver;
712
+ constructor(agent: AgentService, actorResolver: ActorResolver);
713
+ /**
714
+ * Rate a message: `{ value: 'up' | 'down' | null, comment? }`. Answers the stored rating
715
+ * (`{ feedback: null }` once cleared). Only the thread's owner may rate its messages.
716
+ */
717
+ feedback(req: Request, id: string, body: FeedbackBody): Promise<{
718
+ feedback: MessageFeedback | null;
719
+ }>;
720
+ }
721
+
722
+ declare class ModelsController {
723
+ private readonly agent;
724
+ private readonly actorResolver;
725
+ constructor(agent: AgentService, actorResolver: ActorResolver);
726
+ /**
727
+ * The models the caller may pick for `agent` (the default agent when omitted), grouped by
728
+ * provider, with badges and availability — the bound `ModelCatalog`'s answer, or an empty one.
729
+ */
730
+ list(req: Request, agent?: string): Promise<ModelCatalogView>;
731
+ }
732
+
671
733
  /**
672
734
  * The tools THIS caller can reach through an agent, with how a chat surface should talk about each
673
735
  * one (`@AiTool({ presentation })`) — so a client narrates "Querying orders" instead of printing
@@ -871,4 +933,4 @@ declare class HeaderActorResolver implements ActorResolver {
871
933
  resolve(req: unknown): Actor;
872
934
  }
873
935
 
874
- export { AGENT_METADATA, AI_TOOL_METADATA, ATTACHMENT_PAGE_SIZE, Agent, AgentApprovalPortAdapter, AgentDepsFactory, AgentDiscoveryService, AgentModule, AgentModuleAsyncOptions, AgentModuleOptions, type AgentOptions, AgentService, AgentSkillsOptions, AiTool, AiToolDiscoveryService, type AiToolOptions, AttachmentsController, type ChatParams, DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, DEFAULT_MAX_ATTACHMENT_BYTES, type DeclaredSkill, HeaderActorResolver, InProcessTokenStreamSink, InlineAgentRunner, LedgerQuotaStore, MemoriesController, SKILL_METADATA, SYSTEM_PROMPT_CONTRIBUTOR_METADATA, SYSTEM_PROMPT_METADATA, Skill, type SkillBody, SkillDiscoveryService, type SkillOptions, SkillsController, SystemPrompt, SystemPromptContributor, type ThreadDefaultAgentReader, ToolsController, declaredSkillProvider, readAgentMetadata, readAiToolMetadata, readSkillMetadata, resolveSkillsConfig, skillScope };
936
+ export { AGENT_METADATA, AI_TOOL_METADATA, ATTACHMENT_PAGE_SIZE, Agent, AgentApprovalPortAdapter, AgentDepsFactory, AgentDiscoveryService, AgentModule, AgentModuleAsyncOptions, AgentModuleOptions, type AgentOptions, AgentService, AgentSkillsOptions, AiTool, AiToolDiscoveryService, type AiToolOptions, AttachmentsController, type ChatParams, DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, DEFAULT_MAX_ATTACHMENT_BYTES, type DeclaredSkill, HeaderActorResolver, InProcessTokenStreamSink, InlineAgentRunner, LedgerQuotaStore, MemoriesController, MessagesController, ModelsController, SKILL_METADATA, SYSTEM_PROMPT_CONTRIBUTOR_METADATA, SYSTEM_PROMPT_METADATA, Skill, type SkillBody, SkillDiscoveryService, type SkillOptions, SkillsController, SystemPrompt, SystemPromptContributor, type ThreadDefaultAgentReader, type ThreadModelReader, ToolsController, declaredSkillProvider, readAgentMetadata, readAiToolMetadata, readSkillMetadata, resolveSkillsConfig, skillScope };