@dudousxd/nestjs-agent 1.6.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, 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';
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;
@@ -695,6 +719,17 @@ declare class MessagesController {
695
719
  }>;
696
720
  }
697
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
+
698
733
  /**
699
734
  * The tools THIS caller can reach through an agent, with how a chat surface should talk about each
700
735
  * one (`@AiTool({ presentation })`) — so a client narrates "Querying orders" instead of printing
@@ -898,4 +933,4 @@ declare class HeaderActorResolver implements ActorResolver {
898
933
  resolve(req: unknown): Actor;
899
934
  }
900
935
 
901
- 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, 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, 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';
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;
@@ -695,6 +719,17 @@ declare class MessagesController {
695
719
  }>;
696
720
  }
697
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
+
698
733
  /**
699
734
  * The tools THIS caller can reach through an agent, with how a chat surface should talk about each
700
735
  * one (`@AiTool({ presentation })`) — so a client narrates "Querying orders" instead of printing
@@ -898,4 +933,4 @@ declare class HeaderActorResolver implements ActorResolver {
898
933
  resolve(req: unknown): Actor;
899
934
  }
900
935
 
901
- 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, 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 };