@dudousxd/nestjs-agent 0.3.2 → 0.4.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,8 +1,9 @@
1
- import { DynamicModule, Type, OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
2
- import { a as AgentModuleOptions, b as AgentModuleAsyncOptions, A as AgentDepsFactory } from './agent-deps.factory-DpVkZYCy.cjs';
3
- export { c as AGENT_TOOL_BRAND, d as AgentDeps, F as FunctionalTool, e as delegateToolName, p as provideAgentTool, u as utcDay } from './agent-deps.factory-DpVkZYCy.cjs';
4
- import { AgentRunner, AgentStore, QuotaStore, Actor, PageContext, ThreadSummary, ThreadDetail, QuotaView, ToolRegistry, AgentRegistry, PromptContributor, AgentRunInput, Decision, TokenStreamSink, SinkWriter, QuotaState, ActorResolver } from '@dudousxd/nestjs-agent-core';
1
+ import { DynamicModule, OnModuleInit, Type, OnApplicationBootstrap } from '@nestjs/common';
2
+ import { a as AgentModuleOptions, b as AgentModuleAsyncOptions, A as AgentDepsFactory } from './agent-deps.factory-BM_RB6br.cjs';
3
+ export { c as AGENT_TOOL_BRAND, d as AgentAttachmentsOptions, e as AgentDeps, F as FunctionalTool, f as delegateToolName, p as provideAgentTool, u as utcDay } from './agent-deps.factory-BM_RB6br.cjs';
4
+ import { AgentRunner, AgentStore, QuotaStore, Actor, MessageAttachment, PageContext, ThreadSummary, ThreadDetail, UpdateThreadInput, QuotaView, ActorResolver, AttachmentStagingStore, ToolRegistry, AgentRegistry, PromptContributor, AgentRunInput, Decision, TokenStreamSink, SinkWriter, QuotaState } from '@dudousxd/nestjs-agent-core';
5
5
  export * from '@dudousxd/nestjs-agent-core';
6
+ import { Request } from 'express';
6
7
  import { StandardSchemaV1 } from '@standard-schema/spec';
7
8
  import { DiscoveryService, MetadataScanner } from '@nestjs/core';
8
9
 
@@ -16,6 +17,8 @@ interface ChatParams {
16
17
  message: string;
17
18
  threadId?: string;
18
19
  agentName?: string;
20
+ /** Files attached to this message (image/PDF) for a vision-capable model. */
21
+ attachments?: MessageAttachment[];
19
22
  pageContext?: PageContext;
20
23
  /** Re-run the last exchange instead of adding a new message. Requires an existing `threadId`. */
21
24
  regenerate?: boolean;
@@ -44,7 +47,24 @@ declare class AgentService {
44
47
  getThread(actor: Actor, threadId: string): Promise<ThreadDetail | null>;
45
48
  deleteThread(actor: Actor, threadId: string): Promise<void>;
46
49
  forkThread(actor: Actor, threadId: string, fromMessageId: string): Promise<ThreadSummary>;
50
+ /** Kept for source compatibility — a thin wrapper over the more general `updateThread`. */
47
51
  renameThread(actor: Actor, threadId: string, title: string): Promise<void>;
52
+ /**
53
+ * Rename a thread and/or set its default agent. Title-only patches work against ANY store (via
54
+ * the required `setTitle`); a `defaultAgent` change requires the bound store to implement the
55
+ * optional `updateThread` — 501 with a clear message when it doesn't, rather than silently
56
+ * dropping the field.
57
+ */
58
+ updateThread(actor: Actor, threadId: string, patch: UpdateThreadInput): Promise<void>;
59
+ private validateTitle;
60
+ /**
61
+ * Agent-selection precedence for a `chat()` call with no explicit `agentName`: the thread's own
62
+ * `defaultAgent` (if the thread exists and one is set) wins over the module's configured default.
63
+ * Skips the thread lookup entirely when the caller already named an agent or there's no thread yet.
64
+ */
65
+ private resolveAgentName;
66
+ private toSummaryView;
67
+ private toDetailView;
48
68
  promoteThread(actor: Actor, threadId: string): Promise<void>;
49
69
  /**
50
70
  * Drop a message and everything after it — the "edit and resend" / "delete from here" primitive.
@@ -74,6 +94,34 @@ declare class AgentService {
74
94
  private assertOwnsActiveStream;
75
95
  }
76
96
 
97
+ /** Default per-file size cap when `AgentModuleOptions.attachments.maxBytes` is omitted (20 MiB). */
98
+ declare const DEFAULT_MAX_ATTACHMENT_BYTES: number;
99
+ /**
100
+ * Default allowlist: what multimodal model providers commonly accept as native image/file parts.
101
+ */
102
+ declare const DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES: readonly string[];
103
+ /**
104
+ * Optional `POST /agent/attachments` upload surface — mounted only when `AgentModuleOptions
105
+ * .attachments.upload` (or the async config's `attachmentsUpload`) is `true` (see `agent.module.ts`).
106
+ * Multipart single file field `'file'`, buffered in memory (no disk write — `FileInterceptor`'s
107
+ * default storage), validated against the configured size cap + content-type allowlist, then handed
108
+ * to the bound {@link AttachmentStagingStore} to persist and turn into a model-fetchable URL.
109
+ */
110
+ declare class AttachmentsController implements OnModuleInit {
111
+ private readonly options;
112
+ private readonly actorResolver;
113
+ private readonly staging;
114
+ constructor(options: AgentModuleOptions, actorResolver: ActorResolver, staging: AttachmentStagingStore | undefined);
115
+ /**
116
+ * `attachments.upload: true` is what mounts this controller at all (see `agent.module.ts`), so by
117
+ * the time an instance exists the host clearly intends uploads to work. Fail boot loudly rather
118
+ * than mounting a controller that would 501 on every single request because nobody bound
119
+ * `AGENT_ATTACHMENT_STAGING`.
120
+ */
121
+ onModuleInit(): void;
122
+ upload(req: Request, file: Express.Multer.File | undefined): Promise<MessageAttachment>;
123
+ }
124
+
77
125
  declare const AI_TOOL_METADATA: unique symbol;
78
126
  interface AiToolOptions {
79
127
  name: string;
@@ -284,4 +332,4 @@ declare class HeaderActorResolver implements ActorResolver {
284
332
  resolve(req: unknown): Actor;
285
333
  }
286
334
 
287
- export { AGENT_METADATA, AI_TOOL_METADATA, Agent, AgentDepsFactory, AgentDiscoveryService, AgentModule, AgentModuleAsyncOptions, AgentModuleOptions, type AgentOptions, AgentService, AiTool, AiToolDiscoveryService, type AiToolOptions, type ChatParams, HeaderActorResolver, InProcessTokenStreamSink, InlineAgentRunner, LedgerQuotaStore, SYSTEM_PROMPT_CONTRIBUTOR_METADATA, SYSTEM_PROMPT_METADATA, SystemPrompt, SystemPromptContributor, readAgentMetadata, readAiToolMetadata };
335
+ export { AGENT_METADATA, AI_TOOL_METADATA, Agent, AgentDepsFactory, AgentDiscoveryService, AgentModule, AgentModuleAsyncOptions, AgentModuleOptions, type AgentOptions, AgentService, AiTool, AiToolDiscoveryService, type AiToolOptions, AttachmentsController, type ChatParams, DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, DEFAULT_MAX_ATTACHMENT_BYTES, HeaderActorResolver, InProcessTokenStreamSink, InlineAgentRunner, LedgerQuotaStore, SYSTEM_PROMPT_CONTRIBUTOR_METADATA, SYSTEM_PROMPT_METADATA, SystemPrompt, SystemPromptContributor, readAgentMetadata, readAiToolMetadata };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { DynamicModule, Type, OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
2
- import { a as AgentModuleOptions, b as AgentModuleAsyncOptions, A as AgentDepsFactory } from './agent-deps.factory-DpVkZYCy.js';
3
- export { c as AGENT_TOOL_BRAND, d as AgentDeps, F as FunctionalTool, e as delegateToolName, p as provideAgentTool, u as utcDay } from './agent-deps.factory-DpVkZYCy.js';
4
- import { AgentRunner, AgentStore, QuotaStore, Actor, PageContext, ThreadSummary, ThreadDetail, QuotaView, ToolRegistry, AgentRegistry, PromptContributor, AgentRunInput, Decision, TokenStreamSink, SinkWriter, QuotaState, ActorResolver } from '@dudousxd/nestjs-agent-core';
1
+ import { DynamicModule, OnModuleInit, Type, OnApplicationBootstrap } from '@nestjs/common';
2
+ import { a as AgentModuleOptions, b as AgentModuleAsyncOptions, A as AgentDepsFactory } from './agent-deps.factory-BM_RB6br.js';
3
+ export { c as AGENT_TOOL_BRAND, d as AgentAttachmentsOptions, e as AgentDeps, F as FunctionalTool, f as delegateToolName, p as provideAgentTool, u as utcDay } from './agent-deps.factory-BM_RB6br.js';
4
+ import { AgentRunner, AgentStore, QuotaStore, Actor, MessageAttachment, PageContext, ThreadSummary, ThreadDetail, UpdateThreadInput, QuotaView, ActorResolver, AttachmentStagingStore, ToolRegistry, AgentRegistry, PromptContributor, AgentRunInput, Decision, TokenStreamSink, SinkWriter, QuotaState } from '@dudousxd/nestjs-agent-core';
5
5
  export * from '@dudousxd/nestjs-agent-core';
6
+ import { Request } from 'express';
6
7
  import { StandardSchemaV1 } from '@standard-schema/spec';
7
8
  import { DiscoveryService, MetadataScanner } from '@nestjs/core';
8
9
 
@@ -16,6 +17,8 @@ interface ChatParams {
16
17
  message: string;
17
18
  threadId?: string;
18
19
  agentName?: string;
20
+ /** Files attached to this message (image/PDF) for a vision-capable model. */
21
+ attachments?: MessageAttachment[];
19
22
  pageContext?: PageContext;
20
23
  /** Re-run the last exchange instead of adding a new message. Requires an existing `threadId`. */
21
24
  regenerate?: boolean;
@@ -44,7 +47,24 @@ declare class AgentService {
44
47
  getThread(actor: Actor, threadId: string): Promise<ThreadDetail | null>;
45
48
  deleteThread(actor: Actor, threadId: string): Promise<void>;
46
49
  forkThread(actor: Actor, threadId: string, fromMessageId: string): Promise<ThreadSummary>;
50
+ /** Kept for source compatibility — a thin wrapper over the more general `updateThread`. */
47
51
  renameThread(actor: Actor, threadId: string, title: string): Promise<void>;
52
+ /**
53
+ * Rename a thread and/or set its default agent. Title-only patches work against ANY store (via
54
+ * the required `setTitle`); a `defaultAgent` change requires the bound store to implement the
55
+ * optional `updateThread` — 501 with a clear message when it doesn't, rather than silently
56
+ * dropping the field.
57
+ */
58
+ updateThread(actor: Actor, threadId: string, patch: UpdateThreadInput): Promise<void>;
59
+ private validateTitle;
60
+ /**
61
+ * Agent-selection precedence for a `chat()` call with no explicit `agentName`: the thread's own
62
+ * `defaultAgent` (if the thread exists and one is set) wins over the module's configured default.
63
+ * Skips the thread lookup entirely when the caller already named an agent or there's no thread yet.
64
+ */
65
+ private resolveAgentName;
66
+ private toSummaryView;
67
+ private toDetailView;
48
68
  promoteThread(actor: Actor, threadId: string): Promise<void>;
49
69
  /**
50
70
  * Drop a message and everything after it — the "edit and resend" / "delete from here" primitive.
@@ -74,6 +94,34 @@ declare class AgentService {
74
94
  private assertOwnsActiveStream;
75
95
  }
76
96
 
97
+ /** Default per-file size cap when `AgentModuleOptions.attachments.maxBytes` is omitted (20 MiB). */
98
+ declare const DEFAULT_MAX_ATTACHMENT_BYTES: number;
99
+ /**
100
+ * Default allowlist: what multimodal model providers commonly accept as native image/file parts.
101
+ */
102
+ declare const DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES: readonly string[];
103
+ /**
104
+ * Optional `POST /agent/attachments` upload surface — mounted only when `AgentModuleOptions
105
+ * .attachments.upload` (or the async config's `attachmentsUpload`) is `true` (see `agent.module.ts`).
106
+ * Multipart single file field `'file'`, buffered in memory (no disk write — `FileInterceptor`'s
107
+ * default storage), validated against the configured size cap + content-type allowlist, then handed
108
+ * to the bound {@link AttachmentStagingStore} to persist and turn into a model-fetchable URL.
109
+ */
110
+ declare class AttachmentsController implements OnModuleInit {
111
+ private readonly options;
112
+ private readonly actorResolver;
113
+ private readonly staging;
114
+ constructor(options: AgentModuleOptions, actorResolver: ActorResolver, staging: AttachmentStagingStore | undefined);
115
+ /**
116
+ * `attachments.upload: true` is what mounts this controller at all (see `agent.module.ts`), so by
117
+ * the time an instance exists the host clearly intends uploads to work. Fail boot loudly rather
118
+ * than mounting a controller that would 501 on every single request because nobody bound
119
+ * `AGENT_ATTACHMENT_STAGING`.
120
+ */
121
+ onModuleInit(): void;
122
+ upload(req: Request, file: Express.Multer.File | undefined): Promise<MessageAttachment>;
123
+ }
124
+
77
125
  declare const AI_TOOL_METADATA: unique symbol;
78
126
  interface AiToolOptions {
79
127
  name: string;
@@ -284,4 +332,4 @@ declare class HeaderActorResolver implements ActorResolver {
284
332
  resolve(req: unknown): Actor;
285
333
  }
286
334
 
287
- export { AGENT_METADATA, AI_TOOL_METADATA, Agent, AgentDepsFactory, AgentDiscoveryService, AgentModule, AgentModuleAsyncOptions, AgentModuleOptions, type AgentOptions, AgentService, AiTool, AiToolDiscoveryService, type AiToolOptions, type ChatParams, HeaderActorResolver, InProcessTokenStreamSink, InlineAgentRunner, LedgerQuotaStore, SYSTEM_PROMPT_CONTRIBUTOR_METADATA, SYSTEM_PROMPT_METADATA, SystemPrompt, SystemPromptContributor, readAgentMetadata, readAiToolMetadata };
335
+ export { AGENT_METADATA, AI_TOOL_METADATA, Agent, AgentDepsFactory, AgentDiscoveryService, AgentModule, AgentModuleAsyncOptions, AgentModuleOptions, type AgentOptions, AgentService, AiTool, AiToolDiscoveryService, type AiToolOptions, AttachmentsController, type ChatParams, DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, DEFAULT_MAX_ATTACHMENT_BYTES, HeaderActorResolver, InProcessTokenStreamSink, InlineAgentRunner, LedgerQuotaStore, SYSTEM_PROMPT_CONTRIBUTOR_METADATA, SYSTEM_PROMPT_METADATA, SystemPrompt, SystemPromptContributor, readAgentMetadata, readAiToolMetadata };