@breadstone/archipel-mcp 0.0.42 → 0.0.44

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