@breadstone/archipel-mcp 0.0.43 → 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.
- package/data/guides/ai-text-generation.md +397 -107
- package/data/packages/platform-intelligence/api/Class.IntelligenceHealthIndicator.md +5 -5
- package/data/packages/platform-intelligence/api/Class.IntelligenceModule.md +26 -2
- package/data/packages/platform-intelligence/api/Class.IntelligenceTextGenerator.md +43 -9
- package/data/packages/platform-intelligence/api/Class.IntelligenceToolBase.md +93 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceToolRegistry.md +217 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicAdvisor20260301Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicBash20241022Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicBash20250124Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20250522Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20250825Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20260120Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20241022Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20250124Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20251124Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicMemory20250818Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20241022Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250124Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250429Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250728Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicToolSearchBM2520251119Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicToolSearchRegex20251119Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicWebFetch20250910Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicWebFetch20260209Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicWebSearch20250305Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicWebSearch20260209Tool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createGoogleCodeExecutionTool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createGoogleEnterpriseWebSearchTool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createGoogleFileSearchTool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createGoogleGoogleMapsTool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createGoogleGoogleSearchTool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createGoogleUrlContextTool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createGoogleVertexRagStoreTool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createIntelligenceTool.md +27 -0
- package/data/packages/platform-intelligence/api/Function.createOpenAIApplyPatchTool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createOpenAICodeInterpreterTool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createOpenAICustomTool.md +27 -0
- package/data/packages/platform-intelligence/api/Function.createOpenAIFileSearchTool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createOpenAIImageGenerationTool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createOpenAILocalShellTool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createOpenAIMcpTool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createOpenAIShellTool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createOpenAIToolSearchTool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createOpenAIWebSearchPreviewTool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createOpenAIWebSearchTool.md +26 -0
- package/data/packages/platform-intelligence/api/Function.createProviderOptions.md +15 -2
- package/data/packages/platform-intelligence/api/Function.loadAnthropicLanguageModel.md +4 -4
- package/data/packages/platform-intelligence/api/Function.loadGoogleLanguageModel.md +4 -4
- package/data/packages/platform-intelligence/api/Function.loadGrokLanguageModel.md +4 -4
- package/data/packages/platform-intelligence/api/Function.loadOpenAILanguageModel.md +4 -4
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModuleOptions.md +79 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextCompletion.md +30 -6
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextGenerationOptions.md +106 -5
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextGenerator.md +29 -4
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextStreamingOptions.md +183 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTool.md +39 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolRegistry.md +146 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceLanguageModelLoader.md +3 -3
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceLanguageModelLoaders.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceTextStream.md +14 -0
- package/data/packages/platform-intelligence/api/Variable.ANTHROPIC_API_KEY.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.ANTHROPIC_BASE_URL.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.ANTHROPIC_CONFIG_ENTRIES.md +14 -0
- package/data/packages/platform-intelligence/api/Variable.AnthropicIntelligenceToolNames.md +42 -0
- package/data/packages/platform-intelligence/api/Variable.GEMINI_API_KEY.md +2 -2
- package/data/packages/platform-intelligence/api/Variable.GOOGLE_API_KEY.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.GOOGLE_BASE_URL.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.GOOGLE_CONFIG_ENTRIES.md +14 -0
- package/data/packages/platform-intelligence/api/Variable.GROK_API_KEY.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.GROK_BASE_URL.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.GROK_CONFIG_ENTRIES.md +14 -0
- package/data/packages/platform-intelligence/api/Variable.GoogleIntelligenceToolNames.md +34 -0
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_API_KEY.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_BASE_URL.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_MAX_OUTPUT_TOKENS.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_MODEL.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_PROVIDER.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_TEMPERATURE.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_TOP_P.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.OPENAI_API_KEY.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.OPENAI_BASE_URL.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.OPENAI_CONFIG_ENTRIES.md +14 -0
- package/data/packages/platform-intelligence/api/Variable.OpenAIIntelligenceToolNames.md +40 -0
- package/data/packages/platform-intelligence/api/Variable.PLATFORM_INTELLIGENCE_CONFIG_ENTRIES.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.XAI_API_KEY.md +2 -2
- package/data/packages/platform-intelligence/api/Variable.XAI_BASE_URL.md +2 -2
- package/data/packages/platform-intelligence/api/index.md +64 -33
- package/data/packages/platform-intelligence/index.md +278 -69
- package/package.json +1 -1
- package/data/packages/platform-intelligence/api/Class.IntelligenceCapabilityRegistrarBase.md +0 -94
- package/data/packages/platform-intelligence/api/Class.IntelligenceCapabilityRegistry.md +0 -106
- package/data/packages/platform-intelligence/api/Function.loadProviderFactory.md +0 -31
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceArtifact.md +0 -34
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceCapability.md +0 -71
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceCapabilityMetadata.md +0 -70
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceCapabilityPayload.md +0 -46
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceCapabilityRegistry.md +0 -78
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceCapabilityResult.md +0 -46
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceContext.md +0 -72
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceContextBuilder.md +0 -35
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceConversationMessageSnapshot.md +0 -70
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceConversationSnapshot.md +0 -58
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceFollowUpQuestion.md +0 -46
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceIntent.md +0 -46
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceIntentEntity.md +0 -34
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceMessageModel.md +0 -70
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceMessagePayload.md +0 -34
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePrompt.md +0 -34
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptMessage.md +0 -34
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceResponseMessage.md +0 -34
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceConversationMessageRole.md +0 -14
- package/data/packages/platform-intelligence/api/Variable.IntelligenceConversationMessageRoles.md +0 -26
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: platform-intelligence
|
|
3
|
-
description: Multi-provider AI text generation
|
|
3
|
+
description: Multi-provider AI text generation, streaming, and tool calling.
|
|
4
4
|
order: 16
|
|
5
|
-
tags: [intelligence, ai, openai, anthropic, google, grok, text-generation,
|
|
5
|
+
tags: [intelligence, ai, openai, anthropic, google, grok, text-generation, streaming, tool-calling, health]
|
|
6
6
|
package: '@breadstone/archipel-platform-intelligence'
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# platform-intelligence
|
|
10
10
|
|
|
11
|
-
Multi-provider AI text generation library supporting OpenAI, Anthropic, Google Generative AI, and Grok.
|
|
11
|
+
Multi-provider AI text generation library supporting OpenAI, Anthropic, Google Generative AI, and Grok. Tool orchestration is delegated to the AI SDK through native and provider-defined tool definitions, `toolChoice`, `activeTools`, and `stopWhen`. Advanced use cases can pass native AI SDK prompts, request-level models, provider options, headers, telemetry, output settings, and step hooks through the platform generator.
|
|
12
12
|
|
|
13
13
|
**Package:** `@breadstone/archipel-platform-intelligence`
|
|
14
14
|
|
|
@@ -18,101 +18,306 @@ Multi-provider AI text generation library supporting OpenAI, Anthropic, Google G
|
|
|
18
18
|
|
|
19
19
|
```typescript
|
|
20
20
|
import { Module } from '@nestjs/common';
|
|
21
|
-
import { IntelligenceModule } from '@breadstone/archipel-platform-intelligence';
|
|
21
|
+
import { IntelligenceModule, IntelligenceProviderNames } from '@breadstone/archipel-platform-intelligence';
|
|
22
|
+
import { loadOpenAILanguageModel } from '@breadstone/archipel-platform-intelligence/providers/openai';
|
|
22
23
|
|
|
23
24
|
@Module({
|
|
24
|
-
imports: [
|
|
25
|
+
imports: [
|
|
26
|
+
IntelligenceModule.register({
|
|
27
|
+
providerLoaders: {
|
|
28
|
+
[IntelligenceProviderNames.OpenAI]: loadOpenAILanguageModel,
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
25
32
|
})
|
|
26
33
|
export class AppModule {}
|
|
27
34
|
```
|
|
28
35
|
|
|
29
36
|
---
|
|
30
37
|
|
|
31
|
-
## Provider
|
|
38
|
+
## Provider Subpaths
|
|
32
39
|
|
|
33
|
-
|
|
40
|
+
Import only the providers you need:
|
|
34
41
|
|
|
35
|
-
| Provider |
|
|
36
|
-
| --------- |
|
|
37
|
-
| OpenAI | `@breadstone/archipel-platform-intelligence/openai` |
|
|
38
|
-
| Anthropic | `@breadstone/archipel-platform-intelligence/anthropic` |
|
|
39
|
-
| Google | `@breadstone/archipel-platform-intelligence/google` |
|
|
40
|
-
| Grok | `@breadstone/archipel-platform-intelligence/grok` |
|
|
42
|
+
| Provider | Subpath |
|
|
43
|
+
| --------- | ---------------------------------------------------------------- |
|
|
44
|
+
| OpenAI | `@breadstone/archipel-platform-intelligence/providers/openai` |
|
|
45
|
+
| Anthropic | `@breadstone/archipel-platform-intelligence/providers/anthropic` |
|
|
46
|
+
| Google | `@breadstone/archipel-platform-intelligence/providers/google` |
|
|
47
|
+
| Grok | `@breadstone/archipel-platform-intelligence/providers/grok` |
|
|
41
48
|
|
|
42
49
|
---
|
|
43
50
|
|
|
44
|
-
##
|
|
51
|
+
## Tool Registration
|
|
45
52
|
|
|
46
|
-
|
|
53
|
+
Tools can be normal Nest providers or direct `IIntelligenceTool` instances. Register classes for custom application tools, or register provider-native wrappers from provider subpaths.
|
|
47
54
|
|
|
48
55
|
```typescript
|
|
49
|
-
import { Injectable } from '@nestjs/common';
|
|
50
|
-
import {
|
|
56
|
+
import { Injectable, Module } from '@nestjs/common';
|
|
57
|
+
import { tool, type Tool } from 'ai';
|
|
58
|
+
import { z } from 'zod';
|
|
59
|
+
import { IntelligenceModule, IntelligenceProviderNames, IntelligenceToolBase } from '@breadstone/archipel-platform-intelligence';
|
|
60
|
+
import { loadOpenAILanguageModel } from '@breadstone/archipel-platform-intelligence/providers/openai';
|
|
61
|
+
|
|
62
|
+
interface ICustomerSearchInput {
|
|
63
|
+
readonly query: string;
|
|
64
|
+
}
|
|
51
65
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
66
|
+
interface ICustomerSearchOutput {
|
|
67
|
+
readonly customers: ReadonlyArray<string>;
|
|
68
|
+
}
|
|
55
69
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
@Injectable()
|
|
71
|
+
export class CustomerSearchTool extends IntelligenceToolBase<ICustomerSearchInput, ICustomerSearchOutput> {
|
|
72
|
+
public override get name(): string {
|
|
73
|
+
return 'searchCustomers';
|
|
74
|
+
}
|
|
61
75
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
76
|
+
public override get tool(): Tool<ICustomerSearchInput, ICustomerSearchOutput> {
|
|
77
|
+
return tool({
|
|
78
|
+
description: 'Searches customers by name, email, or company.',
|
|
79
|
+
inputSchema: z.object({
|
|
80
|
+
query: z.string().describe('Customer search query'),
|
|
81
|
+
}),
|
|
82
|
+
execute: async (input) => ({ customers: [input.query] }),
|
|
66
83
|
});
|
|
67
|
-
|
|
68
|
-
return result.text;
|
|
69
84
|
}
|
|
70
85
|
}
|
|
86
|
+
|
|
87
|
+
@Module({
|
|
88
|
+
imports: [
|
|
89
|
+
IntelligenceModule.register({
|
|
90
|
+
providerLoaders: {
|
|
91
|
+
[IntelligenceProviderNames.OpenAI]: loadOpenAILanguageModel,
|
|
92
|
+
},
|
|
93
|
+
tools: [CustomerSearchTool],
|
|
94
|
+
}),
|
|
95
|
+
],
|
|
96
|
+
})
|
|
97
|
+
export class AppModule {}
|
|
71
98
|
```
|
|
72
99
|
|
|
73
|
-
|
|
100
|
+
### Provider-Native Tools
|
|
101
|
+
|
|
102
|
+
Provider SDKs expose built-in tools such as web search, file search, code execution, and URL context. Archipel exports wrappers from provider subpaths so each tool is compatible with `IIntelligenceTool` without importing unused provider SDKs from the root entry.
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
import { Module } from '@nestjs/common';
|
|
106
|
+
import { IntelligenceModule, IntelligenceProviderNames } from '@breadstone/archipel-platform-intelligence';
|
|
107
|
+
import { loadOpenAILanguageModel } from '@breadstone/archipel-platform-intelligence/providers/openai';
|
|
108
|
+
import { createOpenAIWebSearchTool } from '@breadstone/archipel-platform-intelligence/providers/openai/tools';
|
|
109
|
+
|
|
110
|
+
@Module({
|
|
111
|
+
imports: [
|
|
112
|
+
IntelligenceModule.register({
|
|
113
|
+
providerLoaders: {
|
|
114
|
+
[IntelligenceProviderNames.OpenAI]: loadOpenAILanguageModel,
|
|
115
|
+
},
|
|
116
|
+
tools: [createOpenAIWebSearchTool({ searchContextSize: 'medium' })],
|
|
117
|
+
}),
|
|
118
|
+
],
|
|
119
|
+
})
|
|
120
|
+
export class AppModule {}
|
|
121
|
+
```
|
|
74
122
|
|
|
75
|
-
|
|
123
|
+
Provider-native wrappers cover OpenAI web search, file search, code interpreter, image generation, shell, MCP, and tool search; Google Search, Enterprise Web Search, URL Context, Code Execution, File Search, Maps, and Vertex RAG Store; and versioned Anthropic web search, web fetch, code execution, bash, text editor, computer, memory, tool search, and advisor tools.
|
|
76
124
|
|
|
77
|
-
The
|
|
125
|
+
The detailed AI text generation guide includes OpenAI recipes for spreadsheet analysis with Code Interpreter, image generation with generated files, deferred tool loading via Tool Search, and grammar-constrained custom tools. In the currently installed OpenAI SDK, `customTool()` constrains provider output but does not run a local `execute` callback; use a normal `tool()` when local execution is required.
|
|
78
126
|
|
|
79
|
-
###
|
|
127
|
+
### Native AI SDK Passthrough
|
|
128
|
+
|
|
129
|
+
`generateText()` and `streamText()` accept native AI SDK `Prompt` objects directly. The options intentionally extend the native AI SDK call options, so provider-specific features can flow through even when Archipel has no dedicated wrapper for them.
|
|
130
|
+
|
|
131
|
+
The configured platform model is used by default. For exact AI SDK model factories, pass `model` per request. When every call provides a native model, set `validateOnModuleInit: false` to skip startup validation of platform provider configuration.
|
|
80
132
|
|
|
81
133
|
```typescript
|
|
82
|
-
import {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
134
|
+
import { openai } from '@ai-sdk/openai';
|
|
135
|
+
import { Injectable, Module } from '@nestjs/common';
|
|
136
|
+
import { IntelligenceModule, IntelligenceTextGenerator } from '@breadstone/archipel-platform-intelligence';
|
|
137
|
+
|
|
138
|
+
@Module({
|
|
139
|
+
imports: [
|
|
140
|
+
IntelligenceModule.register({
|
|
141
|
+
validateOnModuleInit: false,
|
|
142
|
+
}),
|
|
143
|
+
],
|
|
144
|
+
})
|
|
145
|
+
export class RawAiSdkModule {}
|
|
146
|
+
|
|
147
|
+
@Injectable()
|
|
148
|
+
export class RawAiSdkRecipeService {
|
|
149
|
+
public constructor(private readonly _textGenerator: IntelligenceTextGenerator) {}
|
|
150
|
+
|
|
151
|
+
public async answerWithNativeOptions(): Promise<string> {
|
|
152
|
+
const completion = await this._textGenerator.generateText(
|
|
153
|
+
{
|
|
154
|
+
system: 'Answer concisely and include assumptions.',
|
|
155
|
+
prompt: 'Compare the operational risks of outdoor work tomorrow.',
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
model: openai.responses('gpt-5'),
|
|
159
|
+
headers: { 'x-use-case': 'outdoor-risk' },
|
|
160
|
+
providerOptions: {
|
|
161
|
+
openai: {
|
|
162
|
+
reasoningEffort: 'medium',
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
seed: 42,
|
|
166
|
+
},
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
return completion.text;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
91
172
|
```
|
|
92
173
|
|
|
93
|
-
###
|
|
174
|
+
### Outdoor Order Weather Risk Example
|
|
175
|
+
|
|
176
|
+
Use a class-based application tool for tenant data and a provider-native web search tool for current weather context. Set `INTELLIGENCE_PROVIDER=openai` and `INTELLIGENCE_MODEL=gpt-5` in configuration when this flow should use GPT-5.
|
|
94
177
|
|
|
95
178
|
```typescript
|
|
96
|
-
import { Injectable } from '@nestjs/common';
|
|
179
|
+
import { Injectable, Module } from '@nestjs/common';
|
|
180
|
+
import { stepCountIs, tool, type Tool } from 'ai';
|
|
181
|
+
import { z } from 'zod';
|
|
97
182
|
import {
|
|
98
|
-
|
|
99
|
-
|
|
183
|
+
IntelligenceModule,
|
|
184
|
+
IntelligenceProviderNames,
|
|
185
|
+
IntelligenceTextGenerator,
|
|
186
|
+
IntelligenceToolBase,
|
|
187
|
+
type IIntelligenceTextCompletion,
|
|
100
188
|
} from '@breadstone/archipel-platform-intelligence';
|
|
189
|
+
import { OpenAIIntelligenceToolNames, loadOpenAILanguageModel } from '@breadstone/archipel-platform-intelligence/providers/openai';
|
|
190
|
+
import { createOpenAIWebSearchTool } from '@breadstone/archipel-platform-intelligence/providers/openai/tools';
|
|
191
|
+
|
|
192
|
+
interface IOutdoorOrderLookupInput {
|
|
193
|
+
readonly date: string;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
interface IOutdoorOrderLookupOutput {
|
|
197
|
+
readonly date: string;
|
|
198
|
+
readonly orders: ReadonlyArray<{
|
|
199
|
+
readonly id: string;
|
|
200
|
+
readonly location: string;
|
|
201
|
+
readonly scheduledAt: string;
|
|
202
|
+
readonly outdoorWork: boolean;
|
|
203
|
+
}>;
|
|
204
|
+
}
|
|
101
205
|
|
|
102
206
|
@Injectable()
|
|
103
|
-
export class
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
207
|
+
export class OutdoorOrdersTool extends IntelligenceToolBase<IOutdoorOrderLookupInput, IOutdoorOrderLookupOutput> {
|
|
208
|
+
public override get name(): string {
|
|
209
|
+
return 'get_outdoor_orders';
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
public override get tool(): Tool<IOutdoorOrderLookupInput, IOutdoorOrderLookupOutput> {
|
|
213
|
+
return tool({
|
|
214
|
+
description: 'Returns outdoor field orders for the current tenant and date.',
|
|
215
|
+
inputSchema: z.object({
|
|
216
|
+
date: z.string().describe('Date in YYYY-MM-DD format'),
|
|
217
|
+
}),
|
|
218
|
+
execute: async (input: IOutdoorOrderLookupInput) => ({
|
|
219
|
+
date: input.date,
|
|
220
|
+
orders: [
|
|
221
|
+
{
|
|
222
|
+
id: 'ord_4711',
|
|
223
|
+
location: 'Berlin',
|
|
224
|
+
scheduledAt: `${input.date}T08:00:00+02:00`,
|
|
225
|
+
outdoorWork: true,
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
}),
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
@Injectable()
|
|
234
|
+
export class OutdoorOrderRiskAnalysisService {
|
|
235
|
+
public constructor(private readonly _textGenerator: IntelligenceTextGenerator) {}
|
|
236
|
+
|
|
237
|
+
public async analyseOutdoorOrders(date: string): Promise<{ readonly text: string; readonly sources: IIntelligenceTextCompletion['sources'] }> {
|
|
238
|
+
const result = await this._textGenerator.generateText(
|
|
239
|
+
{
|
|
240
|
+
system: 'You assess weather-related risks for tenant outdoor field orders.',
|
|
241
|
+
messages: [{ role: 'user', content: `Review outdoor field orders for ${date} and flag weather-related risks.` }],
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
toolChoice: 'auto',
|
|
245
|
+
activeTools: ['get_outdoor_orders', OpenAIIntelligenceToolNames.WebSearch],
|
|
246
|
+
stopWhen: stepCountIs(3),
|
|
247
|
+
},
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
return {
|
|
251
|
+
text: result.text,
|
|
252
|
+
sources: result.sources,
|
|
253
|
+
};
|
|
107
254
|
}
|
|
108
255
|
}
|
|
256
|
+
|
|
257
|
+
@Module({
|
|
258
|
+
imports: [
|
|
259
|
+
IntelligenceModule.register({
|
|
260
|
+
providerLoaders: {
|
|
261
|
+
[IntelligenceProviderNames.OpenAI]: loadOpenAILanguageModel,
|
|
262
|
+
},
|
|
263
|
+
tools: [
|
|
264
|
+
OutdoorOrdersTool,
|
|
265
|
+
createOpenAIWebSearchTool({
|
|
266
|
+
externalWebAccess: true,
|
|
267
|
+
searchContextSize: 'medium',
|
|
268
|
+
filters: { allowedDomains: ['dwd.de'] },
|
|
269
|
+
}),
|
|
270
|
+
],
|
|
271
|
+
}),
|
|
272
|
+
],
|
|
273
|
+
providers: [OutdoorOrderRiskAnalysisService],
|
|
274
|
+
})
|
|
275
|
+
export class OutdoorOrderRiskAnalysisModule {}
|
|
109
276
|
```
|
|
110
277
|
|
|
111
|
-
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Text Generation
|
|
281
|
+
|
|
282
|
+
Inject `IntelligenceTextGenerator` and call `generateText()`:
|
|
112
283
|
|
|
113
284
|
```typescript
|
|
114
|
-
|
|
115
|
-
|
|
285
|
+
import { Injectable } from '@nestjs/common';
|
|
286
|
+
import type { Prompt } from 'ai';
|
|
287
|
+
import { IntelligenceTextGenerator } from '@breadstone/archipel-platform-intelligence';
|
|
288
|
+
|
|
289
|
+
@Injectable()
|
|
290
|
+
export class SummaryService {
|
|
291
|
+
constructor(private readonly _textGenerator: IntelligenceTextGenerator) {}
|
|
292
|
+
|
|
293
|
+
async summarize(content: string): Promise<string> {
|
|
294
|
+
const prompt: Prompt = {
|
|
295
|
+
system: 'You are a concise summarizer.',
|
|
296
|
+
messages: [{ role: 'user', content }],
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
const result = await this._textGenerator.generateText(prompt, {
|
|
300
|
+
temperature: 0.3,
|
|
301
|
+
toolChoice: 'auto',
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
return result.text;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## Streaming
|
|
312
|
+
`streamText()` uses the same registered tools and returns the native AI SDK stream result.
|
|
313
|
+
|
|
314
|
+
```typescript
|
|
315
|
+
const stream = await this._textGenerator.streamText(prompt, {
|
|
316
|
+
activeTools: ['searchCustomers'],
|
|
317
|
+
stopWhen: stepCountIs(3),
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
return stream.toUIMessageStreamResponse();
|
|
116
321
|
```
|
|
117
322
|
|
|
118
323
|
---
|
|
@@ -121,10 +326,10 @@ const result = await this._textGenerator.generateText(prompt, capability);
|
|
|
121
326
|
|
|
122
327
|
| Variable | Description | Required |
|
|
123
328
|
| -------------------------------- | ---------------------------- | ------------------ |
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
126
|
-
| `
|
|
127
|
-
| `
|
|
329
|
+
| `OPENAI_API_KEY` | OpenAI API key | If using OpenAI |
|
|
330
|
+
| `ANTHROPIC_API_KEY` | Anthropic API key | If using Anthropic |
|
|
331
|
+
| `GOOGLE_API_KEY` | Google Generative AI API key | If using Google |
|
|
332
|
+
| `GROK_API_KEY` | Grok / xAI API key | If using Grok |
|
|
128
333
|
|
|
129
334
|
---
|
|
130
335
|
|
|
@@ -142,9 +347,7 @@ Override the timeout per call via the options parameter:
|
|
|
142
347
|
|
|
143
348
|
```typescript
|
|
144
349
|
const result = await this._textGenerator.generateText(prompt, {
|
|
145
|
-
|
|
146
|
-
model: 'gpt-4o',
|
|
147
|
-
timeoutMs: 15_000, // 15-second timeout
|
|
350
|
+
timeoutMs: 15_000,
|
|
148
351
|
});
|
|
149
352
|
```
|
|
150
353
|
|
|
@@ -160,7 +363,7 @@ The library provides three domain error classes for different failure scenarios:
|
|
|
160
363
|
| ---------------------------------- | ----------------------------- | --------------------------------------------------------------------- |
|
|
161
364
|
| `IntelligenceProviderError` | `INTELLIGENCE_PROVIDER` | Provider SDK failures during text generation |
|
|
162
365
|
| `IntelligenceValidationError` | `INTELLIGENCE_VALIDATION` | Invalid generation parameters (temperature, topP, maxOutputTokens) |
|
|
163
|
-
| `IntelligenceConfigurationError` | `INTELLIGENCE_CONFIGURATION` | Unsupported provider, missing API key, or missing
|
|
366
|
+
| `IntelligenceConfigurationError` | `INTELLIGENCE_CONFIGURATION` | Unsupported provider, missing API key, or missing provider loader |
|
|
164
367
|
|
|
165
368
|
```typescript
|
|
166
369
|
import {
|
|
@@ -174,27 +377,33 @@ import {
|
|
|
174
377
|
|
|
175
378
|
## Lifecycle
|
|
176
379
|
|
|
177
|
-
`IntelligenceTextGenerator` implements `OnModuleInit` and validates the provider configuration eagerly at startup. Missing API keys
|
|
380
|
+
`IntelligenceTextGenerator` implements `OnModuleInit` and validates the provider configuration plus registered provider loader eagerly at startup. Missing API keys, unsupported providers, or missing loaders throw `IntelligenceConfigurationError` before the first request is processed.
|
|
178
381
|
|
|
179
382
|
---
|
|
180
383
|
|
|
181
|
-
##
|
|
384
|
+
## Tool Registry Limits
|
|
182
385
|
|
|
183
|
-
`
|
|
386
|
+
`IntelligenceToolRegistry` enforces a maximum of **128** registered tools. Attempts to register beyond this limit throw `IntelligenceValidationError` to prevent unbounded memory growth.
|
|
184
387
|
|
|
185
388
|
---
|
|
186
389
|
|
|
187
390
|
## Health Check
|
|
188
391
|
|
|
189
|
-
The `IntelligenceHealthIndicator` verifies that
|
|
392
|
+
The `IntelligenceHealthIndicator` verifies that provider configuration can be resolved. If no text generator is available, it reports `disabled: true`. Import it from the `/health` subpath:
|
|
190
393
|
|
|
191
394
|
```typescript
|
|
395
|
+
import { IntelligenceModule, IntelligenceProviderNames } from '@breadstone/archipel-platform-intelligence';
|
|
192
396
|
import { IntelligenceHealthIndicator } from '@breadstone/archipel-platform-intelligence/health';
|
|
397
|
+
import { loadOpenAILanguageModel } from '@breadstone/archipel-platform-intelligence/providers/openai';
|
|
193
398
|
import { HealthModule } from '@breadstone/archipel-platform-health';
|
|
194
399
|
|
|
195
400
|
@Module({
|
|
196
401
|
imports: [
|
|
197
|
-
IntelligenceModule.register({
|
|
402
|
+
IntelligenceModule.register({
|
|
403
|
+
providerLoaders: {
|
|
404
|
+
[IntelligenceProviderNames.OpenAI]: loadOpenAILanguageModel,
|
|
405
|
+
},
|
|
406
|
+
}),
|
|
198
407
|
HealthModule.withIndicators([IntelligenceHealthIndicator]),
|
|
199
408
|
],
|
|
200
409
|
})
|
|
@@ -203,7 +412,7 @@ export class AppModule {}
|
|
|
203
412
|
|
|
204
413
|
| Key | Check | Dependencies |
|
|
205
414
|
| --- | ----- | ------------ |
|
|
206
|
-
| `intelligence` | `up`
|
|
415
|
+
| `intelligence` | `up` when provider configuration resolves, else `down` | `@Optional() IntelligenceTextGenerator` |
|
|
207
416
|
|
|
208
417
|
---
|
|
209
418
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@breadstone/archipel-mcp",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.44",
|
|
4
4
|
"description": "MCP server providing Archipel platform knowledge - documentation, query patterns, and coding conventions - to AI development tools.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/main.js",
|
package/data/packages/platform-intelligence/api/Class.IntelligenceCapabilityRegistrarBase.md
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: 'Abstract Class: IntelligenceCapabilityRegistrarBase'
|
|
3
|
-
generated: true
|
|
4
|
-
editUrl: false
|
|
5
|
-
---
|
|
6
|
-
# Abstract Class: IntelligenceCapabilityRegistrarBase
|
|
7
|
-
|
|
8
|
-
Defined in: [abstracts/IntelligenceCapabilityRegistrarBase.ts:15](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-intelligence/src/abstracts/IntelligenceCapabilityRegistrarBase.ts#L15)
|
|
9
|
-
|
|
10
|
-
Provides a reusable registration flow that allows feature modules to contribute
|
|
11
|
-
capabilities to the global intelligence registry while keeping their implementation details private.
|
|
12
|
-
|
|
13
|
-
## Implements
|
|
14
|
-
|
|
15
|
-
- `OnModuleInit`
|
|
16
|
-
|
|
17
|
-
## Constructors
|
|
18
|
-
|
|
19
|
-
### Constructor
|
|
20
|
-
|
|
21
|
-
```ts
|
|
22
|
-
protected new IntelligenceCapabilityRegistrarBase(registry): IntelligenceCapabilityRegistrarBase;
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Defined in: [abstracts/IntelligenceCapabilityRegistrarBase.ts:30](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-intelligence/src/abstracts/IntelligenceCapabilityRegistrarBase.ts#L30)
|
|
26
|
-
|
|
27
|
-
Initializes a new instance of the IntelligenceCapabilityRegistrarBase class.
|
|
28
|
-
|
|
29
|
-
#### Parameters
|
|
30
|
-
|
|
31
|
-
| Parameter | Type | Description |
|
|
32
|
-
| ------ | ------ | ------ |
|
|
33
|
-
| `registry` | [`IntelligenceCapabilityRegistry`](Class.IntelligenceCapabilityRegistry) | Registry instance that receives contributed capabilities. |
|
|
34
|
-
|
|
35
|
-
#### Returns
|
|
36
|
-
|
|
37
|
-
`IntelligenceCapabilityRegistrarBase`
|
|
38
|
-
|
|
39
|
-
## Accessors
|
|
40
|
-
|
|
41
|
-
### registry
|
|
42
|
-
|
|
43
|
-
#### Get Signature
|
|
44
|
-
|
|
45
|
-
```ts
|
|
46
|
-
get protected registry(): IntelligenceCapabilityRegistry;
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Defined in: [abstracts/IntelligenceCapabilityRegistrarBase.ts:44](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-intelligence/src/abstracts/IntelligenceCapabilityRegistrarBase.ts#L44)
|
|
50
|
-
|
|
51
|
-
Gets the registry instance that should be used to register capabilities.
|
|
52
|
-
|
|
53
|
-
##### Returns
|
|
54
|
-
|
|
55
|
-
[`IntelligenceCapabilityRegistry`](Class.IntelligenceCapabilityRegistry)
|
|
56
|
-
|
|
57
|
-
## Methods
|
|
58
|
-
|
|
59
|
-
### getCapabilities()
|
|
60
|
-
|
|
61
|
-
```ts
|
|
62
|
-
abstract protected getCapabilities(): readonly IIntelligenceCapability[];
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
Defined in: [abstracts/IntelligenceCapabilityRegistrarBase.ts:74](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-intelligence/src/abstracts/IntelligenceCapabilityRegistrarBase.ts#L74)
|
|
66
|
-
|
|
67
|
-
Returns the capabilities that should be registered for the module.
|
|
68
|
-
|
|
69
|
-
#### Returns
|
|
70
|
-
|
|
71
|
-
readonly [`IIntelligenceCapability`](Interface.IIntelligenceCapability)[]
|
|
72
|
-
|
|
73
|
-
***
|
|
74
|
-
|
|
75
|
-
### onModuleInit()
|
|
76
|
-
|
|
77
|
-
```ts
|
|
78
|
-
onModuleInit(): void;
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
Defined in: [abstracts/IntelligenceCapabilityRegistrarBase.ts:58](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-intelligence/src/abstracts/IntelligenceCapabilityRegistrarBase.ts#L58)
|
|
82
|
-
|
|
83
|
-
Template method invoked by NestJS once the provider has been instantiated.
|
|
84
|
-
Registers all capabilities returned by [getCapabilities](#getcapabilities).
|
|
85
|
-
|
|
86
|
-
#### Returns
|
|
87
|
-
|
|
88
|
-
`void`
|
|
89
|
-
|
|
90
|
-
#### Implementation of
|
|
91
|
-
|
|
92
|
-
```ts
|
|
93
|
-
OnModuleInit.onModuleInit
|
|
94
|
-
```
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: 'Class: IntelligenceCapabilityRegistry'
|
|
3
|
-
generated: true
|
|
4
|
-
editUrl: false
|
|
5
|
-
---
|
|
6
|
-
# Class: IntelligenceCapabilityRegistry
|
|
7
|
-
|
|
8
|
-
Defined in: [IntelligenceCapabilityRegistry.ts:15](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-intelligence/src/IntelligenceCapabilityRegistry.ts#L15)
|
|
9
|
-
|
|
10
|
-
Central registry responsible for resolving intelligence capabilities based on intent metadata.
|
|
11
|
-
|
|
12
|
-
## Implements
|
|
13
|
-
|
|
14
|
-
- [`IIntelligenceCapabilityRegistry`](Interface.IIntelligenceCapabilityRegistry)
|
|
15
|
-
|
|
16
|
-
## Constructors
|
|
17
|
-
|
|
18
|
-
### Constructor
|
|
19
|
-
|
|
20
|
-
```ts
|
|
21
|
-
new IntelligenceCapabilityRegistry(): IntelligenceCapabilityRegistry;
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
#### Returns
|
|
25
|
-
|
|
26
|
-
`IntelligenceCapabilityRegistry`
|
|
27
|
-
|
|
28
|
-
## Methods
|
|
29
|
-
|
|
30
|
-
### list()
|
|
31
|
-
|
|
32
|
-
```ts
|
|
33
|
-
list(): readonly IIntelligenceCapability[];
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
Defined in: [IntelligenceCapabilityRegistry.ts:45](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-intelligence/src/IntelligenceCapabilityRegistry.ts#L45)
|
|
37
|
-
|
|
38
|
-
Returns a read-only snapshot of all registered capabilities.
|
|
39
|
-
|
|
40
|
-
#### Returns
|
|
41
|
-
|
|
42
|
-
readonly [`IIntelligenceCapability`](Interface.IIntelligenceCapability)[]
|
|
43
|
-
|
|
44
|
-
A defensive copy of the registered capabilities.
|
|
45
|
-
|
|
46
|
-
#### Implementation of
|
|
47
|
-
|
|
48
|
-
[`IIntelligenceCapabilityRegistry`](Interface.IIntelligenceCapabilityRegistry).[`list`](Interface.IIntelligenceCapabilityRegistry#list)
|
|
49
|
-
|
|
50
|
-
***
|
|
51
|
-
|
|
52
|
-
### register()
|
|
53
|
-
|
|
54
|
-
```ts
|
|
55
|
-
register(capability): void;
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
Defined in: [IntelligenceCapabilityRegistry.ts:27](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-intelligence/src/IntelligenceCapabilityRegistry.ts#L27)
|
|
59
|
-
|
|
60
|
-
Registers a capability in the registry.
|
|
61
|
-
|
|
62
|
-
#### Parameters
|
|
63
|
-
|
|
64
|
-
| Parameter | Type | Description |
|
|
65
|
-
| ------ | ------ | ------ |
|
|
66
|
-
| `capability` | [`IIntelligenceCapability`](Interface.IIntelligenceCapability) | The capability to register. |
|
|
67
|
-
|
|
68
|
-
#### Returns
|
|
69
|
-
|
|
70
|
-
`void`
|
|
71
|
-
|
|
72
|
-
#### Implementation of
|
|
73
|
-
|
|
74
|
-
[`IIntelligenceCapabilityRegistry`](Interface.IIntelligenceCapabilityRegistry).[`register`](Interface.IIntelligenceCapabilityRegistry#register)
|
|
75
|
-
|
|
76
|
-
***
|
|
77
|
-
|
|
78
|
-
### resolve()
|
|
79
|
-
|
|
80
|
-
```ts
|
|
81
|
-
resolve(intent, context):
|
|
82
|
-
| IIntelligenceCapability
|
|
83
|
-
| null;
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
Defined in: [IntelligenceCapabilityRegistry.ts:40](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-intelligence/src/IntelligenceCapabilityRegistry.ts#L40)
|
|
87
|
-
|
|
88
|
-
Resolves the most suitable capability for the given intent and context.
|
|
89
|
-
|
|
90
|
-
#### Parameters
|
|
91
|
-
|
|
92
|
-
| Parameter | Type | Description |
|
|
93
|
-
| ------ | ------ | ------ |
|
|
94
|
-
| `intent` | [`IIntelligenceIntent`](Interface.IIntelligenceIntent) | The structured intent to match against. |
|
|
95
|
-
| `context` | [`IIntelligenceContext`](Interface.IIntelligenceContext) | The aggregated context for the request. |
|
|
96
|
-
|
|
97
|
-
#### Returns
|
|
98
|
-
|
|
99
|
-
\| [`IIntelligenceCapability`](Interface.IIntelligenceCapability)
|
|
100
|
-
\| `null`
|
|
101
|
-
|
|
102
|
-
The matching capability, or `null` if none qualifies.
|
|
103
|
-
|
|
104
|
-
#### Implementation of
|
|
105
|
-
|
|
106
|
-
[`IIntelligenceCapabilityRegistry`](Interface.IIntelligenceCapabilityRegistry).[`resolve`](Interface.IIntelligenceCapabilityRegistry#resolve)
|