@breadstone/archipel-mcp 0.0.43 → 0.0.45

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.
Files changed (120) hide show
  1. package/data/guides/ai-text-generation.md +402 -111
  2. package/data/packages/platform-intelligence/api/Class.IntelligenceHealthIndicator.md +5 -5
  3. package/data/packages/platform-intelligence/api/Class.IntelligenceModule.md +26 -2
  4. package/data/packages/platform-intelligence/api/Class.IntelligenceTextGenerator.md +43 -9
  5. package/data/packages/platform-intelligence/api/Class.IntelligenceToolBase.md +93 -0
  6. package/data/packages/platform-intelligence/api/Class.IntelligenceToolRegistry.md +217 -0
  7. package/data/packages/platform-intelligence/api/Function.createAnthropicAdvisor20260301Tool.md +26 -0
  8. package/data/packages/platform-intelligence/api/Function.createAnthropicBash20241022Tool.md +26 -0
  9. package/data/packages/platform-intelligence/api/Function.createAnthropicBash20250124Tool.md +26 -0
  10. package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20250522Tool.md +26 -0
  11. package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20250825Tool.md +26 -0
  12. package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20260120Tool.md +26 -0
  13. package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20241022Tool.md +26 -0
  14. package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20250124Tool.md +26 -0
  15. package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20251124Tool.md +26 -0
  16. package/data/packages/platform-intelligence/api/Function.createAnthropicMemory20250818Tool.md +26 -0
  17. package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20241022Tool.md +26 -0
  18. package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250124Tool.md +26 -0
  19. package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250429Tool.md +26 -0
  20. package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250728Tool.md +26 -0
  21. package/data/packages/platform-intelligence/api/Function.createAnthropicToolSearchBM2520251119Tool.md +26 -0
  22. package/data/packages/platform-intelligence/api/Function.createAnthropicToolSearchRegex20251119Tool.md +26 -0
  23. package/data/packages/platform-intelligence/api/Function.createAnthropicWebFetch20250910Tool.md +26 -0
  24. package/data/packages/platform-intelligence/api/Function.createAnthropicWebFetch20260209Tool.md +26 -0
  25. package/data/packages/platform-intelligence/api/Function.createAnthropicWebSearch20250305Tool.md +26 -0
  26. package/data/packages/platform-intelligence/api/Function.createAnthropicWebSearch20260209Tool.md +26 -0
  27. package/data/packages/platform-intelligence/api/Function.createGoogleCodeExecutionTool.md +26 -0
  28. package/data/packages/platform-intelligence/api/Function.createGoogleEnterpriseWebSearchTool.md +26 -0
  29. package/data/packages/platform-intelligence/api/Function.createGoogleFileSearchTool.md +26 -0
  30. package/data/packages/platform-intelligence/api/Function.createGoogleGoogleMapsTool.md +26 -0
  31. package/data/packages/platform-intelligence/api/Function.createGoogleGoogleSearchTool.md +26 -0
  32. package/data/packages/platform-intelligence/api/Function.createGoogleUrlContextTool.md +26 -0
  33. package/data/packages/platform-intelligence/api/Function.createGoogleVertexRagStoreTool.md +26 -0
  34. package/data/packages/platform-intelligence/api/Function.createGrokCodeExecutionTool.md +26 -0
  35. package/data/packages/platform-intelligence/api/Function.createGrokFileSearchTool.md +26 -0
  36. package/data/packages/platform-intelligence/api/Function.createGrokMcpServerTool.md +26 -0
  37. package/data/packages/platform-intelligence/api/Function.createGrokViewImageTool.md +26 -0
  38. package/data/packages/platform-intelligence/api/Function.createGrokViewXVideoTool.md +26 -0
  39. package/data/packages/platform-intelligence/api/Function.createGrokWebSearchTool.md +26 -0
  40. package/data/packages/platform-intelligence/api/Function.createGrokXSearchTool.md +26 -0
  41. package/data/packages/platform-intelligence/api/Function.createIntelligenceTool.md +27 -0
  42. package/data/packages/platform-intelligence/api/Function.createOpenAIApplyPatchTool.md +26 -0
  43. package/data/packages/platform-intelligence/api/Function.createOpenAICodeInterpreterTool.md +26 -0
  44. package/data/packages/platform-intelligence/api/Function.createOpenAICustomTool.md +27 -0
  45. package/data/packages/platform-intelligence/api/Function.createOpenAIFileSearchTool.md +26 -0
  46. package/data/packages/platform-intelligence/api/Function.createOpenAIImageGenerationTool.md +26 -0
  47. package/data/packages/platform-intelligence/api/Function.createOpenAILocalShellTool.md +26 -0
  48. package/data/packages/platform-intelligence/api/Function.createOpenAIMcpTool.md +26 -0
  49. package/data/packages/platform-intelligence/api/Function.createOpenAIShellTool.md +26 -0
  50. package/data/packages/platform-intelligence/api/Function.createOpenAIToolSearchTool.md +26 -0
  51. package/data/packages/platform-intelligence/api/Function.createOpenAIWebSearchPreviewTool.md +26 -0
  52. package/data/packages/platform-intelligence/api/Function.createOpenAIWebSearchTool.md +26 -0
  53. package/data/packages/platform-intelligence/api/Function.createProviderOptions.md +15 -2
  54. package/data/packages/platform-intelligence/api/Function.loadAnthropicLanguageModel.md +4 -4
  55. package/data/packages/platform-intelligence/api/Function.loadGoogleLanguageModel.md +4 -4
  56. package/data/packages/platform-intelligence/api/Function.loadGrokLanguageModel.md +4 -4
  57. package/data/packages/platform-intelligence/api/Function.loadOpenAILanguageModel.md +4 -4
  58. package/data/packages/platform-intelligence/api/Interface.IIntelligenceModuleOptions.md +79 -0
  59. package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextCompletion.md +30 -6
  60. package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextGenerationOptions.md +106 -5
  61. package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextGenerator.md +29 -4
  62. package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextStreamingOptions.md +183 -0
  63. package/data/packages/platform-intelligence/api/Interface.IIntelligenceTool.md +39 -0
  64. package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolRegistry.md +146 -0
  65. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceLanguageModelLoader.md +3 -3
  66. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceLanguageModelLoaders.md +14 -0
  67. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceTextStream.md +14 -0
  68. package/data/packages/platform-intelligence/api/Variable.ANTHROPIC_API_KEY.md +1 -1
  69. package/data/packages/platform-intelligence/api/Variable.ANTHROPIC_BASE_URL.md +1 -1
  70. package/data/packages/platform-intelligence/api/Variable.ANTHROPIC_CONFIG_ENTRIES.md +14 -0
  71. package/data/packages/platform-intelligence/api/Variable.AnthropicIntelligenceToolNames.md +42 -0
  72. package/data/packages/platform-intelligence/api/Variable.GEMINI_API_KEY.md +2 -2
  73. package/data/packages/platform-intelligence/api/Variable.GOOGLE_API_KEY.md +1 -1
  74. package/data/packages/platform-intelligence/api/Variable.GOOGLE_BASE_URL.md +1 -1
  75. package/data/packages/platform-intelligence/api/Variable.GOOGLE_CONFIG_ENTRIES.md +14 -0
  76. package/data/packages/platform-intelligence/api/Variable.GROK_API_KEY.md +1 -1
  77. package/data/packages/platform-intelligence/api/Variable.GROK_BASE_URL.md +1 -1
  78. package/data/packages/platform-intelligence/api/Variable.GROK_CONFIG_ENTRIES.md +14 -0
  79. package/data/packages/platform-intelligence/api/Variable.GoogleIntelligenceToolNames.md +34 -0
  80. package/data/packages/platform-intelligence/api/Variable.GrokIntelligenceToolNames.md +34 -0
  81. package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_API_KEY.md +1 -1
  82. package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_BASE_URL.md +1 -1
  83. package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_MAX_OUTPUT_TOKENS.md +1 -1
  84. package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_MODEL.md +1 -1
  85. package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_PROVIDER.md +1 -1
  86. package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_TEMPERATURE.md +1 -1
  87. package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_TOP_P.md +1 -1
  88. package/data/packages/platform-intelligence/api/Variable.OPENAI_API_KEY.md +1 -1
  89. package/data/packages/platform-intelligence/api/Variable.OPENAI_BASE_URL.md +1 -1
  90. package/data/packages/platform-intelligence/api/Variable.OPENAI_CONFIG_ENTRIES.md +14 -0
  91. package/data/packages/platform-intelligence/api/Variable.OpenAIIntelligenceToolNames.md +40 -0
  92. package/data/packages/platform-intelligence/api/Variable.PLATFORM_INTELLIGENCE_CONFIG_ENTRIES.md +1 -1
  93. package/data/packages/platform-intelligence/api/Variable.XAI_API_KEY.md +2 -2
  94. package/data/packages/platform-intelligence/api/Variable.XAI_BASE_URL.md +2 -2
  95. package/data/packages/platform-intelligence/api/index.md +72 -33
  96. package/data/packages/platform-intelligence/index.md +280 -69
  97. package/package.json +1 -1
  98. package/data/packages/platform-intelligence/api/Class.IntelligenceCapabilityRegistrarBase.md +0 -94
  99. package/data/packages/platform-intelligence/api/Class.IntelligenceCapabilityRegistry.md +0 -106
  100. package/data/packages/platform-intelligence/api/Function.loadProviderFactory.md +0 -31
  101. package/data/packages/platform-intelligence/api/Interface.IIntelligenceArtifact.md +0 -34
  102. package/data/packages/platform-intelligence/api/Interface.IIntelligenceCapability.md +0 -71
  103. package/data/packages/platform-intelligence/api/Interface.IIntelligenceCapabilityMetadata.md +0 -70
  104. package/data/packages/platform-intelligence/api/Interface.IIntelligenceCapabilityPayload.md +0 -46
  105. package/data/packages/platform-intelligence/api/Interface.IIntelligenceCapabilityRegistry.md +0 -78
  106. package/data/packages/platform-intelligence/api/Interface.IIntelligenceCapabilityResult.md +0 -46
  107. package/data/packages/platform-intelligence/api/Interface.IIntelligenceContext.md +0 -72
  108. package/data/packages/platform-intelligence/api/Interface.IIntelligenceContextBuilder.md +0 -35
  109. package/data/packages/platform-intelligence/api/Interface.IIntelligenceConversationMessageSnapshot.md +0 -70
  110. package/data/packages/platform-intelligence/api/Interface.IIntelligenceConversationSnapshot.md +0 -58
  111. package/data/packages/platform-intelligence/api/Interface.IIntelligenceFollowUpQuestion.md +0 -46
  112. package/data/packages/platform-intelligence/api/Interface.IIntelligenceIntent.md +0 -46
  113. package/data/packages/platform-intelligence/api/Interface.IIntelligenceIntentEntity.md +0 -34
  114. package/data/packages/platform-intelligence/api/Interface.IIntelligenceMessageModel.md +0 -70
  115. package/data/packages/platform-intelligence/api/Interface.IIntelligenceMessagePayload.md +0 -34
  116. package/data/packages/platform-intelligence/api/Interface.IIntelligencePrompt.md +0 -34
  117. package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptMessage.md +0 -34
  118. package/data/packages/platform-intelligence/api/Interface.IIntelligenceResponseMessage.md +0 -34
  119. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceConversationMessageRole.md +0 -14
  120. package/data/packages/platform-intelligence/api/Variable.IntelligenceConversationMessageRoles.md +0 -26
@@ -6,7 +6,7 @@ order: 15
6
6
 
7
7
  # AI Text Generation
8
8
 
9
- This guide covers text generation with `platform-intelligence`: choosing an AI provider, configuring the module, generating completions, registering custom capabilities, and building intent-based orchestration.
9
+ This guide covers text generation with `platform-intelligence`: choosing an AI provider, configuring the module, generating completions, streaming responses, and registering class-based or provider-native AI SDK tools.
10
10
 
11
11
  ---
12
12
 
@@ -23,31 +23,41 @@ Install the AI SDK provider package for the model you want to use:
23
23
  | **OpenAI** | `@ai-sdk/openai` |
24
24
  | **Anthropic** | `@ai-sdk/anthropic` |
25
25
  | **Google** | `@ai-sdk/google` |
26
- | **Grok (xAI)** | `@ai-sdk/openai` |
26
+ | **Grok (xAI)** | `@ai-sdk/xai` |
27
27
 
28
28
  ```bash
29
29
  # Example: OpenAI
30
30
  yarn add @ai-sdk/openai
31
- ```
32
31
 
33
- > Grok uses the OpenAI-compatible endpoint, so it shares the `@ai-sdk/openai` package.
32
+ # Example: Grok / xAI
33
+ yarn add @ai-sdk/xai
34
+ ```
34
35
 
35
36
  ---
36
37
 
37
38
  ## Module Registration
38
39
 
39
- Import `IntelligenceModule` into your application module. It exposes `IntelligenceTextGenerator` and `IntelligenceCapabilityRegistry` as shared providers.
40
+ Import `IntelligenceModule` into your application module. It exposes `IntelligenceTextGenerator` and `IntelligenceToolRegistry` as shared providers.
40
41
 
41
42
  ```typescript
42
43
  import { Module } from '@nestjs/common';
43
- import { IntelligenceModule } from '@breadstone/archipel-platform-intelligence';
44
+ import { IntelligenceModule, IntelligenceProviderNames } from '@breadstone/archipel-platform-intelligence';
45
+ import { loadOpenAILanguageModel } from '@breadstone/archipel-platform-intelligence/providers/openai';
44
46
 
45
47
  @Module({
46
- imports: [IntelligenceModule],
48
+ imports: [
49
+ IntelligenceModule.register({
50
+ providerLoaders: {
51
+ [IntelligenceProviderNames.OpenAI]: loadOpenAILanguageModel,
52
+ },
53
+ }),
54
+ ],
47
55
  })
48
56
  export class AppModule {}
49
57
  ```
50
58
 
59
+ Register only the provider loaders you install. The root entry does not import provider SDK packages.
60
+
51
61
  ---
52
62
 
53
63
  ## Configuration
@@ -71,7 +81,7 @@ INTELLIGENCE_BASE_URL= # optional — override for custom endpoints
71
81
  | `openai` | `gpt-4o-mini` | OpenAI API |
72
82
  | `anthropic` | `claude-sonnet-4-20250514` | Anthropic API |
73
83
  | `google` | `gemini-2.0-flash` | Google Gemini API |
74
- | `grok` | `grok-3-mini-fast` | xAI Grok via OpenAI-compatible API |
84
+ | `grok` | `grok-3-mini` | xAI Grok API |
75
85
 
76
86
  Each provider resolves its API key and base URL from dedicated environment variables when the generic `INTELLIGENCE_API_KEY` is not set:
77
87
 
@@ -79,7 +89,7 @@ Each provider resolves its API key and base URL from dedicated environment varia
79
89
  # Provider-specific keys (optional — fallback from INTELLIGENCE_API_KEY)
80
90
  OPENAI_API_KEY=sk-...
81
91
  ANTHROPIC_API_KEY=sk-ant-...
82
- GOOGLE_GENERATIVE_AI_API_KEY=AI...
92
+ GOOGLE_API_KEY=AI...
83
93
  GROK_API_KEY=xai-...
84
94
  ```
85
95
 
@@ -91,8 +101,8 @@ Inject `IntelligenceTextGenerator` to generate completions:
91
101
 
92
102
  ```typescript
93
103
  import { Injectable } from '@nestjs/common';
94
- import { IntelligenceTextGenerator } from '@breadstone/archipel-platform-intelligence';
95
- import type { IIntelligencePrompt } from '@breadstone/archipel-platform-intelligence';
104
+ import type { Prompt } from 'ai';
105
+ import { IntelligenceTextGenerator, type IIntelligenceTextCompletion } from '@breadstone/archipel-platform-intelligence';
96
106
 
97
107
  @Injectable()
98
108
  export class SummaryService {
@@ -103,8 +113,8 @@ export class SummaryService {
103
113
  }
104
114
 
105
115
  public async summarize(content: string): Promise<string> {
106
- const prompt: IIntelligencePrompt = {
107
- systemPrompt: 'You are a concise summarizer. Respond with a short summary.',
116
+ const prompt: Prompt = {
117
+ system: 'You are a concise summarizer. Respond with a short summary.',
108
118
  messages: [{ role: 'user', content: content }],
109
119
  };
110
120
 
@@ -117,18 +127,12 @@ export class SummaryService {
117
127
 
118
128
  ### Prompt Structure
119
129
 
120
- A prompt consists of an optional system prompt and an ordered array of messages:
130
+ A prompt uses the native AI SDK `Prompt` type. Use either a string prompt or a full message array:
121
131
 
122
132
  ```typescript
123
- interface IIntelligencePrompt {
124
- readonly systemPrompt: string | null;
125
- readonly messages: ReadonlyArray<IIntelligencePromptMessage>;
126
- }
127
-
128
- interface IIntelligencePromptMessage {
129
- readonly role: 'user' | 'assistant' | 'system';
130
- readonly content: string;
131
- }
133
+ type Prompt =
134
+ | { readonly system?: string; readonly prompt: string }
135
+ | { readonly system?: string; readonly messages: Array<ModelMessage> };
132
136
  ```
133
137
 
134
138
  ### Per-Request Overrides
@@ -144,13 +148,15 @@ const completion = await this._textGenerator.generateText(prompt, {
144
148
 
145
149
  ### Completion Response
146
150
 
147
- The response includes the generated text, the provider/model used, and optional token usage telemetry:
151
+ The response includes the generated text, the provider/model used, provider-native sources, generated files, and optional token usage telemetry:
148
152
 
149
153
  ```typescript
150
154
  interface IIntelligenceTextCompletion {
151
155
  readonly text: string;
152
156
  readonly provider: string;
153
157
  readonly model: string;
158
+ readonly sources: ReadonlyArray<LanguageModelV3Source>;
159
+ readonly files: ReadonlyArray<GeneratedFile>;
154
160
  readonly usage: IIntelligenceCompletionUsage | null;
155
161
  }
156
162
 
@@ -168,8 +174,8 @@ interface IIntelligenceCompletionUsage {
168
174
  Build multi-turn conversations by passing the full message history:
169
175
 
170
176
  ```typescript
171
- const prompt: IIntelligencePrompt = {
172
- systemPrompt: 'You are a helpful fitness coach.',
177
+ const prompt: Prompt = {
178
+ system: 'You are a helpful fitness coach.',
173
179
  messages: [
174
180
  { role: 'user', content: 'What should I eat before a workout?' },
175
181
  { role: 'assistant', content: 'A balanced meal with carbs and protein about 2 hours before.' },
@@ -182,124 +188,405 @@ const completion = await this._textGenerator.generateText(prompt);
182
188
 
183
189
  ---
184
190
 
185
- ## Capability System
191
+ ## Tool Registration
186
192
 
187
- The intelligence module includes a capability registry that lets you build intent-based orchestration. Capabilities are domain-specific handlers that respond to classified user intents.
193
+ The intelligence module uses native AI SDK tools. Define a class that exposes a `name` and a native `Tool`, or register provider-native tool wrappers from provider subpaths.
188
194
 
189
- ### Defining a Capability
195
+ ```typescript
196
+ import { Injectable, Module } from '@nestjs/common';
197
+ import { tool, type Tool } from 'ai';
198
+ import { z } from 'zod';
199
+ import { IntelligenceModule, IntelligenceProviderNames, IntelligenceToolBase } from '@breadstone/archipel-platform-intelligence';
200
+ import { loadOpenAILanguageModel } from '@breadstone/archipel-platform-intelligence/providers/openai';
201
+
202
+ interface IWorkoutInput {
203
+ readonly goal: string;
204
+ }
190
205
 
191
- Implement the `IIntelligenceCapability` interface:
206
+ interface IWorkoutOutput {
207
+ readonly recommendation: string;
208
+ }
209
+
210
+ @Injectable()
211
+ export class WorkoutRecommendationTool extends IntelligenceToolBase<IWorkoutInput, IWorkoutOutput> {
212
+ public override get name(): string {
213
+ return 'recommendWorkout';
214
+ }
215
+
216
+ public override get tool(): Tool<IWorkoutInput, IWorkoutOutput> {
217
+ return tool({
218
+ description: 'Recommends a workout plan for a user goal.',
219
+ inputSchema: z.object({
220
+ goal: z.string().describe('The user fitness goal'),
221
+ }),
222
+ execute: async (input) => ({
223
+ recommendation: `Workout plan for ${input.goal}`,
224
+ }),
225
+ });
226
+ }
227
+ }
228
+
229
+ @Module({
230
+ imports: [
231
+ IntelligenceModule.register({
232
+ providerLoaders: {
233
+ [IntelligenceProviderNames.OpenAI]: loadOpenAILanguageModel,
234
+ },
235
+ tools: [WorkoutRecommendationTool],
236
+ }),
237
+ ],
238
+ })
239
+ export class WorkoutModule {}
240
+ ```
241
+
242
+ Provider-defined AI SDK tools are available through tree-shakable provider subpaths. They return `IIntelligenceTool` instances and can be placed directly in the `tools` array:
192
243
 
193
244
  ```typescript
194
- import type {
195
- IIntelligenceCapability,
196
- IIntelligenceCapabilityMetadata,
197
- IIntelligenceCapabilityPayload,
198
- IIntelligenceCapabilityResult,
199
- IIntelligenceContext,
200
- IIntelligenceIntent,
201
- } from '@breadstone/archipel-platform-intelligence';
245
+ import { Module } from '@nestjs/common';
246
+ import { IntelligenceModule, IntelligenceProviderNames } from '@breadstone/archipel-platform-intelligence';
247
+ import { loadOpenAILanguageModel } from '@breadstone/archipel-platform-intelligence/providers/openai';
248
+ import { createOpenAIWebSearchTool } from '@breadstone/archipel-platform-intelligence/providers/openai/tools';
202
249
 
203
- export class WorkoutRecommendationCapability implements IIntelligenceCapability {
204
- public readonly metadata: IIntelligenceCapabilityMetadata = {
205
- id: 'workout-recommendation',
206
- name: 'Workout Recommendation',
207
- description: 'Recommends workouts based on user preferences.',
208
- priority: 10,
209
- intentName: 'recommend_workout',
210
- };
211
-
212
- public canHandle(intent: IIntelligenceIntent, _context: IIntelligenceContext): boolean {
213
- return intent.name === 'recommend_workout' && intent.confidence >= 0.7;
250
+ @Module({
251
+ imports: [
252
+ IntelligenceModule.register({
253
+ providerLoaders: {
254
+ [IntelligenceProviderNames.OpenAI]: loadOpenAILanguageModel,
255
+ },
256
+ tools: [createOpenAIWebSearchTool({ searchContextSize: 'medium' })],
257
+ }),
258
+ ],
259
+ })
260
+ export class SearchModule {}
261
+ ```
262
+
263
+ OpenAI, Google, Anthropic, and Grok provider subpaths expose wrappers for their built-in web search, file search, code execution, URL context, shell, MCP, X search, image/video understanding, and versioned tool families where supported by the underlying SDK.
264
+
265
+ ### Native AI SDK Passthrough
266
+
267
+ Archipel is not intended to be a closed subset of the AI SDK. `IntelligenceTextGenerator.generateText()` and `streamText()` accept native AI SDK `Prompt` objects directly. Their options extend the native AI SDK call options, while Archipel still contributes provider configuration, registered tool merging, timeout defaults, logging, and normalized completion metadata.
268
+
269
+ Use the native AI SDK prompt shape for prompt strings, multimodal `ModelMessage` arrays, system-message arrays, or other prompt forms supported by the AI SDK.
270
+
271
+ ```typescript
272
+ import { openai } from '@ai-sdk/openai';
273
+ import { Injectable, Module } from '@nestjs/common';
274
+ import { IntelligenceModule, IntelligenceTextGenerator, type IIntelligenceTextCompletion } from '@breadstone/archipel-platform-intelligence';
275
+
276
+ @Module({
277
+ imports: [
278
+ IntelligenceModule.register({
279
+ validateOnModuleInit: false,
280
+ }),
281
+ ],
282
+ })
283
+ export class RawAiSdkModule {}
284
+
285
+ @Injectable()
286
+ export class RawAiSdkRecipeService {
287
+ private readonly _textGenerator: IntelligenceTextGenerator;
288
+
289
+ public constructor(textGenerator: IntelligenceTextGenerator) {
290
+ this._textGenerator = textGenerator;
214
291
  }
215
292
 
216
- public async execute(payload: IIntelligenceCapabilityPayload): Promise<IIntelligenceCapabilityResult> {
217
- // Use payload.intent, payload.context, payload.userMessage
218
- return {
219
- messages: [{ content: 'Here is your personalized workout plan...', metadata: null }],
220
- artifacts: [],
221
- followUps: [{ id: 'adjust', label: 'Adjust difficulty', payload: { action: 'adjust' } }],
222
- };
293
+ public async generateWithNativeAiSdkOptions(): Promise<IIntelligenceTextCompletion> {
294
+ return this._textGenerator.generateText(
295
+ {
296
+ system: 'Answer concisely and include assumptions.',
297
+ prompt: 'Compare the operational risks of outdoor work tomorrow.',
298
+ },
299
+ {
300
+ model: openai.responses('gpt-5'),
301
+ headers: { 'x-use-case': 'outdoor-risk' },
302
+ providerOptions: {
303
+ openai: {
304
+ reasoningEffort: 'medium',
305
+ },
306
+ },
307
+ seed: 42,
308
+ },
309
+ );
223
310
  }
224
311
  }
225
312
  ```
226
313
 
227
- ### Registering Capabilities
314
+ If every request passes a native AI SDK model, `validateOnModuleInit: false` avoids requiring platform provider configuration at startup. If no `model` option is supplied, the configured provider loader and `INTELLIGENCE_PROVIDER` / `INTELLIGENCE_MODEL` values still define the model.
228
315
 
229
- Use `IntelligenceCapabilityRegistrarBase` to auto-register capabilities when a module initializes:
316
+ ### Additional OpenAI Tool Recipes
317
+
318
+ The same pattern works for other provider-defined OpenAI tools. Register the provider tool wrapper on the module when it is available to the whole use case, or pass request-specific tools through `generateText()` when the tool needs request data such as a `fileId`.
230
319
 
231
320
  ```typescript
232
321
  import { Injectable } from '@nestjs/common';
322
+ import { stepCountIs, tool } from 'ai';
323
+ import { z } from 'zod';
324
+ import { IntelligenceTextGenerator } from '@breadstone/archipel-platform-intelligence';
325
+ import { OpenAIIntelligenceToolNames } from '@breadstone/archipel-platform-intelligence/providers/openai';
233
326
  import {
234
- IntelligenceCapabilityRegistrarBase,
235
- IntelligenceCapabilityRegistry,
236
- } from '@breadstone/archipel-platform-intelligence';
237
- import type { IIntelligenceCapability } from '@breadstone/archipel-platform-intelligence';
327
+ createOpenAICodeInterpreterTool,
328
+ createOpenAICustomTool,
329
+ createOpenAIImageGenerationTool,
330
+ createOpenAIToolSearchTool,
331
+ } from '@breadstone/archipel-platform-intelligence/providers/openai/tools';
238
332
 
239
333
  @Injectable()
240
- export class WorkoutCapabilityRegistrar extends IntelligenceCapabilityRegistrarBase {
241
- constructor(registry: IntelligenceCapabilityRegistry) {
242
- super(registry);
334
+ export class OpenAIToolRecipeService {
335
+ private readonly _textGenerator: IntelligenceTextGenerator;
336
+
337
+ public constructor(textGenerator: IntelligenceTextGenerator) {
338
+ this._textGenerator = textGenerator;
243
339
  }
244
340
 
245
- protected getCapabilities(): ReadonlyArray<IIntelligenceCapability> {
246
- return [new WorkoutRecommendationCapability()];
341
+ public async analyseSpreadsheet(fileId: string): Promise<IIntelligenceTextCompletion> {
342
+ return this._textGenerator.generateText(
343
+ {
344
+ system: 'You analyze uploaded spreadsheets and explain unusual values clearly.',
345
+ messages: [
346
+ {
347
+ role: 'user',
348
+ content: 'Analyze the file, detect unusual values, and summarize the most important findings as a table.',
349
+ },
350
+ ],
351
+ },
352
+ {
353
+ activeTools: [OpenAIIntelligenceToolNames.CodeInterpreter],
354
+ tools: {
355
+ [OpenAIIntelligenceToolNames.CodeInterpreter]: createOpenAICodeInterpreterTool({
356
+ container: { fileIds: [fileId] },
357
+ }).tool,
358
+ },
359
+ },
360
+ );
247
361
  }
248
- }
249
- ```
250
362
 
251
- Register the registrar as a provider in your feature module:
363
+ public async generateIllustration(description: string): Promise<IIntelligenceTextCompletion> {
364
+ return this._textGenerator.generateText(
365
+ {
366
+ prompt: description,
367
+ },
368
+ {
369
+ activeTools: [OpenAIIntelligenceToolNames.ImageGeneration],
370
+ tools: {
371
+ [OpenAIIntelligenceToolNames.ImageGeneration]: createOpenAIImageGenerationTool({
372
+ quality: 'medium',
373
+ size: '1024x1024',
374
+ }).tool,
375
+ },
376
+ },
377
+ );
378
+ }
252
379
 
253
- ```typescript
254
- import { Module } from '@nestjs/common';
255
- import { IntelligenceModule } from '@breadstone/archipel-platform-intelligence';
380
+ public async answerWithDeferredTools(prompt: string): Promise<IIntelligenceTextCompletion> {
381
+ return this._textGenerator.generateText(
382
+ {
383
+ prompt: prompt,
384
+ },
385
+ {
386
+ stopWhen: stepCountIs(10),
387
+ tools: {
388
+ [OpenAIIntelligenceToolNames.ToolSearch]: createOpenAIToolSearchTool().tool,
389
+ get_birthdays: tool({
390
+ description: 'Returns employee birthdays in a date range.',
391
+ inputSchema: z.object({
392
+ from: z.string(),
393
+ to: z.string(),
394
+ }),
395
+ execute: async (input) => ({ from: input.from, to: input.to, employees: [] }),
396
+ providerOptions: {
397
+ openai: { deferLoading: true },
398
+ },
399
+ }),
400
+ search_orders: tool({
401
+ description: 'Searches orders using domain-specific filters.',
402
+ inputSchema: z.object({
403
+ query: z.string(),
404
+ }),
405
+ execute: async (input) => ({ query: input.query, orders: [] }),
406
+ providerOptions: {
407
+ openai: { deferLoading: true },
408
+ },
409
+ }),
410
+ },
411
+ },
412
+ );
413
+ }
256
414
 
257
- @Module({
258
- imports: [IntelligenceModule],
259
- providers: [WorkoutCapabilityRegistrar],
260
- })
261
- export class WorkoutModule {}
415
+ public async createReadOnlyReportQuery(prompt: string): Promise<IIntelligenceTextCompletion> {
416
+ return this._textGenerator.generateText(
417
+ {
418
+ system: 'Create only read-only reporting queries. The query must start with SELECT.',
419
+ messages: [{ role: 'user', content: prompt }],
420
+ },
421
+ {
422
+ toolChoice: 'required',
423
+ stopWhen: stepCountIs(3),
424
+ activeTools: ['report_query'],
425
+ tools: {
426
+ report_query: createOpenAICustomTool({
427
+ name: 'report_query',
428
+ description: 'Create a strictly read-only reporting query.',
429
+ format: {
430
+ type: 'grammar',
431
+ syntax: 'regex',
432
+ definition: 'SELECT .+',
433
+ },
434
+ }).tool,
435
+ },
436
+ },
437
+ );
438
+ }
439
+ }
262
440
  ```
263
441
 
264
- ### Resolving Capabilities at Runtime
442
+ `generateIllustration()` can return generated images through `completion.files`, while web search results are exposed through `completion.sources`. The platform keeps the AI SDK tool objects intact, so provider-specific options such as `container.fileIds`, `deferLoading`, grammar formats, and image settings still pass through to OpenAI. With the currently installed OpenAI SDK, `customTool()` supports grammar-constrained provider output but not a local `execute` callback; run parser, allowlist, and tenant filtering before executing any generated query, or model that execution as a normal `tool()` when local execution is required.
265
443
 
266
- Use the registry to find the best-matching capability for a classified intent:
444
+ ### Outdoor Order Weather Risk Example
445
+
446
+ This is the Archipel equivalent of using one application tool together with OpenAI web search. The model is selected through configuration, for example `INTELLIGENCE_PROVIDER=openai` and `INTELLIGENCE_MODEL=gpt-5`; the use case only depends on `IntelligenceTextGenerator`.
267
447
 
268
448
  ```typescript
269
- import { Injectable } from '@nestjs/common';
270
- import { IntelligenceCapabilityRegistry } from '@breadstone/archipel-platform-intelligence';
271
- import type {
272
- IIntelligenceCapabilityResult,
273
- IIntelligenceContext,
274
- IIntelligenceIntent,
449
+ import { Injectable, Module } from '@nestjs/common';
450
+ import { stepCountIs, tool, type Tool } from 'ai';
451
+ import { z } from 'zod';
452
+ import {
453
+ IntelligenceModule,
454
+ IntelligenceProviderNames,
455
+ IntelligenceTextGenerator,
456
+ IntelligenceToolBase,
457
+ type IIntelligenceTextCompletion,
275
458
  } from '@breadstone/archipel-platform-intelligence';
459
+ import { OpenAIIntelligenceToolNames, loadOpenAILanguageModel } from '@breadstone/archipel-platform-intelligence/providers/openai';
460
+ import { createOpenAIWebSearchTool } from '@breadstone/archipel-platform-intelligence/providers/openai/tools';
461
+
462
+ interface IOutdoorOrderLookupInput {
463
+ readonly date: string;
464
+ }
465
+
466
+ interface IOutdoorOrder {
467
+ readonly id: string;
468
+ readonly location: string;
469
+ readonly scheduledAt: string;
470
+ readonly outdoorWork: boolean;
471
+ }
472
+
473
+ interface IOutdoorOrderLookupOutput {
474
+ readonly date: string;
475
+ readonly orders: ReadonlyArray<IOutdoorOrder>;
476
+ }
477
+
478
+ @Injectable()
479
+ export class OutdoorOrdersTool extends IntelligenceToolBase<IOutdoorOrderLookupInput, IOutdoorOrderLookupOutput> {
480
+ public override get name(): string {
481
+ return 'get_outdoor_orders';
482
+ }
483
+
484
+ public override get tool(): Tool<IOutdoorOrderLookupInput, IOutdoorOrderLookupOutput> {
485
+ return tool({
486
+ description: 'Returns outdoor field orders for the current tenant and date.',
487
+ inputSchema: z.object({
488
+ date: z.string().describe('Date in YYYY-MM-DD format'),
489
+ }),
490
+ execute: async (input: IOutdoorOrderLookupInput) => this.loadOutdoorOrders(input.date),
491
+ });
492
+ }
493
+
494
+ private async loadOutdoorOrders(date: string): Promise<IOutdoorOrderLookupOutput> {
495
+ return {
496
+ date: date,
497
+ orders: [
498
+ {
499
+ id: 'ord_4711',
500
+ location: 'Berlin',
501
+ scheduledAt: `${date}T08:00:00+02:00`,
502
+ outdoorWork: true,
503
+ },
504
+ ],
505
+ };
506
+ }
507
+ }
276
508
 
277
509
  @Injectable()
278
- export class ChatOrchestrator {
279
- private readonly _registry: IntelligenceCapabilityRegistry;
510
+ export class OutdoorOrderRiskAnalysisService {
511
+ private readonly _textGenerator: IntelligenceTextGenerator;
280
512
 
281
- constructor(registry: IntelligenceCapabilityRegistry) {
282
- this._registry = registry;
513
+ public constructor(textGenerator: IntelligenceTextGenerator) {
514
+ this._textGenerator = textGenerator;
283
515
  }
284
516
 
285
- public async handle(
286
- intent: IIntelligenceIntent,
287
- context: IIntelligenceContext,
288
- userMessage: string,
289
- ): Promise<IIntelligenceCapabilityResult | null> {
290
- const capability = this._registry.resolve(intent, context);
291
- if (!capability) {
292
- return null; // No matching capability fall back to generic response
293
- }
294
-
295
- return capability.execute({ intent, context, userMessage });
517
+ public async analyseOutdoorOrders(date: string): Promise<{ readonly text: string; readonly sources: IIntelligenceTextCompletion['sources'] }> {
518
+ const result = await this._textGenerator.generateText(
519
+ {
520
+ system: 'You assess weather-related risks for tenant outdoor field orders.',
521
+ messages: [
522
+ {
523
+ role: 'user',
524
+ content: `Review outdoor field orders for ${date} and flag weather-related risks.`,
525
+ },
526
+ ],
527
+ },
528
+ {
529
+ toolChoice: 'auto',
530
+ activeTools: ['get_outdoor_orders', OpenAIIntelligenceToolNames.WebSearch],
531
+ stopWhen: stepCountIs(3),
532
+ },
533
+ );
534
+
535
+ return {
536
+ text: result.text,
537
+ sources: result.sources,
538
+ };
296
539
  }
297
540
  }
541
+
542
+ @Module({
543
+ imports: [
544
+ IntelligenceModule.register({
545
+ providerLoaders: {
546
+ [IntelligenceProviderNames.OpenAI]: loadOpenAILanguageModel,
547
+ },
548
+ tools: [
549
+ OutdoorOrdersTool,
550
+ createOpenAIWebSearchTool({
551
+ externalWebAccess: true,
552
+ searchContextSize: 'medium',
553
+ filters: {
554
+ allowedDomains: ['dwd.de'],
555
+ },
556
+ }),
557
+ ],
558
+ }),
559
+ ],
560
+ providers: [OutdoorOrderRiskAnalysisService],
561
+ })
562
+ export class OutdoorOrderRiskAnalysisModule {}
298
563
  ```
299
564
 
300
- Capabilities are resolved by priority (lowest number first). If multiple capabilities can handle the same intent, the one with the highest priority (lowest value) wins.
565
+ Use AI SDK request options to constrain tool use per call:
301
566
 
302
- > **Capacity limit:** The registry enforces a maximum of **500** registered capabilities. Attempts to exceed this limit are logged as warnings and silently ignored.
567
+ ```typescript
568
+ const completion = await this._textGenerator.generateText(prompt, {
569
+ toolChoice: 'auto',
570
+ activeTools: ['recommendWorkout'],
571
+ });
572
+ ```
573
+
574
+ > **Capacity limit:** The registry enforces a maximum of **128** registered tools.
575
+
576
+ ---
577
+
578
+ ## Streaming Text
579
+
580
+ `streamText()` uses the same provider configuration and registered tools as `generateText()` and returns the native AI SDK stream result.
581
+
582
+ ```typescript
583
+ const stream = await this._textGenerator.streamText(prompt, {
584
+ activeTools: ['recommendWorkout'],
585
+ stopWhen: stepCountIs(3),
586
+ });
587
+
588
+ return stream.toUIMessageStreamResponse();
589
+ ```
303
590
 
304
591
  ---
305
592
 
@@ -325,7 +612,7 @@ Two additional error classes handle configuration and validation failures:
325
612
  | ---------------------------------- | ----------------------------- | --------------------------------------------------------------------- |
326
613
  | `IntelligenceProviderError` | `INTELLIGENCE_PROVIDER` | Provider SDK failures during text generation |
327
614
  | `IntelligenceValidationError` | `INTELLIGENCE_VALIDATION` | Invalid generation parameters (temperature, topP, maxOutputTokens) |
328
- | `IntelligenceConfigurationError` | `INTELLIGENCE_CONFIGURATION` | Unsupported provider, missing API key, or missing SDK package |
615
+ | `IntelligenceConfigurationError` | `INTELLIGENCE_CONFIGURATION` | Unsupported provider, missing API key, or missing provider loader |
329
616
 
330
617
  ### Timeout & Retry Defaults
331
618
 
@@ -362,7 +649,7 @@ try {
362
649
  }
363
650
  ```
364
651
 
365
- If an AI SDK provider package is not installed, the error message clearly states which package is missing.
652
+ If no loader is registered for the configured provider, startup fails with a clear configuration error. If a provider subpath is imported without its AI SDK peer package installed, the application fails at that import boundary instead of pulling the provider through the root package.
366
653
 
367
654
  ---
368
655
 
@@ -372,16 +659,20 @@ If an AI SDK provider package is not installed, the error message clearly states
372
659
  flowchart TB
373
660
  subgraph IntelligenceModule[IntelligenceModule]
374
661
  TextGenerator[IntelligenceTextGenerator\nConfigService -> provider]
375
- CapabilityRegistry[IntelligenceCapability Registry]
662
+ ToolRegistry[IntelligenceToolRegistry]
376
663
  end
377
664
 
378
665
  GenerateText["generateText(prompt, options?)"]
379
- ResolveCapability["resolve(intent, context)\nregister(capability)"]
380
- ProviderLoaders[Provider Loaders\nOpenAI, Anthropic, Google, Grok]
381
- FeatureCapabilities[Feature Capabilities\ncustom handlers]
666
+ StreamText["streamText(prompt, options?)"]
667
+ ResolveTools["toToolSet()\nregister(tool)"]
668
+ ProviderLoaders[Registered Provider Loaders\nproviders/openai, providers/anthropic, providers/google, providers/grok]
669
+ FeatureTools[Feature Tools\nnative AI SDK tools]
382
670
 
383
671
  TextGenerator --> GenerateText
384
- CapabilityRegistry --> ResolveCapability
672
+ TextGenerator --> StreamText
673
+ ToolRegistry --> ResolveTools
385
674
  TextGenerator --> ProviderLoaders
386
- CapabilityRegistry --> FeatureCapabilities
675
+ ToolRegistry --> FeatureTools
676
+ GenerateText --> ToolRegistry
677
+ StreamText --> ToolRegistry
387
678
  ```