@mgvdev/nestjs-ai 0.1.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/LICENSE +21 -0
- package/README.md +655 -0
- package/dist/ai-module-options.interface-B5X4AFLC.d.cts +192 -0
- package/dist/ai-module-options.interface-Ca6y_MY2.d.ts +192 -0
- package/dist/conversation-store.interface-CtQY-qcc.d.cts +30 -0
- package/dist/conversation-store.interface-CtQY-qcc.d.ts +30 -0
- package/dist/index.cjs +3209 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1441 -0
- package/dist/index.d.ts +1441 -0
- package/dist/index.js +3163 -0
- package/dist/index.js.map +1 -0
- package/dist/stream-to-socket-fJphU0WN.d.cts +47 -0
- package/dist/stream-to-socket-fJphU0WN.d.ts +47 -0
- package/dist/testing.cjs +2395 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +46 -0
- package/dist/testing.d.ts +46 -0
- package/dist/testing.js +2391 -0
- package/dist/testing.js.map +1 -0
- package/dist/typeorm.cjs +115 -0
- package/dist/typeorm.cjs.map +1 -0
- package/dist/typeorm.d.cts +44 -0
- package/dist/typeorm.d.ts +44 -0
- package/dist/typeorm.js +113 -0
- package/dist/typeorm.js.map +1 -0
- package/dist/websocket.cjs +154 -0
- package/dist/websocket.cjs.map +1 -0
- package/dist/websocket.d.cts +25 -0
- package/dist/websocket.d.ts +25 -0
- package/dist/websocket.js +152 -0
- package/dist/websocket.js.map +1 -0
- package/documentation/README.md +44 -0
- package/documentation/agents-and-tools.md +102 -0
- package/documentation/api-reference.md +117 -0
- package/documentation/configuration.md +87 -0
- package/documentation/content-safety.md +51 -0
- package/documentation/embeddings-and-rag.md +105 -0
- package/documentation/evals-and-testing.md +56 -0
- package/documentation/getting-started.md +96 -0
- package/documentation/guardrails-events-telemetry.md +72 -0
- package/documentation/jobs-and-realtime.md +69 -0
- package/documentation/memory.md +101 -0
- package/documentation/multimodal.md +49 -0
- package/documentation/orchestration-and-mcp.md +68 -0
- package/documentation/prompts.md +51 -0
- package/documentation/reliability.md +90 -0
- package/documentation/structured-output-and-streaming.md +81 -0
- package/package.json +146 -0
- package/skill/nestjs-ai/SKILL.md +154 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import * as _nestjs_common from '@nestjs/common';
|
|
2
|
+
import { Type, ModuleMetadata } from '@nestjs/common';
|
|
3
|
+
import { C as ConversationStore } from './conversation-store.interface-CtQY-qcc.cjs';
|
|
4
|
+
|
|
5
|
+
/** Price per 1M tokens, in USD. */
|
|
6
|
+
interface ModelPricing {
|
|
7
|
+
input: number;
|
|
8
|
+
output: number;
|
|
9
|
+
}
|
|
10
|
+
/** Maps a bare model id (no provider prefix) to its pricing. */
|
|
11
|
+
type PricingTable = Record<string, ModelPricing>;
|
|
12
|
+
/** Minimal usage shape needed for cost. */
|
|
13
|
+
interface UsageLike {
|
|
14
|
+
inputTokens?: number;
|
|
15
|
+
outputTokens?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Default USD pricing per 1M tokens for common models. Override or extend via
|
|
19
|
+
* `AiModule.forRoot({ pricing })`. Prices are indicative — verify against your
|
|
20
|
+
* provider's current rates.
|
|
21
|
+
*/
|
|
22
|
+
declare const DEFAULT_PRICING: PricingTable;
|
|
23
|
+
/** Strips a `"provider:"` prefix from a model id. */
|
|
24
|
+
declare function bareModelId(modelId: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Computes the USD cost of a usage record for a model. Returns 0 when the model
|
|
27
|
+
* is not in the pricing table.
|
|
28
|
+
*/
|
|
29
|
+
declare function costOf(usage: UsageLike, modelId: string, pricing?: PricingTable): number;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A named, optionally versioned prompt template.
|
|
33
|
+
*/
|
|
34
|
+
interface PromptDefinition {
|
|
35
|
+
/** Unique name used to look the prompt up. */
|
|
36
|
+
name: string;
|
|
37
|
+
/** Optional version; when omitted the latest registered version is used. */
|
|
38
|
+
version?: string;
|
|
39
|
+
/** Template body with `{{variable}}` placeholders. */
|
|
40
|
+
template: string;
|
|
41
|
+
/** Optional human-readable description. */
|
|
42
|
+
description?: string;
|
|
43
|
+
}
|
|
44
|
+
/** Reference to a registered prompt for rendering. */
|
|
45
|
+
interface PromptRef {
|
|
46
|
+
name: string;
|
|
47
|
+
vars?: Record<string, unknown>;
|
|
48
|
+
version?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Replaces `{{var}}` placeholders in `template` with values from `vars`.
|
|
52
|
+
* Throws if a referenced variable is missing, to catch typos early.
|
|
53
|
+
*/
|
|
54
|
+
declare function interpolate(template: string, vars?: Record<string, unknown>): string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Ways to supply a custom conversation store: a class, or a class/factory/value
|
|
58
|
+
* provider (registered under the internal store token).
|
|
59
|
+
*/
|
|
60
|
+
type ConversationStoreProvider = Type<ConversationStore> | {
|
|
61
|
+
useClass: Type<ConversationStore>;
|
|
62
|
+
} | {
|
|
63
|
+
useFactory: (...args: any[]) => ConversationStore | Promise<ConversationStore>;
|
|
64
|
+
inject?: any[];
|
|
65
|
+
} | {
|
|
66
|
+
useValue: ConversationStore;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Per-provider configuration. Every field is optional so a provider can also
|
|
70
|
+
* rely on its SDK's implicit environment variables (e.g. `OPENAI_API_KEY`).
|
|
71
|
+
*/
|
|
72
|
+
interface ProviderConfig {
|
|
73
|
+
apiKey?: string;
|
|
74
|
+
baseURL?: string;
|
|
75
|
+
/** Extra headers forwarded on every request to this provider. */
|
|
76
|
+
headers?: Record<string, string>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Providers the module knows how to instantiate out of the box. The matching
|
|
80
|
+
* `@ai-sdk/*` package must be installed for a configured provider to resolve.
|
|
81
|
+
*/
|
|
82
|
+
interface ProvidersConfig {
|
|
83
|
+
openai?: ProviderConfig;
|
|
84
|
+
anthropic?: ProviderConfig;
|
|
85
|
+
google?: ProviderConfig;
|
|
86
|
+
}
|
|
87
|
+
interface AiModuleOptions {
|
|
88
|
+
/** Provider credentials keyed by provider name. */
|
|
89
|
+
providers?: ProvidersConfig;
|
|
90
|
+
/**
|
|
91
|
+
* Model used when a call does not specify one, e.g. `"openai:gpt-4o"` or a
|
|
92
|
+
* bare `"gpt-4o"` when a single provider is configured. An array configures a
|
|
93
|
+
* fallback chain (each tried in order).
|
|
94
|
+
*/
|
|
95
|
+
defaultModel?: string | string[];
|
|
96
|
+
/** Default retry count forwarded to generate/stream calls. */
|
|
97
|
+
maxRetries?: number;
|
|
98
|
+
/** Default embedding model, e.g. `"openai:text-embedding-3-small"`. */
|
|
99
|
+
defaultEmbeddingModel?: string;
|
|
100
|
+
/** Default image model, e.g. `"openai:dall-e-3"`. */
|
|
101
|
+
defaultImageModel?: string;
|
|
102
|
+
/** Default speech (text-to-speech) model, e.g. `"openai:tts-1"`. */
|
|
103
|
+
defaultSpeechModel?: string;
|
|
104
|
+
/** Default transcription model, e.g. `"openai:whisper-1"`. */
|
|
105
|
+
defaultTranscriptionModel?: string;
|
|
106
|
+
/** Default maximum tool-calling steps for agent runs. */
|
|
107
|
+
defaultMaxSteps?: number;
|
|
108
|
+
/**
|
|
109
|
+
* OpenTelemetry settings forwarded to the AI SDK's `experimental_telemetry`.
|
|
110
|
+
* Requires an OTel setup in the host app to actually export spans.
|
|
111
|
+
*/
|
|
112
|
+
telemetry?: {
|
|
113
|
+
isEnabled?: boolean;
|
|
114
|
+
functionId?: string;
|
|
115
|
+
};
|
|
116
|
+
/** Prompt templates to register at startup. */
|
|
117
|
+
prompts?: PromptDefinition[];
|
|
118
|
+
/** Guardrail provider classes to register (also discovered via `@Guardrail`). */
|
|
119
|
+
guardrails?: _nestjs_common.Type<any>[];
|
|
120
|
+
/** Custom vector store provider (defaults to `InMemoryVectorStore`). */
|
|
121
|
+
vectorStore?: _nestjs_common.Type<any> | {
|
|
122
|
+
useClass?: _nestjs_common.Type<any>;
|
|
123
|
+
useFactory?: (...args: any[]) => any;
|
|
124
|
+
useValue?: any;
|
|
125
|
+
inject?: any[];
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Response/embedding cache. When set, resolved language models are wrapped
|
|
129
|
+
* with a caching middleware and embeddings are cached.
|
|
130
|
+
*/
|
|
131
|
+
cache?: _nestjs_common.Type<any> | {
|
|
132
|
+
useClass?: _nestjs_common.Type<any>;
|
|
133
|
+
useFactory?: (...args: any[]) => any;
|
|
134
|
+
useValue?: any;
|
|
135
|
+
inject?: any[];
|
|
136
|
+
};
|
|
137
|
+
/** TTL (ms) for cached generations/embeddings. Default: no expiry. */
|
|
138
|
+
cacheTtlMs?: number;
|
|
139
|
+
/** Per-model USD pricing (per 1M tokens) for cost tracking. */
|
|
140
|
+
pricing?: PricingTable;
|
|
141
|
+
/** Max accumulated USD cost per conversation before runs are blocked. */
|
|
142
|
+
maxCostPerConversation?: number;
|
|
143
|
+
/** Rate limiter for throttling agent runs. */
|
|
144
|
+
rateLimiter?: _nestjs_common.Type<any> | {
|
|
145
|
+
useClass?: _nestjs_common.Type<any>;
|
|
146
|
+
useFactory?: (...args: any[]) => any;
|
|
147
|
+
useValue?: any;
|
|
148
|
+
inject?: any[];
|
|
149
|
+
};
|
|
150
|
+
/** Reranking model id (e.g. `"cohere:rerank-v3.5"`) for `ModelReranker`. */
|
|
151
|
+
rerankingModel?: string;
|
|
152
|
+
/** Approval gate for tools flagged `requiresApproval` (defaults to auto-approve). */
|
|
153
|
+
approvalGate?: _nestjs_common.Type<any> | {
|
|
154
|
+
useClass?: _nestjs_common.Type<any>;
|
|
155
|
+
useFactory?: (...args: any[]) => any;
|
|
156
|
+
useValue?: any;
|
|
157
|
+
inject?: any[];
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Optional conversation store provider. When omitted an in-memory store is
|
|
161
|
+
* registered. Use `useClass`/`useFactory`/`useValue` to plug a custom store.
|
|
162
|
+
*/
|
|
163
|
+
conversationStore?: ConversationStoreProvider;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Async configuration for `AiModule.forRootAsync`, allowing the options to be
|
|
167
|
+
* built from injected dependencies such as `ConfigService`.
|
|
168
|
+
*/
|
|
169
|
+
interface AiModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
170
|
+
useFactory: (...args: any[]) => Promise<AiModuleOptions> | AiModuleOptions;
|
|
171
|
+
inject?: any[];
|
|
172
|
+
/**
|
|
173
|
+
* Optional conversation store provider registered alongside the async
|
|
174
|
+
* options (the factory result's `conversationStore` is ignored for DI
|
|
175
|
+
* reasons — declare it here instead).
|
|
176
|
+
*/
|
|
177
|
+
conversationStore?: ConversationStoreProvider;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Classes registered via `AiModule.forFeature` for convenience so users do not
|
|
181
|
+
* have to wire agents/tools into their own module's `providers` array.
|
|
182
|
+
*/
|
|
183
|
+
interface AiFeatureOptions {
|
|
184
|
+
agents?: Type<any>[];
|
|
185
|
+
tools?: Type<any>[];
|
|
186
|
+
/** Guardrail provider classes to register for discovery. */
|
|
187
|
+
guardrails?: Type<any>[];
|
|
188
|
+
/** Prompt templates to register at startup. */
|
|
189
|
+
prompts?: PromptDefinition[];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export { type AiModuleOptions as A, type ConversationStoreProvider as C, DEFAULT_PRICING as D, type ModelPricing as M, type PromptRef as P, type UsageLike as U, type AiModuleAsyncOptions as a, type AiFeatureOptions as b, type PromptDefinition as c, type PricingTable as d, type ProviderConfig as e, type ProvidersConfig as f, bareModelId as g, costOf as h, interpolate as i };
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import * as _nestjs_common from '@nestjs/common';
|
|
2
|
+
import { Type, ModuleMetadata } from '@nestjs/common';
|
|
3
|
+
import { C as ConversationStore } from './conversation-store.interface-CtQY-qcc.js';
|
|
4
|
+
|
|
5
|
+
/** Price per 1M tokens, in USD. */
|
|
6
|
+
interface ModelPricing {
|
|
7
|
+
input: number;
|
|
8
|
+
output: number;
|
|
9
|
+
}
|
|
10
|
+
/** Maps a bare model id (no provider prefix) to its pricing. */
|
|
11
|
+
type PricingTable = Record<string, ModelPricing>;
|
|
12
|
+
/** Minimal usage shape needed for cost. */
|
|
13
|
+
interface UsageLike {
|
|
14
|
+
inputTokens?: number;
|
|
15
|
+
outputTokens?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Default USD pricing per 1M tokens for common models. Override or extend via
|
|
19
|
+
* `AiModule.forRoot({ pricing })`. Prices are indicative — verify against your
|
|
20
|
+
* provider's current rates.
|
|
21
|
+
*/
|
|
22
|
+
declare const DEFAULT_PRICING: PricingTable;
|
|
23
|
+
/** Strips a `"provider:"` prefix from a model id. */
|
|
24
|
+
declare function bareModelId(modelId: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Computes the USD cost of a usage record for a model. Returns 0 when the model
|
|
27
|
+
* is not in the pricing table.
|
|
28
|
+
*/
|
|
29
|
+
declare function costOf(usage: UsageLike, modelId: string, pricing?: PricingTable): number;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A named, optionally versioned prompt template.
|
|
33
|
+
*/
|
|
34
|
+
interface PromptDefinition {
|
|
35
|
+
/** Unique name used to look the prompt up. */
|
|
36
|
+
name: string;
|
|
37
|
+
/** Optional version; when omitted the latest registered version is used. */
|
|
38
|
+
version?: string;
|
|
39
|
+
/** Template body with `{{variable}}` placeholders. */
|
|
40
|
+
template: string;
|
|
41
|
+
/** Optional human-readable description. */
|
|
42
|
+
description?: string;
|
|
43
|
+
}
|
|
44
|
+
/** Reference to a registered prompt for rendering. */
|
|
45
|
+
interface PromptRef {
|
|
46
|
+
name: string;
|
|
47
|
+
vars?: Record<string, unknown>;
|
|
48
|
+
version?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Replaces `{{var}}` placeholders in `template` with values from `vars`.
|
|
52
|
+
* Throws if a referenced variable is missing, to catch typos early.
|
|
53
|
+
*/
|
|
54
|
+
declare function interpolate(template: string, vars?: Record<string, unknown>): string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Ways to supply a custom conversation store: a class, or a class/factory/value
|
|
58
|
+
* provider (registered under the internal store token).
|
|
59
|
+
*/
|
|
60
|
+
type ConversationStoreProvider = Type<ConversationStore> | {
|
|
61
|
+
useClass: Type<ConversationStore>;
|
|
62
|
+
} | {
|
|
63
|
+
useFactory: (...args: any[]) => ConversationStore | Promise<ConversationStore>;
|
|
64
|
+
inject?: any[];
|
|
65
|
+
} | {
|
|
66
|
+
useValue: ConversationStore;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Per-provider configuration. Every field is optional so a provider can also
|
|
70
|
+
* rely on its SDK's implicit environment variables (e.g. `OPENAI_API_KEY`).
|
|
71
|
+
*/
|
|
72
|
+
interface ProviderConfig {
|
|
73
|
+
apiKey?: string;
|
|
74
|
+
baseURL?: string;
|
|
75
|
+
/** Extra headers forwarded on every request to this provider. */
|
|
76
|
+
headers?: Record<string, string>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Providers the module knows how to instantiate out of the box. The matching
|
|
80
|
+
* `@ai-sdk/*` package must be installed for a configured provider to resolve.
|
|
81
|
+
*/
|
|
82
|
+
interface ProvidersConfig {
|
|
83
|
+
openai?: ProviderConfig;
|
|
84
|
+
anthropic?: ProviderConfig;
|
|
85
|
+
google?: ProviderConfig;
|
|
86
|
+
}
|
|
87
|
+
interface AiModuleOptions {
|
|
88
|
+
/** Provider credentials keyed by provider name. */
|
|
89
|
+
providers?: ProvidersConfig;
|
|
90
|
+
/**
|
|
91
|
+
* Model used when a call does not specify one, e.g. `"openai:gpt-4o"` or a
|
|
92
|
+
* bare `"gpt-4o"` when a single provider is configured. An array configures a
|
|
93
|
+
* fallback chain (each tried in order).
|
|
94
|
+
*/
|
|
95
|
+
defaultModel?: string | string[];
|
|
96
|
+
/** Default retry count forwarded to generate/stream calls. */
|
|
97
|
+
maxRetries?: number;
|
|
98
|
+
/** Default embedding model, e.g. `"openai:text-embedding-3-small"`. */
|
|
99
|
+
defaultEmbeddingModel?: string;
|
|
100
|
+
/** Default image model, e.g. `"openai:dall-e-3"`. */
|
|
101
|
+
defaultImageModel?: string;
|
|
102
|
+
/** Default speech (text-to-speech) model, e.g. `"openai:tts-1"`. */
|
|
103
|
+
defaultSpeechModel?: string;
|
|
104
|
+
/** Default transcription model, e.g. `"openai:whisper-1"`. */
|
|
105
|
+
defaultTranscriptionModel?: string;
|
|
106
|
+
/** Default maximum tool-calling steps for agent runs. */
|
|
107
|
+
defaultMaxSteps?: number;
|
|
108
|
+
/**
|
|
109
|
+
* OpenTelemetry settings forwarded to the AI SDK's `experimental_telemetry`.
|
|
110
|
+
* Requires an OTel setup in the host app to actually export spans.
|
|
111
|
+
*/
|
|
112
|
+
telemetry?: {
|
|
113
|
+
isEnabled?: boolean;
|
|
114
|
+
functionId?: string;
|
|
115
|
+
};
|
|
116
|
+
/** Prompt templates to register at startup. */
|
|
117
|
+
prompts?: PromptDefinition[];
|
|
118
|
+
/** Guardrail provider classes to register (also discovered via `@Guardrail`). */
|
|
119
|
+
guardrails?: _nestjs_common.Type<any>[];
|
|
120
|
+
/** Custom vector store provider (defaults to `InMemoryVectorStore`). */
|
|
121
|
+
vectorStore?: _nestjs_common.Type<any> | {
|
|
122
|
+
useClass?: _nestjs_common.Type<any>;
|
|
123
|
+
useFactory?: (...args: any[]) => any;
|
|
124
|
+
useValue?: any;
|
|
125
|
+
inject?: any[];
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Response/embedding cache. When set, resolved language models are wrapped
|
|
129
|
+
* with a caching middleware and embeddings are cached.
|
|
130
|
+
*/
|
|
131
|
+
cache?: _nestjs_common.Type<any> | {
|
|
132
|
+
useClass?: _nestjs_common.Type<any>;
|
|
133
|
+
useFactory?: (...args: any[]) => any;
|
|
134
|
+
useValue?: any;
|
|
135
|
+
inject?: any[];
|
|
136
|
+
};
|
|
137
|
+
/** TTL (ms) for cached generations/embeddings. Default: no expiry. */
|
|
138
|
+
cacheTtlMs?: number;
|
|
139
|
+
/** Per-model USD pricing (per 1M tokens) for cost tracking. */
|
|
140
|
+
pricing?: PricingTable;
|
|
141
|
+
/** Max accumulated USD cost per conversation before runs are blocked. */
|
|
142
|
+
maxCostPerConversation?: number;
|
|
143
|
+
/** Rate limiter for throttling agent runs. */
|
|
144
|
+
rateLimiter?: _nestjs_common.Type<any> | {
|
|
145
|
+
useClass?: _nestjs_common.Type<any>;
|
|
146
|
+
useFactory?: (...args: any[]) => any;
|
|
147
|
+
useValue?: any;
|
|
148
|
+
inject?: any[];
|
|
149
|
+
};
|
|
150
|
+
/** Reranking model id (e.g. `"cohere:rerank-v3.5"`) for `ModelReranker`. */
|
|
151
|
+
rerankingModel?: string;
|
|
152
|
+
/** Approval gate for tools flagged `requiresApproval` (defaults to auto-approve). */
|
|
153
|
+
approvalGate?: _nestjs_common.Type<any> | {
|
|
154
|
+
useClass?: _nestjs_common.Type<any>;
|
|
155
|
+
useFactory?: (...args: any[]) => any;
|
|
156
|
+
useValue?: any;
|
|
157
|
+
inject?: any[];
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Optional conversation store provider. When omitted an in-memory store is
|
|
161
|
+
* registered. Use `useClass`/`useFactory`/`useValue` to plug a custom store.
|
|
162
|
+
*/
|
|
163
|
+
conversationStore?: ConversationStoreProvider;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Async configuration for `AiModule.forRootAsync`, allowing the options to be
|
|
167
|
+
* built from injected dependencies such as `ConfigService`.
|
|
168
|
+
*/
|
|
169
|
+
interface AiModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
170
|
+
useFactory: (...args: any[]) => Promise<AiModuleOptions> | AiModuleOptions;
|
|
171
|
+
inject?: any[];
|
|
172
|
+
/**
|
|
173
|
+
* Optional conversation store provider registered alongside the async
|
|
174
|
+
* options (the factory result's `conversationStore` is ignored for DI
|
|
175
|
+
* reasons — declare it here instead).
|
|
176
|
+
*/
|
|
177
|
+
conversationStore?: ConversationStoreProvider;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Classes registered via `AiModule.forFeature` for convenience so users do not
|
|
181
|
+
* have to wire agents/tools into their own module's `providers` array.
|
|
182
|
+
*/
|
|
183
|
+
interface AiFeatureOptions {
|
|
184
|
+
agents?: Type<any>[];
|
|
185
|
+
tools?: Type<any>[];
|
|
186
|
+
/** Guardrail provider classes to register for discovery. */
|
|
187
|
+
guardrails?: Type<any>[];
|
|
188
|
+
/** Prompt templates to register at startup. */
|
|
189
|
+
prompts?: PromptDefinition[];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export { type AiModuleOptions as A, type ConversationStoreProvider as C, DEFAULT_PRICING as D, type ModelPricing as M, type PromptRef as P, type UsageLike as U, type AiModuleAsyncOptions as a, type AiFeatureOptions as b, type PromptDefinition as c, type PricingTable as d, type ProviderConfig as e, type ProvidersConfig as f, bareModelId as g, costOf as h, interpolate as i };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ModelMessage } from 'ai';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A single conversation message, re-exported from the AI SDK so consumers of
|
|
5
|
+
* this library never need to import `ai` types directly.
|
|
6
|
+
*/
|
|
7
|
+
type AiMessage = ModelMessage;
|
|
8
|
+
/**
|
|
9
|
+
* The input accepted by agent `.run()` / `.stream()` and the raw facade: either
|
|
10
|
+
* a plain user string or an explicit list of messages.
|
|
11
|
+
*/
|
|
12
|
+
type AiInput = string | AiMessage[];
|
|
13
|
+
/** Normalizes a string or message list into a message array. */
|
|
14
|
+
declare function toMessages(input: AiInput): AiMessage[];
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Persistence contract for conversation history. Implement this interface to
|
|
18
|
+
* back conversations with a database, cache, or any other store, then register
|
|
19
|
+
* it through `AiModule.forRoot({ conversationStore })`.
|
|
20
|
+
*/
|
|
21
|
+
interface ConversationStore {
|
|
22
|
+
/** Returns the ordered messages for a conversation (empty if unknown). */
|
|
23
|
+
load(conversationId: string): Promise<AiMessage[]>;
|
|
24
|
+
/** Appends messages to a conversation, preserving order. */
|
|
25
|
+
append(conversationId: string, messages: AiMessage[]): Promise<void>;
|
|
26
|
+
/** Removes all messages for a conversation. */
|
|
27
|
+
clear(conversationId: string): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { type AiMessage as A, type ConversationStore as C, type AiInput as a, toMessages as t };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ModelMessage } from 'ai';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A single conversation message, re-exported from the AI SDK so consumers of
|
|
5
|
+
* this library never need to import `ai` types directly.
|
|
6
|
+
*/
|
|
7
|
+
type AiMessage = ModelMessage;
|
|
8
|
+
/**
|
|
9
|
+
* The input accepted by agent `.run()` / `.stream()` and the raw facade: either
|
|
10
|
+
* a plain user string or an explicit list of messages.
|
|
11
|
+
*/
|
|
12
|
+
type AiInput = string | AiMessage[];
|
|
13
|
+
/** Normalizes a string or message list into a message array. */
|
|
14
|
+
declare function toMessages(input: AiInput): AiMessage[];
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Persistence contract for conversation history. Implement this interface to
|
|
18
|
+
* back conversations with a database, cache, or any other store, then register
|
|
19
|
+
* it through `AiModule.forRoot({ conversationStore })`.
|
|
20
|
+
*/
|
|
21
|
+
interface ConversationStore {
|
|
22
|
+
/** Returns the ordered messages for a conversation (empty if unknown). */
|
|
23
|
+
load(conversationId: string): Promise<AiMessage[]>;
|
|
24
|
+
/** Appends messages to a conversation, preserving order. */
|
|
25
|
+
append(conversationId: string, messages: AiMessage[]): Promise<void>;
|
|
26
|
+
/** Removes all messages for a conversation. */
|
|
27
|
+
clear(conversationId: string): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { type AiMessage as A, type ConversationStore as C, type AiInput as a, toMessages as t };
|