@breadstone/archipel-mcp 0.0.54 → 0.0.56
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-image-generation.md +101 -0
- package/data/guides/ai-realtime-voice.md +85 -473
- package/data/guides/ai-text-generation.md +98 -635
- package/data/guides/health-indicators.md +67 -66
- package/data/guides/index.md +2 -1
- package/data/guides/intelligence-prompts-warm-up.md +81 -312
- package/data/packages/platform-intelligence/api/Class.AnthropicIntelligenceProviderAdapter.md +122 -0
- package/data/packages/platform-intelligence/api/Class.GatewayIntelligenceProviderAdapter.md +122 -0
- package/data/packages/platform-intelligence/api/Class.GoogleIntelligenceProviderAdapter.md +122 -0
- package/data/packages/platform-intelligence/api/Class.GrokIntelligenceProviderAdapter.md +122 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceAgent.md +95 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceAgentFactory.md +11 -23
- package/data/packages/platform-intelligence/api/Class.IntelligenceEmbeddingGenerator.md +25 -21
- package/data/packages/platform-intelligence/api/Class.IntelligenceHealthIndicator.md +15 -10
- package/data/packages/platform-intelligence/api/Class.IntelligenceImageGenerator.md +117 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceLanguageGenerator.md +159 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceModule.md +2 -2
- package/data/packages/platform-intelligence/api/Class.IntelligencePromptExecutor.md +6 -6
- package/data/packages/platform-intelligence/api/Class.IntelligencePromptPolicyPort.md +1 -1
- package/data/packages/platform-intelligence/api/Class.IntelligenceProviderAdapterPort.md +104 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceProviderAssetUploader.md +21 -15
- package/data/packages/platform-intelligence/api/Class.IntelligenceProviderDiagnostics.md +55 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceProviderError.md +14 -4
- package/data/packages/platform-intelligence/api/Class.IntelligenceProviderRegistry.md +68 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeError.md +9 -9
- package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeMeteringPort.md +1 -1
- package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeSessionFactory.md +8 -8
- package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeSessionPort.md +18 -18
- package/data/packages/platform-intelligence/api/Class.IntelligenceReranker.md +58 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceSpeechGenerator.md +117 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceToolBase.md +14 -16
- package/data/packages/platform-intelligence/api/Class.IntelligenceToolRegistry.md +14 -18
- package/data/packages/platform-intelligence/api/Class.IntelligenceTranscriptionGenerator.md +139 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceVideoGenerator.md +117 -0
- package/data/packages/platform-intelligence/api/Class.MiMoIntelligenceProviderAdapter.md +122 -0
- package/data/packages/platform-intelligence/api/Class.OpenAIIntelligenceProviderAdapter.md +122 -0
- package/data/packages/platform-intelligence/api/Function.createAnthropicAdvisor20260301Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicBash20241022Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicBash20250124Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20250522Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20250825Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20260120Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20241022Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20250124Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20251124Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicMemory20250818Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20241022Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250124Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250429Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250728Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicToolSearchBM2520251119Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicToolSearchRegex20251119Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicWebFetch20250910Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicWebFetch20260209Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicWebSearch20250305Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createAnthropicWebSearch20260209Tool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleCodeExecutionTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleEnterpriseWebSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleFileSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleGoogleMapsTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleGoogleSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleUrlContextTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGoogleVertexRagStoreTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokCodeExecutionTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokFileSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokMcpServerTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokViewImageTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokViewXVideoTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokWebSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createGrokXSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createIntelligenceJsonSchema.md +31 -0
- package/data/packages/platform-intelligence/api/Function.createIntelligenceTool.md +2 -2
- package/data/packages/platform-intelligence/api/Function.createMimoCustomTool.md +5 -5
- package/data/packages/platform-intelligence/api/Function.createOpenAIApplyPatchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAICodeInterpreterTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAICustomTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIFileSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIImageGenerationTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAILocalShellTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIMcpTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIShellTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIToolSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIWebSearchPreviewTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.createOpenAIWebSearchTool.md +1 -1
- package/data/packages/platform-intelligence/api/Function.defineIntelligenceTool.md +31 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceAgentConfiguration.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingBatchOptions.md +140 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingBatchResult.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingOptions.md +130 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingResult.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceFileUploadOptions.md +118 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceFileUploadResult.md +60 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceGeneratedFile.md +40 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceGenerationStepStartEvent.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceImageGenerationOptions.md +186 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceImageGenerationResult.md +60 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceLanguageCompletion.md +141 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceLanguageGenerationOptions.md +250 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceLanguageStream.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModelReference.md +34 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModelRequestOptions.md +72 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModelStatus.md +30 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModuleOptions.md +54 -26
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceObjectStream.md +56 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePrompt.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptDefinition.md +14 -14
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptEffectivePolicy.md +1 -1
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptExecutionPolicy.md +1 -1
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptExecutionResult.md +15 -27
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderConfiguration.md +10 -10
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderLoadRequest.md +54 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderProbeResult.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeModuleOptions.md +9 -21
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeSessionOptions.md +23 -11
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeUsage.md +174 -10
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRequestOptions.md +114 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRerankingOptions.md +156 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRerankingResult.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSkillUploadOptions.md +110 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSkillUploadResult.md +80 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSpeechGenerationOptions.md +180 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSpeechGenerationResult.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceStreamingTranscriptionOptions.md +155 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTool.md +7 -10
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolCall.md +40 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolDefinition.md +91 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolExecutionEndEvent.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolExecutionStartEvent.md +30 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolRegistry.md +4 -4
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTranscriptionOptions.md +130 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTranscriptionResult.md +84 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTranscriptionStream.md +97 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceUsage.md +197 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceVideoGenerationOptions.md +245 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceVideoGenerationResult.md +50 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IIntelligenceModelMessage.md +43 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IIntelligencePromptModelRequirement.md +2 -2
- package/data/packages/platform-intelligence/api/TypeAlias.IIntelligenceSchema.md +70 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceCapability.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceDefaultModels.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceJsonValue.md +22 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligencePromptDefinitionConfiguration.md +2 -2
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligencePromptGenerationOptions.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceProviderName.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceProviderOptions.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceProviderProbeStatus.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceProviderToolOptions.md +17 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeMeteringEvent.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRequestTimeouts.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceToolChoice.md +21 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceToolOutput.md +22 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceToolSet.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceTranscriptionStreamPart.md +46 -0
- package/data/packages/platform-intelligence/api/Variable.AI_GATEWAY_API_KEY.md +14 -0
- package/data/packages/platform-intelligence/api/Variable.AI_GATEWAY_BASE_URL.md +14 -0
- package/data/packages/platform-intelligence/api/Variable.AI_GATEWAY_CONFIG_ENTRIES.md +14 -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 +2 -2
- 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.IntelligenceCapabilityNames.md +40 -0
- package/data/packages/platform-intelligence/api/Variable.IntelligenceProviderNames.md +2 -0
- package/data/packages/platform-intelligence/api/Variable.PLATFORM_INTELLIGENCE_CONFIG_ENTRIES.md +2 -2
- package/data/packages/platform-intelligence/api/index.md +83 -32
- package/data/packages/platform-intelligence/index.md +81 -622
- package/package.json +1 -1
- package/data/packages/index.md +0 -8
- package/data/packages/platform-analytics/index.md +0 -209
- package/data/packages/platform-authentication/index.md +0 -725
- package/data/packages/platform-blob-storage/index.md +0 -416
- package/data/packages/platform-bootstrap/index.md +0 -162
- package/data/packages/platform-caching/index.md +0 -167
- package/data/packages/platform-configuration/index.md +0 -226
- package/data/packages/platform-core/index.md +0 -504
- package/data/packages/platform-cryptography/index.md +0 -142
- package/data/packages/platform-database/index.md +0 -337
- package/data/packages/platform-documents/index.md +0 -255
- package/data/packages/platform-esigning/index.md +0 -710
- package/data/packages/platform-feature-flags/index.md +0 -103
- package/data/packages/platform-health/index.md +0 -141
- package/data/packages/platform-intelligence/api/Class.IntelligenceMediaGenerator.md +0 -118
- package/data/packages/platform-intelligence/api/Class.IntelligenceStructuredGenerator.md +0 -70
- package/data/packages/platform-intelligence/api/Class.IntelligenceTelemetryRegistry.md +0 -44
- package/data/packages/platform-intelligence/api/Class.IntelligenceTextGenerator.md +0 -138
- package/data/packages/platform-intelligence/api/Function.createProviderOptions.md +0 -39
- package/data/packages/platform-intelligence/api/Function.loadAnthropicLanguageModel.md +0 -26
- package/data/packages/platform-intelligence/api/Function.loadGoogleLanguageModel.md +0 -26
- package/data/packages/platform-intelligence/api/Function.loadGoogleRealtimeModel.md +0 -25
- package/data/packages/platform-intelligence/api/Function.loadGrokLanguageModel.md +0 -26
- package/data/packages/platform-intelligence/api/Function.loadGrokRealtimeModel.md +0 -25
- package/data/packages/platform-intelligence/api/Function.loadMimoLanguageModel.md +0 -26
- package/data/packages/platform-intelligence/api/Function.loadOpenAILanguageModel.md +0 -26
- package/data/packages/platform-intelligence/api/Function.loadOpenAIRealtimeModel.md +0 -25
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceCompletionUsage.md +0 -46
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextCompletion.md +0 -180
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextGenerationOptions.md +0 -144
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextGenerator.md +0 -78
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextStreamingOptions.md +0 -170
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceLanguageModelLoader.md +0 -24
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceLanguageModelLoaders.md +0 -14
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeModelLoader.md +0 -25
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeModelLoaders.md +0 -14
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceTextStream.md +0 -14
- package/data/packages/platform-logging/index.md +0 -150
- package/data/packages/platform-mailing/index.md +0 -470
- package/data/packages/platform-mapping/index.md +0 -123
- package/data/packages/platform-mcp/index.md +0 -335
- package/data/packages/platform-openapi/index.md +0 -207
- package/data/packages/platform-payments/index.md +0 -610
- package/data/packages/platform-queue/index.md +0 -192
- package/data/packages/platform-reporting/index.md +0 -233
- package/data/packages/platform-resources/index.md +0 -137
- package/data/packages/platform-telemetry/index.md +0 -262
|
@@ -1,627 +1,86 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
3
|
-
description:
|
|
4
|
-
order: 16
|
|
5
|
-
tags: [intelligence, ai, openai, anthropic, google, grok, text-generation, streaming, realtime, voice, metering, tool-calling, health]
|
|
6
|
-
package: '@breadstone/archipel-platform-intelligence'
|
|
2
|
+
title: Platform Intelligence
|
|
3
|
+
description: Provider-neutral language, embedding, image, speech, transcription, video, reranking, realtime, agent, file, and skill infrastructure for NestJS.
|
|
7
4
|
---
|
|
8
5
|
|
|
9
|
-
#
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
IntelligenceModule.register({
|
|
27
|
-
providerLoaders: {
|
|
28
|
-
[IntelligenceProviderNames.OpenAI]: loadOpenAILanguageModel,
|
|
29
|
-
},
|
|
30
|
-
}),
|
|
31
|
-
],
|
|
32
|
-
})
|
|
33
|
-
export class AppModule {}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
## Reusable Prompts
|
|
39
|
-
|
|
40
|
-
Use `intelligencePrompt()` to keep a prompt's identity, version, schemas,
|
|
41
|
-
instructions, messages, and execution requirements in one pure definition.
|
|
42
|
-
Bind already prepared feature data with `.with(...)` and execute the resulting
|
|
43
|
-
invocation through the NestJS `IntelligencePromptExecutor`.
|
|
44
|
-
|
|
45
|
-
For a guided first implementation, see
|
|
46
|
-
[Intelligence Prompts Warm-up](/guides/intelligence-prompts-warm-up).
|
|
47
|
-
|
|
48
|
-
```typescript
|
|
49
|
-
import { Injectable } from '@nestjs/common';
|
|
50
|
-
import { z } from 'zod';
|
|
51
|
-
import {
|
|
52
|
-
intelligencePrompt,
|
|
53
|
-
IntelligencePromptExecutor,
|
|
54
|
-
} from '@breadstone/archipel-platform-intelligence';
|
|
55
|
-
|
|
56
|
-
const DuplicateDetectionPrompt = intelligencePrompt({
|
|
57
|
-
name: 'crm.duplicate-detection',
|
|
58
|
-
version: 1,
|
|
59
|
-
mode: 'object',
|
|
60
|
-
inputSchema: z.object({
|
|
61
|
-
sourceId: z.number().int(),
|
|
62
|
-
candidateIds: z.array(z.number().int()),
|
|
63
|
-
}),
|
|
64
|
-
outputSchema: z.object({
|
|
65
|
-
scores: z.array(z.object({
|
|
66
|
-
id: z.number().int(),
|
|
67
|
-
score: z.number().min(0).max(100),
|
|
68
|
-
})),
|
|
69
|
-
}),
|
|
70
|
-
system: () => [
|
|
71
|
-
'Score duplicate candidates using only the supplied fields.',
|
|
72
|
-
'Do not infer facts from missing data.',
|
|
73
|
-
],
|
|
74
|
-
messages: ({ input }) => [
|
|
75
|
-
{ role: 'user', content: JSON.stringify(input) },
|
|
76
|
-
],
|
|
77
|
-
execution: {
|
|
78
|
-
options: { temperature: 0, maxOutputTokens: 800 },
|
|
79
|
-
model: { strategy: 'automatic' },
|
|
80
|
-
requiredCapabilities: ['structuredOutput'],
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
export function duplicateDetectionPrompt(sourceId: number, candidateIds: ReadonlyArray<number>) {
|
|
85
|
-
return DuplicateDetectionPrompt.with({ sourceId, candidateIds });
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
@Injectable()
|
|
89
|
-
export class DuplicateDetectionService {
|
|
90
|
-
public constructor(private readonly prompts: IntelligencePromptExecutor) {}
|
|
91
|
-
|
|
92
|
-
public async score(sourceId: number, candidateIds: ReadonlyArray<number>) {
|
|
93
|
-
const execution = await this.prompts.execute(
|
|
94
|
-
duplicateDetectionPrompt(sourceId, candidateIds),
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
return execution.output.scores;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
6
|
+
# Platform Intelligence
|
|
7
|
+
|
|
8
|
+
Applications depend on Archipel capability facades and register only the
|
|
9
|
+
provider subpaths they use. Provider SDKs, ESM loading, model construction,
|
|
10
|
+
timeouts, retries, and error normalization stay inside the package.
|
|
11
|
+
|
|
12
|
+
```mermaid
|
|
13
|
+
flowchart LR
|
|
14
|
+
App["Application services"] --> Facades["Archipel capability facades"]
|
|
15
|
+
Facades --> Registry["Provider registry"]
|
|
16
|
+
Registry --> Port["IntelligenceProviderAdapterPort"]
|
|
17
|
+
Port --> OpenAI["/provider/openai"]
|
|
18
|
+
Port --> Anthropic["/provider/anthropic"]
|
|
19
|
+
Port --> Google["/provider/google"]
|
|
20
|
+
Port --> Grok["/provider/grok"]
|
|
21
|
+
Port --> MiMo["/provider/mimo"]
|
|
22
|
+
Port --> Gateway["/provider/gateway"]
|
|
100
23
|
```
|
|
101
24
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
[IntelligenceProviderNames.Google]: loadGoogleRealtimeModel,
|
|
165
|
-
[IntelligenceProviderNames.Grok]: loadGrokRealtimeModel,
|
|
166
|
-
},
|
|
167
|
-
meteringAdapter: RealtimeMeteringAdapter,
|
|
168
|
-
meteringIntervalMs: 30_000,
|
|
169
|
-
},
|
|
170
|
-
}),
|
|
171
|
-
],
|
|
172
|
-
})
|
|
173
|
-
export class RealtimeModule {}
|
|
174
|
-
|
|
175
|
-
@Injectable()
|
|
176
|
-
export class RealtimeConsultationService {
|
|
177
|
-
public constructor(private readonly sessions: IntelligenceRealtimeSessionFactory) {}
|
|
178
|
-
|
|
179
|
-
public async open(consultationId: string): Promise<void> {
|
|
180
|
-
const session = await this.sessions.createSession({
|
|
181
|
-
sessionId: consultationId,
|
|
182
|
-
model: 'gpt-realtime',
|
|
183
|
-
sessionConfiguration: {
|
|
184
|
-
instructions: 'Transcribe the consultation and answer concisely.',
|
|
185
|
-
inputAudioFormat: { type: 'audio/pcm', rate: 24_000 },
|
|
186
|
-
inputAudioTranscription: {},
|
|
187
|
-
outputModalities: ['text', 'audio'],
|
|
188
|
-
turnDetection: { type: 'server-vad' },
|
|
189
|
-
},
|
|
190
|
-
onEvent: forwardToAuthenticatedClient,
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
await session.connect();
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
| Provider | Archipel loader | Example model |
|
|
199
|
-
| --- | --- | --- |
|
|
200
|
-
| OpenAI | `loadOpenAIRealtimeModel` | `gpt-realtime` |
|
|
201
|
-
| Google | `loadGoogleRealtimeModel` | `gemini-3.1-flash-live-preview` |
|
|
202
|
-
| xAI / Grok | `loadGrokRealtimeModel` | `grok-voice-latest` |
|
|
203
|
-
|
|
204
|
-
### Metering and audit
|
|
205
|
-
|
|
206
|
-
The application-supplied `IntelligenceRealtimeMeteringPort` receives four
|
|
207
|
-
idempotently identifiable event types:
|
|
208
|
-
|
|
209
|
-
| Event | Meaning |
|
|
210
|
-
| --- | --- |
|
|
211
|
-
| `session-started` | One upstream provider connection opened |
|
|
212
|
-
| `billing-interval` | Elapsed provider-independent usage, every 30 seconds by default and once more for the final partial interval |
|
|
213
|
-
| `provider-usage` | Exact token and modality counts when present in the raw provider event |
|
|
214
|
-
| `session-ended` | Connection duration and close reason |
|
|
215
|
-
|
|
216
|
-
An application can debit its own token ledger and append its AI audit log in
|
|
217
|
-
the same transaction keyed by `eventId`. Time-based charging remains available
|
|
218
|
-
when a provider omits exact usage; exact token usage remains available for cost
|
|
219
|
-
reconciliation when reported.
|
|
220
|
-
|
|
221
|
-
### Failure and persistence rules
|
|
222
|
-
|
|
223
|
-
- Provider token requests and WebSocket setup are capped at five seconds and
|
|
224
|
-
transient token creation is retried at most twice.
|
|
225
|
-
- Inbound, outbound, metering, and WebSocket buffers are bounded.
|
|
226
|
-
- Normalized events preserve provider wire order.
|
|
227
|
-
- Nest shutdown closes all owned sessions and flushes metering.
|
|
228
|
-
- Archipel does not silently reconnect a lost provider conversation because a
|
|
229
|
-
new connection has different conversational state.
|
|
230
|
-
- The consuming application must persist audio chunks and transcript progress
|
|
231
|
-
durably before acknowledging them, then reconstruct context when it opens a
|
|
232
|
-
replacement provider session.
|
|
233
|
-
|
|
234
|
-
---
|
|
235
|
-
|
|
236
|
-
## Provider Subpaths
|
|
237
|
-
|
|
238
|
-
Import only the providers you need:
|
|
239
|
-
|
|
240
|
-
| Provider | Subpath |
|
|
241
|
-
| --------- | ---------------------------------------------------------------- |
|
|
242
|
-
| OpenAI | `@breadstone/archipel-platform-intelligence/providers/openai` |
|
|
243
|
-
| Anthropic | `@breadstone/archipel-platform-intelligence/providers/anthropic` |
|
|
244
|
-
| Google | `@breadstone/archipel-platform-intelligence/providers/google` |
|
|
245
|
-
| Grok | `@breadstone/archipel-platform-intelligence/providers/grok` |
|
|
246
|
-
|
|
247
|
-
Provider-native tool wrappers are exported through matching `/tools` subpaths, for example `@breadstone/archipel-platform-intelligence/providers/grok/tools`.
|
|
248
|
-
|
|
249
|
-
---
|
|
250
|
-
|
|
251
|
-
## Tool Registration
|
|
252
|
-
|
|
253
|
-
Tools can be normal Nest providers or direct `IIntelligenceTool` instances. Register classes for custom application tools, or register provider-native wrappers from provider subpaths.
|
|
254
|
-
|
|
255
|
-
```typescript
|
|
256
|
-
import { Injectable, Module } from '@nestjs/common';
|
|
257
|
-
import { tool, type Tool } from 'ai';
|
|
258
|
-
import { z } from 'zod';
|
|
259
|
-
import { IntelligenceModule, IntelligenceProviderNames, IntelligenceToolBase } from '@breadstone/archipel-platform-intelligence';
|
|
260
|
-
import { loadOpenAILanguageModel } from '@breadstone/archipel-platform-intelligence/providers/openai';
|
|
261
|
-
|
|
262
|
-
interface ICustomerSearchInput {
|
|
263
|
-
readonly query: string;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
interface ICustomerSearchOutput {
|
|
267
|
-
readonly customers: ReadonlyArray<string>;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
@Injectable()
|
|
271
|
-
export class CustomerSearchTool extends IntelligenceToolBase<ICustomerSearchInput, ICustomerSearchOutput> {
|
|
272
|
-
public override get name(): string {
|
|
273
|
-
return 'searchCustomers';
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
public override get tool(): Tool<ICustomerSearchInput, ICustomerSearchOutput> {
|
|
277
|
-
return tool({
|
|
278
|
-
description: 'Searches customers by name, email, or company.',
|
|
279
|
-
inputSchema: z.object({
|
|
280
|
-
query: z.string().describe('Customer search query'),
|
|
281
|
-
}),
|
|
282
|
-
execute: async (input) => ({ customers: [input.query] }),
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
@Module({
|
|
288
|
-
imports: [
|
|
289
|
-
IntelligenceModule.register({
|
|
290
|
-
providerLoaders: {
|
|
291
|
-
[IntelligenceProviderNames.OpenAI]: loadOpenAILanguageModel,
|
|
292
|
-
},
|
|
293
|
-
tools: [CustomerSearchTool],
|
|
294
|
-
}),
|
|
295
|
-
],
|
|
296
|
-
})
|
|
297
|
-
export class AppModule {}
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
### Provider-Native Tools
|
|
301
|
-
|
|
302
|
-
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.
|
|
303
|
-
|
|
304
|
-
```typescript
|
|
305
|
-
import { Module } from '@nestjs/common';
|
|
306
|
-
import { IntelligenceModule, IntelligenceProviderNames } from '@breadstone/archipel-platform-intelligence';
|
|
307
|
-
import { loadOpenAILanguageModel } from '@breadstone/archipel-platform-intelligence/providers/openai';
|
|
308
|
-
import { createOpenAIWebSearchTool } from '@breadstone/archipel-platform-intelligence/providers/openai/tools';
|
|
309
|
-
|
|
310
|
-
@Module({
|
|
311
|
-
imports: [
|
|
312
|
-
IntelligenceModule.register({
|
|
313
|
-
providerLoaders: {
|
|
314
|
-
[IntelligenceProviderNames.OpenAI]: loadOpenAILanguageModel,
|
|
315
|
-
},
|
|
316
|
-
tools: [createOpenAIWebSearchTool({ searchContextSize: 'medium' })],
|
|
317
|
-
}),
|
|
318
|
-
],
|
|
319
|
-
})
|
|
320
|
-
export class AppModule {}
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
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; versioned Anthropic web search, web fetch, code execution, bash, text editor, computer, memory, tool search, and advisor tools; and Grok web search, X search, file search, code execution, MCP, image understanding, and X-video understanding.
|
|
324
|
-
|
|
325
|
-
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.
|
|
326
|
-
|
|
327
|
-
### Native AI SDK Passthrough
|
|
328
|
-
|
|
329
|
-
`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.
|
|
330
|
-
|
|
331
|
-
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.
|
|
332
|
-
|
|
333
|
-
```typescript
|
|
334
|
-
import { openai } from '@ai-sdk/openai';
|
|
335
|
-
import { Injectable, Module } from '@nestjs/common';
|
|
336
|
-
import { IntelligenceModule, IntelligenceTextGenerator } from '@breadstone/archipel-platform-intelligence';
|
|
337
|
-
|
|
338
|
-
@Module({
|
|
339
|
-
imports: [
|
|
340
|
-
IntelligenceModule.register({
|
|
341
|
-
validateOnModuleInit: false,
|
|
342
|
-
}),
|
|
343
|
-
],
|
|
344
|
-
})
|
|
345
|
-
export class RawAiSdkModule {}
|
|
346
|
-
|
|
347
|
-
@Injectable()
|
|
348
|
-
export class RawAiSdkRecipeService {
|
|
349
|
-
public constructor(private readonly _textGenerator: IntelligenceTextGenerator) {}
|
|
350
|
-
|
|
351
|
-
public async answerWithNativeOptions(): Promise<string> {
|
|
352
|
-
const completion = await this._textGenerator.generateText(
|
|
353
|
-
{
|
|
354
|
-
system: 'Answer concisely and include assumptions.',
|
|
355
|
-
prompt: 'Compare the operational risks of outdoor work tomorrow.',
|
|
356
|
-
},
|
|
357
|
-
{
|
|
358
|
-
model: openai.responses('gpt-5'),
|
|
359
|
-
headers: { 'x-use-case': 'outdoor-risk' },
|
|
360
|
-
providerOptions: {
|
|
361
|
-
openai: {
|
|
362
|
-
reasoningEffort: 'medium',
|
|
363
|
-
},
|
|
364
|
-
},
|
|
365
|
-
seed: 42,
|
|
366
|
-
},
|
|
367
|
-
);
|
|
368
|
-
|
|
369
|
-
return completion.text;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
### Outdoor Order Weather Risk Example
|
|
375
|
-
|
|
376
|
-
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.
|
|
377
|
-
|
|
378
|
-
```typescript
|
|
379
|
-
import { Injectable, Module } from '@nestjs/common';
|
|
380
|
-
import { stepCountIs, tool, type Tool } from 'ai';
|
|
381
|
-
import { z } from 'zod';
|
|
382
|
-
import {
|
|
383
|
-
IntelligenceModule,
|
|
384
|
-
IntelligenceProviderNames,
|
|
385
|
-
IntelligenceTextGenerator,
|
|
386
|
-
IntelligenceToolBase,
|
|
387
|
-
type IIntelligenceTextCompletion,
|
|
388
|
-
} from '@breadstone/archipel-platform-intelligence';
|
|
389
|
-
import { OpenAIIntelligenceToolNames, loadOpenAILanguageModel } from '@breadstone/archipel-platform-intelligence/providers/openai';
|
|
390
|
-
import { createOpenAIWebSearchTool } from '@breadstone/archipel-platform-intelligence/providers/openai/tools';
|
|
391
|
-
|
|
392
|
-
interface IOutdoorOrderLookupInput {
|
|
393
|
-
readonly date: string;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
interface IOutdoorOrderLookupOutput {
|
|
397
|
-
readonly date: string;
|
|
398
|
-
readonly orders: ReadonlyArray<{
|
|
399
|
-
readonly id: string;
|
|
400
|
-
readonly location: string;
|
|
401
|
-
readonly scheduledAt: string;
|
|
402
|
-
readonly outdoorWork: boolean;
|
|
403
|
-
}>;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
@Injectable()
|
|
407
|
-
export class OutdoorOrdersTool extends IntelligenceToolBase<IOutdoorOrderLookupInput, IOutdoorOrderLookupOutput> {
|
|
408
|
-
public override get name(): string {
|
|
409
|
-
return 'get_outdoor_orders';
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
public override get tool(): Tool<IOutdoorOrderLookupInput, IOutdoorOrderLookupOutput> {
|
|
413
|
-
return tool({
|
|
414
|
-
description: 'Returns outdoor field orders for the current tenant and date.',
|
|
415
|
-
inputSchema: z.object({
|
|
416
|
-
date: z.string().describe('Date in YYYY-MM-DD format'),
|
|
417
|
-
}),
|
|
418
|
-
execute: async (input: IOutdoorOrderLookupInput) => ({
|
|
419
|
-
date: input.date,
|
|
420
|
-
orders: [
|
|
421
|
-
{
|
|
422
|
-
id: 'ord_4711',
|
|
423
|
-
location: 'Berlin',
|
|
424
|
-
scheduledAt: `${input.date}T08:00:00+02:00`,
|
|
425
|
-
outdoorWork: true,
|
|
426
|
-
},
|
|
427
|
-
],
|
|
428
|
-
}),
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
@Injectable()
|
|
434
|
-
export class OutdoorOrderRiskAnalysisService {
|
|
435
|
-
public constructor(private readonly _textGenerator: IntelligenceTextGenerator) {}
|
|
436
|
-
|
|
437
|
-
public async analyseOutdoorOrders(date: string): Promise<{ readonly text: string; readonly sources: IIntelligenceTextCompletion['sources'] }> {
|
|
438
|
-
const result = await this._textGenerator.generateText(
|
|
439
|
-
{
|
|
440
|
-
system: 'You assess weather-related risks for tenant outdoor field orders.',
|
|
441
|
-
messages: [{ role: 'user', content: `Review outdoor field orders for ${date} and flag weather-related risks.` }],
|
|
442
|
-
},
|
|
443
|
-
{
|
|
444
|
-
toolChoice: 'auto',
|
|
445
|
-
activeTools: ['get_outdoor_orders', OpenAIIntelligenceToolNames.WebSearch],
|
|
446
|
-
stopWhen: stepCountIs(3),
|
|
447
|
-
},
|
|
448
|
-
);
|
|
449
|
-
|
|
450
|
-
return {
|
|
451
|
-
text: result.text,
|
|
452
|
-
sources: result.sources,
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
@Module({
|
|
458
|
-
imports: [
|
|
459
|
-
IntelligenceModule.register({
|
|
460
|
-
providerLoaders: {
|
|
461
|
-
[IntelligenceProviderNames.OpenAI]: loadOpenAILanguageModel,
|
|
462
|
-
},
|
|
463
|
-
tools: [
|
|
464
|
-
OutdoorOrdersTool,
|
|
465
|
-
createOpenAIWebSearchTool({
|
|
466
|
-
externalWebAccess: true,
|
|
467
|
-
searchContextSize: 'medium',
|
|
468
|
-
filters: { allowedDomains: ['dwd.de'] },
|
|
469
|
-
}),
|
|
470
|
-
],
|
|
471
|
-
}),
|
|
472
|
-
],
|
|
473
|
-
providers: [OutdoorOrderRiskAnalysisService],
|
|
474
|
-
})
|
|
475
|
-
export class OutdoorOrderRiskAnalysisModule {}
|
|
476
|
-
```
|
|
477
|
-
|
|
478
|
-
---
|
|
479
|
-
|
|
480
|
-
## Text Generation
|
|
481
|
-
|
|
482
|
-
Inject `IntelligenceTextGenerator` and call `generateText()`:
|
|
483
|
-
|
|
484
|
-
```typescript
|
|
485
|
-
import { Injectable } from '@nestjs/common';
|
|
486
|
-
import type { Prompt } from 'ai';
|
|
487
|
-
import { IntelligenceTextGenerator } from '@breadstone/archipel-platform-intelligence';
|
|
488
|
-
|
|
489
|
-
@Injectable()
|
|
490
|
-
export class SummaryService {
|
|
491
|
-
constructor(private readonly _textGenerator: IntelligenceTextGenerator) {}
|
|
492
|
-
|
|
493
|
-
async summarize(content: string): Promise<string> {
|
|
494
|
-
const prompt: Prompt = {
|
|
495
|
-
system: 'You are a concise summarizer.',
|
|
496
|
-
messages: [{ role: 'user', content }],
|
|
497
|
-
};
|
|
498
|
-
|
|
499
|
-
const result = await this._textGenerator.generateText(prompt, {
|
|
500
|
-
temperature: 0.3,
|
|
501
|
-
toolChoice: 'auto',
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
return result.text;
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
```
|
|
508
|
-
|
|
509
|
-
---
|
|
510
|
-
|
|
511
|
-
## Streaming
|
|
512
|
-
`streamText()` uses the same registered tools and returns the native AI SDK stream result.
|
|
513
|
-
|
|
514
|
-
```typescript
|
|
515
|
-
const stream = await this._textGenerator.streamText(prompt, {
|
|
516
|
-
activeTools: ['searchCustomers'],
|
|
517
|
-
stopWhen: stepCountIs(3),
|
|
518
|
-
});
|
|
519
|
-
|
|
520
|
-
return stream.toUIMessageStreamResponse();
|
|
521
|
-
```
|
|
522
|
-
|
|
523
|
-
---
|
|
524
|
-
|
|
525
|
-
## Environment Variables
|
|
526
|
-
|
|
527
|
-
| Variable | Description | Required |
|
|
528
|
-
| -------------------------------- | ---------------------------- | ------------------ |
|
|
529
|
-
| `OPENAI_API_KEY` | OpenAI API key | If using OpenAI |
|
|
530
|
-
| `ANTHROPIC_API_KEY` | Anthropic API key | If using Anthropic |
|
|
531
|
-
| `GOOGLE_API_KEY` | Google Generative AI API key | If using Google |
|
|
532
|
-
| `GROK_API_KEY` | Grok / xAI API key | If using Grok |
|
|
533
|
-
|
|
534
|
-
---
|
|
535
|
-
|
|
536
|
-
## Timeout & Retry
|
|
537
|
-
|
|
538
|
-
All `generateText()` calls include built-in resilience:
|
|
539
|
-
|
|
540
|
-
| Setting | Default | Description |
|
|
541
|
-
| ----------- | -------- | -------------------------------------------------------- |
|
|
542
|
-
| `timeoutMs` | `30000` | Abort the provider request after this many milliseconds |
|
|
543
|
-
| Max retries | `2` | Retryable errors are retried with exponential backoff |
|
|
544
|
-
| Backoff | 1s → 4s | Exponential with a 4-second cap |
|
|
545
|
-
|
|
546
|
-
Override the timeout per call via the options parameter:
|
|
547
|
-
|
|
548
|
-
```typescript
|
|
549
|
-
const result = await this._textGenerator.generateText(prompt, {
|
|
550
|
-
timeoutMs: 15_000,
|
|
551
|
-
});
|
|
552
|
-
```
|
|
553
|
-
|
|
554
|
-
All errors are wrapped in `IntelligenceProviderError` with `provider`, `model`, and `retryable` metadata.
|
|
555
|
-
|
|
556
|
-
---
|
|
557
|
-
|
|
558
|
-
## Error Handling
|
|
559
|
-
|
|
560
|
-
The library provides domain error classes for different failure scenarios:
|
|
561
|
-
|
|
562
|
-
| Error class | Code | When thrown |
|
|
563
|
-
| ---------------------------------- | ----------------------------- | --------------------------------------------------------------------- |
|
|
564
|
-
| `IntelligenceProviderError` | `INTELLIGENCE_PROVIDER` | Provider SDK failures during text generation |
|
|
565
|
-
| `IntelligenceRealtimeError` | Realtime phase metadata | Configuration, token, connect, send, receive, metering, or close failures |
|
|
566
|
-
| `IntelligenceValidationError` | `INTELLIGENCE_VALIDATION` | Invalid generation parameters (temperature, topP, maxOutputTokens) |
|
|
567
|
-
| `IntelligenceConfigurationError` | `INTELLIGENCE_CONFIGURATION` | Unsupported provider, missing API key, or missing provider loader |
|
|
568
|
-
|
|
569
|
-
```typescript
|
|
570
|
-
import {
|
|
571
|
-
IntelligenceProviderError,
|
|
572
|
-
IntelligenceValidationError,
|
|
573
|
-
IntelligenceConfigurationError,
|
|
574
|
-
} from '@breadstone/archipel-platform-intelligence';
|
|
575
|
-
```
|
|
576
|
-
|
|
577
|
-
---
|
|
578
|
-
|
|
579
|
-
## Lifecycle
|
|
580
|
-
|
|
581
|
-
`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. `IntelligenceRealtimeSessionFactory` implements `OnModuleDestroy`, closes all owned provider WebSockets, and flushes queued metering on shutdown.
|
|
582
|
-
|
|
583
|
-
Set `validateOnModuleInit: false` for a realtime-only module because that option
|
|
584
|
-
controls eager text-model initialization. When text and realtime are both
|
|
585
|
-
used, register the language-model loaders and keep the default eager
|
|
586
|
-
validation.
|
|
587
|
-
|
|
588
|
-
---
|
|
589
|
-
|
|
590
|
-
## Tool Registry Limits
|
|
591
|
-
|
|
592
|
-
`IntelligenceToolRegistry` enforces a maximum of **128** registered tools. Attempts to register beyond this limit throw `IntelligenceValidationError` to prevent unbounded memory growth.
|
|
593
|
-
|
|
594
|
-
---
|
|
595
|
-
|
|
596
|
-
## Health Check
|
|
597
|
-
|
|
598
|
-
The `IntelligenceHealthIndicator` verifies that provider configuration can be resolved and reports registered realtime providers plus active session count. If neither text nor realtime infrastructure is available, it reports `disabled: true`. Import it from the `/health` subpath:
|
|
599
|
-
|
|
600
|
-
```typescript
|
|
601
|
-
import { IntelligenceModule, IntelligenceProviderNames } from '@breadstone/archipel-platform-intelligence';
|
|
602
|
-
import { IntelligenceHealthIndicator } from '@breadstone/archipel-platform-intelligence/health';
|
|
603
|
-
import { loadOpenAILanguageModel } from '@breadstone/archipel-platform-intelligence/providers/openai';
|
|
604
|
-
import { HealthModule } from '@breadstone/archipel-platform-health';
|
|
605
|
-
|
|
606
|
-
@Module({
|
|
607
|
-
imports: [
|
|
608
|
-
IntelligenceModule.register({
|
|
609
|
-
providerLoaders: {
|
|
610
|
-
[IntelligenceProviderNames.OpenAI]: loadOpenAILanguageModel,
|
|
611
|
-
},
|
|
612
|
-
}),
|
|
613
|
-
HealthModule.withIndicators([IntelligenceHealthIndicator]),
|
|
614
|
-
],
|
|
615
|
-
})
|
|
616
|
-
export class AppModule {}
|
|
617
|
-
```
|
|
618
|
-
|
|
619
|
-
| Key | Check | Dependencies |
|
|
620
|
-
| --- | ----- | ------------ |
|
|
621
|
-
| `intelligence` | `up` when provider configuration resolves, else `down`; includes realtime readiness when registered | `@Optional() IntelligenceTextGenerator`, `@Optional() IntelligenceRealtimeSessionFactory` |
|
|
622
|
-
|
|
623
|
-
---
|
|
624
|
-
|
|
625
|
-
## API Reference
|
|
626
|
-
|
|
627
|
-
See the full [API documentation](./api/) for all exported types, interfaces, and classes.
|
|
25
|
+
## Providers
|
|
26
|
+
|
|
27
|
+
| Provider | Import subpath | Configuration entries |
|
|
28
|
+
| ----------------- | ---------------------- | --------------------------- |
|
|
29
|
+
| OpenAI | `/provider/openai` | `OPENAI_CONFIG_ENTRIES` |
|
|
30
|
+
| Anthropic | `/provider/anthropic` | `ANTHROPIC_CONFIG_ENTRIES` |
|
|
31
|
+
| Google | `/provider/google` | `GOOGLE_CONFIG_ENTRIES` |
|
|
32
|
+
| xAI / Grok | `/provider/grok` | `GROK_CONFIG_ENTRIES` |
|
|
33
|
+
| Xiaomi MiMo | `/provider/mimo` | `MIMO_CONFIG_ENTRIES` |
|
|
34
|
+
| Vercel AI Gateway | `/provider/gateway` | `AI_GATEWAY_CONFIG_ENTRIES` |
|
|
35
|
+
|
|
36
|
+
OpenAI, Anthropic, Google, Grok, and MiMo also expose provider-owned tools from
|
|
37
|
+
their `/tools` subpaths. Provider-specific environment keys are exported only
|
|
38
|
+
from the corresponding provider entrypoint; the package root stays
|
|
39
|
+
provider-neutral. Provider entrypoints do not re-export tool factories, so
|
|
40
|
+
provider tools remain a separate opt-in runtime boundary.
|
|
41
|
+
|
|
42
|
+
The standard package test target first runs the Nx package build and then the
|
|
43
|
+
provider-entrypoint and generator-topology contract tests. The build compiles
|
|
44
|
+
every declared subpath, while the tests keep package exports, TypeScript paths,
|
|
45
|
+
provider-local barrels, optional provider dependencies, and the
|
|
46
|
+
provider-neutral root surface synchronized.
|
|
47
|
+
|
|
48
|
+
## Capability Surface
|
|
49
|
+
|
|
50
|
+
| Surface | Responsibility |
|
|
51
|
+
| ------------------------------------ | ---------------------------------------------- |
|
|
52
|
+
| `IntelligenceLanguageGenerator` | Text, structured output, streams, and tools |
|
|
53
|
+
| `IntelligenceEmbeddingGenerator` | Single and batch embeddings |
|
|
54
|
+
| `IntelligenceImageGenerator` | Image generation and editing |
|
|
55
|
+
| `IntelligenceSpeechGenerator` | Text-to-speech generation |
|
|
56
|
+
| `IntelligenceTranscriptionGenerator` | Bounded and live transcription |
|
|
57
|
+
| `IntelligenceVideoGenerator` | Text/image-to-video generation |
|
|
58
|
+
| `IntelligenceReranker` | Provider-neutral semantic ranking |
|
|
59
|
+
| `IntelligenceRealtimeSessionFactory` | Server-owned bidirectional audio/text sessions |
|
|
60
|
+
| `IntelligenceAgentFactory` | Bounded reusable tool-loop agents |
|
|
61
|
+
| `IntelligenceProviderAssetUploader` | Provider files and skills |
|
|
62
|
+
| `IntelligenceProviderDiagnostics` | Bounded provider/model probes |
|
|
63
|
+
|
|
64
|
+
## Normalized Usage
|
|
65
|
+
|
|
66
|
+
Capability results use `IIntelligenceUsage` to transport provider-reported
|
|
67
|
+
input, output, total, cache-read, cache-write, reasoning, and text/image/audio
|
|
68
|
+
modality counters. Missing counters are `null`, not zero. Image generation
|
|
69
|
+
reconciles the normalized result with provider metadata so text input, image
|
|
70
|
+
input, and generated image output remain separately accountable when the
|
|
71
|
+
provider exposes them.
|
|
72
|
+
|
|
73
|
+
Archipel deliberately does not assign monetary prices or application billing
|
|
74
|
+
units. Consumers persist and price the normalized usage according to their own
|
|
75
|
+
provider, model, currency, entitlement, and audit policies.
|
|
76
|
+
|
|
77
|
+
OpenAI video uses an internal asynchronous create/poll/download bridge because
|
|
78
|
+
the OpenAI AI SDK provider does not expose a video-model handle. The bridge is
|
|
79
|
+
owned by `/provider/openai`; applications continue to use the provider-neutral
|
|
80
|
+
`IntelligenceVideoGenerator` contract. The current OpenAI Videos API and Sora
|
|
81
|
+
2 models are scheduled to shut down on September 24, 2026, so their eventual
|
|
82
|
+
replacement remains isolated to that provider entry point.
|
|
83
|
+
|
|
84
|
+
See the [package README](https://github.com/RueDeRennes/archipel/tree/main/libs/platform-intelligence)
|
|
85
|
+
for registration and migration examples and the generated API pages for
|
|
86
|
+
contract details.
|