@dudousxd/nestjs-agent 0.1.0 → 0.3.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.
@@ -1,4 +1,4 @@
1
- import { ModelProvider, AgentStore, ToolRegistry, RolesPolicy, QuotaStore, TokenStreamSink, PromptBuilder, Persona, Retriever, ToolSpec, ToolHandler, ActorResolver, AgentDefinition, AgentRegistry } from '@dudousxd/nestjs-agent-core';
1
+ import { ModelProvider, AgentStore, ToolRegistry, RolesPolicy, QuotaStore, TokenStreamSink, PromptBuilder, PromptContributor, Retriever, ToolSpec, ToolHandler, ActorResolver, AgentRegistry } from '@dudousxd/nestjs-agent-core';
2
2
  import { Provider, FactoryProvider, ModuleMetadata, InjectionToken, OptionalFactoryDependency } from '@nestjs/common';
3
3
 
4
4
  /** Everything `runAgentLoop` needs, minus the per-run `day` the runner stamps. */
@@ -12,10 +12,10 @@ interface AgentDeps {
12
12
  /** Fallback accounting label; the provider's turn result overrides it when set. */
13
13
  modelId?: string;
14
14
  systemPrompt: string | PromptBuilder;
15
+ /** App-wide `@SystemPromptContributor()` sections appended after the agent's base prompt. */
16
+ promptContributors: PromptContributor[];
15
17
  maxSteps: number;
16
- personas: Map<string, Persona>;
17
- defaultPersona: string;
18
- /** Agent-level tool allow-list (intersected with the persona's). Undefined → all tools. */
18
+ /** Agent-level tool allow-list. Undefined → all tools (after role filtering). */
19
19
  toolAllowList?: string[];
20
20
  /** Per-tool execution timeout in ms (from module options). Undefined → no timeout. */
21
21
  toolTimeoutMs?: number;
@@ -49,15 +49,6 @@ interface FunctionalTool {
49
49
  declare function provideAgentTool(tool: FunctionalTool): Provider;
50
50
  declare function provideAgentTool(factory: (...deps: never[]) => FunctionalTool, inject?: FactoryProvider['inject']): Provider;
51
51
 
52
- /**
53
- * The implicit default agent, configured inline on `forRoot`. It is an {@link AgentDefinition}
54
- * with `name` optional (defaults to `'default'`) — everything agent-shaped is an AgentDefinition,
55
- * whether it's this default or one registered via `forFeature`. Omit it entirely for a bare
56
- * assistant with no base prompt, personas, or tool allow-list.
57
- */
58
- type DefaultAgentOptions = Omit<AgentDefinition, 'name'> & {
59
- name?: string;
60
- };
61
52
  interface AgentModuleOptions {
62
53
  /** The LLM provider (e.g. a Vercel AI SDK wrapper). Required. */
63
54
  model: ModelProvider;
@@ -129,10 +120,11 @@ interface AgentModuleOptions {
129
120
  topK?: number;
130
121
  };
131
122
  /**
132
- * The implicit single agent's config (base prompt, personas, tool allow-list, model/step
133
- * config). Omit for a bare assistant. Additional named agents are added via `forFeature`.
123
+ * The name of the agent a turn uses when the caller doesn't select one. Omit → the single
124
+ * discovered `@Agent` (when there is exactly one), else `'default'` (a bare assistant if no
125
+ * `@Agent` is registered). Agents themselves are declared as `@Agent`-decorated providers, not here.
134
126
  */
135
- defaultAgent?: DefaultAgentOptions;
127
+ defaultAgent?: string;
136
128
  }
137
129
  interface AgentModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
138
130
  inject?: Array<InjectionToken | OptionalFactoryDependency>;
@@ -150,9 +142,9 @@ interface AgentModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
150
142
  durable?: boolean;
151
143
  }
152
144
 
153
- /** The synthesized `agent`-kind tool name an orchestrator uses to delegate to `target`. */
145
+ /** The synthesized `agent`-kind tool name an orchestrator uses to hand off to `target`. */
154
146
  declare function delegateToolName(target: string): string;
155
- /** Builds the per-agent loop deps. The single-agent case is just the `default` definition. */
147
+ /** Builds the per-agent loop deps. The single-agent case is just the one registered `@Agent`. */
156
148
  declare class AgentDepsFactory {
157
149
  private readonly options;
158
150
  private readonly model;
@@ -161,8 +153,13 @@ declare class AgentDepsFactory {
161
153
  private readonly rolesPolicy;
162
154
  private readonly registry;
163
155
  private readonly agents;
156
+ private readonly promptContributors;
164
157
  private readonly quota;
165
- constructor(options: AgentModuleOptions, model: ModelProvider, store: AgentStore, sink: TokenStreamSink, rolesPolicy: RolesPolicy, registry: ToolRegistry, agents: AgentRegistry, quota: QuotaStore | undefined);
158
+ constructor(options: AgentModuleOptions, model: ModelProvider, store: AgentStore, sink: TokenStreamSink, rolesPolicy: RolesPolicy, registry: ToolRegistry, agents: AgentRegistry, promptContributors: PromptContributor[], quota: QuotaStore | undefined);
159
+ /**
160
+ * The agent a turn uses when the caller names none: the explicit `defaultAgent` option, else the
161
+ * sole registered `@Agent` when there is exactly one, else `'default'` (a bare assistant).
162
+ */
166
163
  defaultAgentName(): string;
167
164
  private effectiveTools;
168
165
  forAgent(agentName?: string): AgentDeps;
@@ -170,4 +167,4 @@ declare class AgentDepsFactory {
170
167
  private followUpsCount;
171
168
  }
172
169
 
173
- export { AgentDepsFactory as A, type DefaultAgentOptions as D, type FunctionalTool as F, type AgentModuleOptions as a, type AgentModuleAsyncOptions as b, AGENT_TOOL_BRAND as c, type AgentDeps as d, delegateToolName as e, provideAgentTool as p, utcDay as u };
170
+ export { AgentDepsFactory as A, type FunctionalTool as F, type AgentModuleOptions as a, type AgentModuleAsyncOptions as b, AGENT_TOOL_BRAND as c, type AgentDeps as d, delegateToolName as e, provideAgentTool as p, utcDay as u };
@@ -1,4 +1,4 @@
1
- import { ModelProvider, AgentStore, ToolRegistry, RolesPolicy, QuotaStore, TokenStreamSink, PromptBuilder, Persona, Retriever, ToolSpec, ToolHandler, ActorResolver, AgentDefinition, AgentRegistry } from '@dudousxd/nestjs-agent-core';
1
+ import { ModelProvider, AgentStore, ToolRegistry, RolesPolicy, QuotaStore, TokenStreamSink, PromptBuilder, PromptContributor, Retriever, ToolSpec, ToolHandler, ActorResolver, AgentRegistry } from '@dudousxd/nestjs-agent-core';
2
2
  import { Provider, FactoryProvider, ModuleMetadata, InjectionToken, OptionalFactoryDependency } from '@nestjs/common';
3
3
 
4
4
  /** Everything `runAgentLoop` needs, minus the per-run `day` the runner stamps. */
@@ -12,10 +12,10 @@ interface AgentDeps {
12
12
  /** Fallback accounting label; the provider's turn result overrides it when set. */
13
13
  modelId?: string;
14
14
  systemPrompt: string | PromptBuilder;
15
+ /** App-wide `@SystemPromptContributor()` sections appended after the agent's base prompt. */
16
+ promptContributors: PromptContributor[];
15
17
  maxSteps: number;
16
- personas: Map<string, Persona>;
17
- defaultPersona: string;
18
- /** Agent-level tool allow-list (intersected with the persona's). Undefined → all tools. */
18
+ /** Agent-level tool allow-list. Undefined → all tools (after role filtering). */
19
19
  toolAllowList?: string[];
20
20
  /** Per-tool execution timeout in ms (from module options). Undefined → no timeout. */
21
21
  toolTimeoutMs?: number;
@@ -49,15 +49,6 @@ interface FunctionalTool {
49
49
  declare function provideAgentTool(tool: FunctionalTool): Provider;
50
50
  declare function provideAgentTool(factory: (...deps: never[]) => FunctionalTool, inject?: FactoryProvider['inject']): Provider;
51
51
 
52
- /**
53
- * The implicit default agent, configured inline on `forRoot`. It is an {@link AgentDefinition}
54
- * with `name` optional (defaults to `'default'`) — everything agent-shaped is an AgentDefinition,
55
- * whether it's this default or one registered via `forFeature`. Omit it entirely for a bare
56
- * assistant with no base prompt, personas, or tool allow-list.
57
- */
58
- type DefaultAgentOptions = Omit<AgentDefinition, 'name'> & {
59
- name?: string;
60
- };
61
52
  interface AgentModuleOptions {
62
53
  /** The LLM provider (e.g. a Vercel AI SDK wrapper). Required. */
63
54
  model: ModelProvider;
@@ -129,10 +120,11 @@ interface AgentModuleOptions {
129
120
  topK?: number;
130
121
  };
131
122
  /**
132
- * The implicit single agent's config (base prompt, personas, tool allow-list, model/step
133
- * config). Omit for a bare assistant. Additional named agents are added via `forFeature`.
123
+ * The name of the agent a turn uses when the caller doesn't select one. Omit → the single
124
+ * discovered `@Agent` (when there is exactly one), else `'default'` (a bare assistant if no
125
+ * `@Agent` is registered). Agents themselves are declared as `@Agent`-decorated providers, not here.
134
126
  */
135
- defaultAgent?: DefaultAgentOptions;
127
+ defaultAgent?: string;
136
128
  }
137
129
  interface AgentModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
138
130
  inject?: Array<InjectionToken | OptionalFactoryDependency>;
@@ -150,9 +142,9 @@ interface AgentModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
150
142
  durable?: boolean;
151
143
  }
152
144
 
153
- /** The synthesized `agent`-kind tool name an orchestrator uses to delegate to `target`. */
145
+ /** The synthesized `agent`-kind tool name an orchestrator uses to hand off to `target`. */
154
146
  declare function delegateToolName(target: string): string;
155
- /** Builds the per-agent loop deps. The single-agent case is just the `default` definition. */
147
+ /** Builds the per-agent loop deps. The single-agent case is just the one registered `@Agent`. */
156
148
  declare class AgentDepsFactory {
157
149
  private readonly options;
158
150
  private readonly model;
@@ -161,8 +153,13 @@ declare class AgentDepsFactory {
161
153
  private readonly rolesPolicy;
162
154
  private readonly registry;
163
155
  private readonly agents;
156
+ private readonly promptContributors;
164
157
  private readonly quota;
165
- constructor(options: AgentModuleOptions, model: ModelProvider, store: AgentStore, sink: TokenStreamSink, rolesPolicy: RolesPolicy, registry: ToolRegistry, agents: AgentRegistry, quota: QuotaStore | undefined);
158
+ constructor(options: AgentModuleOptions, model: ModelProvider, store: AgentStore, sink: TokenStreamSink, rolesPolicy: RolesPolicy, registry: ToolRegistry, agents: AgentRegistry, promptContributors: PromptContributor[], quota: QuotaStore | undefined);
159
+ /**
160
+ * The agent a turn uses when the caller names none: the explicit `defaultAgent` option, else the
161
+ * sole registered `@Agent` when there is exactly one, else `'default'` (a bare assistant).
162
+ */
166
163
  defaultAgentName(): string;
167
164
  private effectiveTools;
168
165
  forAgent(agentName?: string): AgentDeps;
@@ -170,4 +167,4 @@ declare class AgentDepsFactory {
170
167
  private followUpsCount;
171
168
  }
172
169
 
173
- export { AgentDepsFactory as A, type DefaultAgentOptions as D, type FunctionalTool as F, type AgentModuleOptions as a, type AgentModuleAsyncOptions as b, AGENT_TOOL_BRAND as c, type AgentDeps as d, delegateToolName as e, provideAgentTool as p, utcDay as u };
170
+ export { AgentDepsFactory as A, type FunctionalTool as F, type AgentModuleOptions as a, type AgentModuleAsyncOptions as b, AGENT_TOOL_BRAND as c, type AgentDeps as d, delegateToolName as e, provideAgentTool as p, utcDay as u };