@breadstone/archipel-mcp 0.0.53 → 0.0.55
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 +96 -0
- package/data/guides/ai-realtime-voice.md +69 -464
- package/data/guides/ai-text-generation.md +95 -622
- package/data/guides/index.md +3 -1
- package/data/guides/intelligence-prompts-warm-up.md +138 -0
- package/data/packages/platform-intelligence/api/Class.AnthropicIntelligenceProviderAdapter.md +78 -0
- package/data/packages/platform-intelligence/api/Class.DefaultIntelligencePromptPolicyAdapter.md +54 -0
- package/data/packages/platform-intelligence/api/Class.GatewayIntelligenceProviderAdapter.md +78 -0
- package/data/packages/platform-intelligence/api/Class.GoogleIntelligenceProviderAdapter.md +78 -0
- package/data/packages/platform-intelligence/api/Class.GrokIntelligenceProviderAdapter.md +78 -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 +11 -7
- package/data/packages/platform-intelligence/api/Class.IntelligenceLanguageGenerator.md +159 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceMediaGenerator.md +60 -38
- package/data/packages/platform-intelligence/api/Class.IntelligenceModule.md +2 -2
- package/data/packages/platform-intelligence/api/Class.IntelligencePromptExecutor.md +88 -0
- package/data/packages/platform-intelligence/api/Class.IntelligencePromptPolicyPort.md +48 -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 +2 -2
- package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeSessionFactory.md +12 -12
- 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.IntelligenceToolBase.md +14 -16
- package/data/packages/platform-intelligence/api/Class.IntelligenceToolRegistry.md +10 -14
- package/data/packages/platform-intelligence/api/Class.MiMoIntelligenceProviderAdapter.md +78 -0
- package/data/packages/platform-intelligence/api/Class.OpenAIIntelligenceProviderAdapter.md +102 -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/Function.intelligencePrompt.md +31 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceAgentConfiguration.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingBatchOptions.md +124 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingBatchResult.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingOptions.md +114 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingResult.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceFileUploadOptions.md +102 -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 +170 -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 +234 -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 +52 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModelStatus.md +30 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModuleOptions.md +43 -25
- 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 +145 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptEffectivePolicy.md +30 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptExecutionContext.md +20 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptExecutionPolicy.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptExecutionResult.md +127 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptInvocation.md +49 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptPolicyRequest.md +60 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptRenderContext.md +26 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderAdapter.md +73 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderConfiguration.md +10 -10
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderLoadRequest.md +40 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderProbeResult.md +70 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeAudioFormat.md +3 -3
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeCloseEvent.md +4 -4
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeModuleOptions.md +9 -21
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeSessionConfiguration.md +11 -11
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeSessionOptions.md +11 -11
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeToolDefinition.md +5 -5
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeTranscriptionConfiguration.md +4 -4
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeTurnDetectionConfiguration.md +5 -5
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeUsage.md +10 -10
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRequestOptions.md +98 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRerankingOptions.md +140 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRerankingResult.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSkillUploadOptions.md +94 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSkillUploadResult.md +80 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSpeechGenerationOptions.md +164 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSpeechGenerationResult.md +50 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceStreamingTranscriptionOptions.md +139 -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 +114 -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 +40 -0
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceVideoGenerationOptions.md +229 -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 +25 -0
- 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.IntelligencePromptCapability.md +20 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligencePromptDefinitionConfiguration.md +29 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligencePromptGenerationOptions.md +16 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligencePromptLatency.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligencePromptMode.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligencePromptQuality.md +14 -0
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligencePromptReasoning.md +14 -0
- 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.IntelligenceRealtimeClientEvent.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeMetadataValue.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeMeteringEvent.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeServerEvent.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeStatus.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 +1 -1
- package/data/packages/platform-intelligence/api/index.md +98 -30
- 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.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 -168
- 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-intelligence/index.md +0 -549
- 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,683 +1,156 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: AI
|
|
3
|
-
description: Generate text
|
|
2
|
+
title: AI Language Generation
|
|
3
|
+
description: Generate text and structured output, stream results, use tools, and create agents without leaking provider SDKs.
|
|
4
4
|
order: 15
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
# AI
|
|
7
|
+
# AI Language Generation
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
`IntelligenceLanguageGenerator` is the provider-neutral language facade. It
|
|
10
|
+
owns plain text, schema-constrained objects, streaming, tool execution, result
|
|
11
|
+
normalization, retries, cancellation, and timeouts.
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
[AI Realtime Voice](./ai-realtime-voice) guide. Realtime sessions have a
|
|
13
|
-
different transport, lifecycle, persistence, and metering model from request-
|
|
14
|
-
or response-scoped text generation.
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## Installation
|
|
13
|
+
Consumer applications depend only on Archipel:
|
|
19
14
|
|
|
20
15
|
```bash
|
|
21
16
|
yarn add @breadstone/archipel-platform-intelligence
|
|
22
17
|
```
|
|
23
18
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
| Provider | Package |
|
|
27
|
-
| -------------- | ------------------- |
|
|
28
|
-
| **OpenAI** | `@ai-sdk/openai` |
|
|
29
|
-
| **Anthropic** | `@ai-sdk/anthropic` |
|
|
30
|
-
| **Google** | `@ai-sdk/google` |
|
|
31
|
-
| **Grok (xAI)** | `@ai-sdk/xai` |
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
# Example: OpenAI
|
|
35
|
-
yarn add @ai-sdk/openai
|
|
36
|
-
|
|
37
|
-
# Example: Grok / xAI
|
|
38
|
-
yarn add @ai-sdk/xai
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## Module Registration
|
|
44
|
-
|
|
45
|
-
Import `IntelligenceModule` into your application module. It exposes `IntelligenceTextGenerator` and `IntelligenceToolRegistry` as shared providers.
|
|
19
|
+
## Registration
|
|
46
20
|
|
|
47
21
|
```typescript
|
|
48
22
|
import { Module } from '@nestjs/common';
|
|
49
|
-
import {
|
|
50
|
-
|
|
23
|
+
import {
|
|
24
|
+
IntelligenceCapabilityNames,
|
|
25
|
+
IntelligenceModule,
|
|
26
|
+
IntelligenceProviderNames,
|
|
27
|
+
} from '@breadstone/archipel-platform-intelligence';
|
|
28
|
+
import { AnthropicIntelligenceProviderAdapter } from '@breadstone/archipel-platform-intelligence/anthropic';
|
|
29
|
+
import { OpenAIIntelligenceProviderAdapter } from '@breadstone/archipel-platform-intelligence/openai';
|
|
51
30
|
|
|
52
31
|
@Module({
|
|
53
32
|
imports: [
|
|
54
33
|
IntelligenceModule.register({
|
|
55
|
-
|
|
56
|
-
|
|
34
|
+
providerAdapters: [
|
|
35
|
+
new OpenAIIntelligenceProviderAdapter(),
|
|
36
|
+
new AnthropicIntelligenceProviderAdapter(),
|
|
37
|
+
],
|
|
38
|
+
defaultModels: {
|
|
39
|
+
[IntelligenceCapabilityNames.Language]: {
|
|
40
|
+
provider: IntelligenceProviderNames.OpenAI,
|
|
41
|
+
model: 'gpt-5.4-mini',
|
|
42
|
+
},
|
|
57
43
|
},
|
|
58
44
|
}),
|
|
59
45
|
],
|
|
60
46
|
})
|
|
61
|
-
export class
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Register only the provider loaders you install. The root entry does not import provider SDK packages.
|
|
65
|
-
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
## Configuration
|
|
69
|
-
|
|
70
|
-
All intelligence settings are read from environment variables via `ConfigService`. No direct `process.env` access is needed.
|
|
71
|
-
|
|
72
|
-
```dotenv
|
|
73
|
-
INTELLIGENCE_PROVIDER=openai
|
|
74
|
-
INTELLIGENCE_MODEL=gpt-4o-mini
|
|
75
|
-
INTELLIGENCE_API_KEY=sk-...
|
|
76
|
-
INTELLIGENCE_TEMPERATURE=0.7
|
|
77
|
-
INTELLIGENCE_TOP_P=1
|
|
78
|
-
INTELLIGENCE_MAX_OUTPUT_TOKENS=1024
|
|
79
|
-
INTELLIGENCE_BASE_URL= # optional — override for custom endpoints
|
|
47
|
+
export class ApplicationModule {}
|
|
80
48
|
```
|
|
81
49
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
| `INTELLIGENCE_PROVIDER` | Default model | Notes |
|
|
85
|
-
| ----------------------- | -------------------------- | ---------------------------------- |
|
|
86
|
-
| `openai` | `gpt-4o-mini` | OpenAI API |
|
|
87
|
-
| `anthropic` | `claude-sonnet-4-20250514` | Anthropic API |
|
|
88
|
-
| `google` | `gemini-2.0-flash` | Google Gemini API |
|
|
89
|
-
| `grok` | `grok-3-mini` | xAI Grok API |
|
|
90
|
-
|
|
91
|
-
Each provider resolves its API key and base URL from dedicated environment variables when the generic `INTELLIGENCE_API_KEY` is not set:
|
|
92
|
-
|
|
93
|
-
```dotenv
|
|
94
|
-
# Provider-specific keys (optional — fallback from INTELLIGENCE_API_KEY)
|
|
95
|
-
OPENAI_API_KEY=sk-...
|
|
96
|
-
ANTHROPIC_API_KEY=sk-ant-...
|
|
97
|
-
GOOGLE_API_KEY=AI...
|
|
98
|
-
GROK_API_KEY=xai-...
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
---
|
|
102
|
-
|
|
103
|
-
## Generating Text
|
|
104
|
-
|
|
105
|
-
Inject `IntelligenceTextGenerator` to generate completions:
|
|
106
|
-
|
|
107
|
-
```typescript
|
|
108
|
-
import { Injectable } from '@nestjs/common';
|
|
109
|
-
import type { Prompt } from 'ai';
|
|
110
|
-
import { IntelligenceTextGenerator, type IIntelligenceTextCompletion } from '@breadstone/archipel-platform-intelligence';
|
|
111
|
-
|
|
112
|
-
@Injectable()
|
|
113
|
-
export class SummaryService {
|
|
114
|
-
private readonly _textGenerator: IntelligenceTextGenerator;
|
|
115
|
-
|
|
116
|
-
constructor(textGenerator: IntelligenceTextGenerator) {
|
|
117
|
-
this._textGenerator = textGenerator;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
public async summarize(content: string): Promise<string> {
|
|
121
|
-
const prompt: Prompt = {
|
|
122
|
-
system: 'You are a concise summarizer. Respond with a short summary.',
|
|
123
|
-
messages: [{ role: 'user', content: content }],
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const completion = await this._textGenerator.generateText(prompt);
|
|
127
|
-
|
|
128
|
-
return completion.text;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### Prompt Structure
|
|
134
|
-
|
|
135
|
-
A prompt uses the native AI SDK `Prompt` type. Use either a string prompt or a full message array:
|
|
50
|
+
## Text and Objects
|
|
136
51
|
|
|
137
52
|
```typescript
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
53
|
+
const completion = await language.generateText(
|
|
54
|
+
{
|
|
55
|
+
system: 'Answer using the supplied application context only.',
|
|
56
|
+
prompt: 'Summarize the open tasks.',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
maxOutputTokens: 800,
|
|
60
|
+
maxRetries: 2,
|
|
61
|
+
},
|
|
62
|
+
);
|
|
142
63
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
maxOutputTokens: 256, // shorter responses
|
|
151
|
-
});
|
|
64
|
+
const structured = await language.generateObject(
|
|
65
|
+
{ prompt: 'Classify the customer request.' },
|
|
66
|
+
z.object({
|
|
67
|
+
category: z.enum(['billing', 'technical', 'other']),
|
|
68
|
+
urgency: z.enum(['low', 'normal', 'high']),
|
|
69
|
+
}),
|
|
70
|
+
);
|
|
152
71
|
```
|
|
153
72
|
|
|
154
|
-
|
|
73
|
+
Applications can provide a model override as
|
|
74
|
+
`{ provider: string, model: string }`. They never construct a provider-native
|
|
75
|
+
model.
|
|
155
76
|
|
|
156
|
-
|
|
77
|
+
## Streaming
|
|
157
78
|
|
|
158
79
|
```typescript
|
|
159
|
-
|
|
160
|
-
readonly text: string;
|
|
161
|
-
readonly provider: string;
|
|
162
|
-
readonly model: string;
|
|
163
|
-
readonly sources: ReadonlyArray<LanguageModelV3Source>;
|
|
164
|
-
readonly files: ReadonlyArray<GeneratedFile>;
|
|
165
|
-
readonly usage: IIntelligenceCompletionUsage | null;
|
|
166
|
-
}
|
|
80
|
+
const stream = await language.streamText({ prompt: 'Explain the result.' });
|
|
167
81
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
readonly completionTokens: number | null;
|
|
171
|
-
readonly totalTokens: number | null;
|
|
82
|
+
for await (const delta of stream.textStream) {
|
|
83
|
+
sendToAuthenticatedClient(delta);
|
|
172
84
|
}
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
---
|
|
176
|
-
|
|
177
|
-
## Multi-Turn Conversations
|
|
178
|
-
|
|
179
|
-
Build multi-turn conversations by passing the full message history:
|
|
180
85
|
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
system: 'You are a helpful fitness coach.',
|
|
184
|
-
messages: [
|
|
185
|
-
{ role: 'user', content: 'What should I eat before a workout?' },
|
|
186
|
-
{ role: 'assistant', content: 'A balanced meal with carbs and protein about 2 hours before.' },
|
|
187
|
-
{ role: 'user', content: 'Can you give me a specific example?' },
|
|
188
|
-
],
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
const completion = await this._textGenerator.generateText(prompt);
|
|
86
|
+
const finalText = await stream.text;
|
|
87
|
+
const usage = await stream.usage;
|
|
192
88
|
```
|
|
193
89
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
90
|
+
`streamObject()` exposes partial structured output and a validated final object.
|
|
91
|
+
All stream iterables and result promises normalize provider failures as
|
|
92
|
+
`IntelligenceProviderError`.
|
|
197
93
|
|
|
198
|
-
|
|
94
|
+
## Application Tools
|
|
199
95
|
|
|
200
96
|
```typescript
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
import { loadOpenAILanguageModel } from '@breadstone/archipel-platform-intelligence/providers/openai';
|
|
206
|
-
|
|
207
|
-
interface IWorkoutInput {
|
|
208
|
-
readonly goal: string;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
interface IWorkoutOutput {
|
|
212
|
-
readonly recommendation: string;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
@Injectable()
|
|
216
|
-
export class WorkoutRecommendationTool extends IntelligenceToolBase<IWorkoutInput, IWorkoutOutput> {
|
|
97
|
+
export class CustomerSearchTool extends IntelligenceToolBase<
|
|
98
|
+
ICustomerSearchInput,
|
|
99
|
+
ReadonlyArray<ICustomerSummary>
|
|
100
|
+
> {
|
|
217
101
|
public override get name(): string {
|
|
218
|
-
return '
|
|
102
|
+
return 'customer_search';
|
|
219
103
|
}
|
|
220
104
|
|
|
221
|
-
public override get tool()
|
|
222
|
-
return
|
|
223
|
-
description: '
|
|
224
|
-
inputSchema:
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
105
|
+
public override get tool() {
|
|
106
|
+
return defineIntelligenceTool({
|
|
107
|
+
description: 'Searches customers visible to the authenticated tenant.',
|
|
108
|
+
inputSchema: createIntelligenceJsonSchema<ICustomerSearchInput>({
|
|
109
|
+
type: 'object',
|
|
110
|
+
properties: { query: { type: 'string' } },
|
|
111
|
+
required: ['query'],
|
|
112
|
+
additionalProperties: false,
|
|
229
113
|
}),
|
|
114
|
+
execute: async ({ query }) => this._customers.search(query),
|
|
230
115
|
});
|
|
231
116
|
}
|
|
232
117
|
}
|
|
233
|
-
|
|
234
|
-
@Module({
|
|
235
|
-
imports: [
|
|
236
|
-
IntelligenceModule.register({
|
|
237
|
-
providerLoaders: {
|
|
238
|
-
[IntelligenceProviderNames.OpenAI]: loadOpenAILanguageModel,
|
|
239
|
-
},
|
|
240
|
-
tools: [WorkoutRecommendationTool],
|
|
241
|
-
}),
|
|
242
|
-
],
|
|
243
|
-
})
|
|
244
|
-
export class WorkoutModule {}
|
|
245
118
|
```
|
|
246
119
|
|
|
247
|
-
|
|
120
|
+
Register tools through `IntelligenceModule.register({ tools: [...] })`. Use
|
|
121
|
+
`activeToolNames` to constrain a call and `maxSteps` to bound the tool loop.
|
|
122
|
+
Tool authorization remains application-owned and must fail closed before data
|
|
123
|
+
or side effects are exposed.
|
|
248
124
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
import { loadOpenAILanguageModel } from '@breadstone/archipel-platform-intelligence/providers/openai';
|
|
253
|
-
import { createOpenAIWebSearchTool } from '@breadstone/archipel-platform-intelligence/providers/openai/tools';
|
|
125
|
+
Provider-owned tools are imported from Archipel provider `/tools` subpaths.
|
|
126
|
+
They are represented by opaque Archipel definitions; their native SDK types do
|
|
127
|
+
not cross into the application.
|
|
254
128
|
|
|
255
|
-
|
|
256
|
-
imports: [
|
|
257
|
-
IntelligenceModule.register({
|
|
258
|
-
providerLoaders: {
|
|
259
|
-
[IntelligenceProviderNames.OpenAI]: loadOpenAILanguageModel,
|
|
260
|
-
},
|
|
261
|
-
tools: [createOpenAIWebSearchTool({ searchContextSize: 'medium' })],
|
|
262
|
-
}),
|
|
263
|
-
],
|
|
264
|
-
})
|
|
265
|
-
export class SearchModule {}
|
|
266
|
-
```
|
|
129
|
+
## Agents
|
|
267
130
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
### Native AI SDK Passthrough
|
|
271
|
-
|
|
272
|
-
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.
|
|
273
|
-
|
|
274
|
-
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.
|
|
275
|
-
|
|
276
|
-
```typescript
|
|
277
|
-
import { openai } from '@ai-sdk/openai';
|
|
278
|
-
import { Injectable, Module } from '@nestjs/common';
|
|
279
|
-
import { IntelligenceModule, IntelligenceTextGenerator, type IIntelligenceTextCompletion } from '@breadstone/archipel-platform-intelligence';
|
|
280
|
-
|
|
281
|
-
@Module({
|
|
282
|
-
imports: [
|
|
283
|
-
IntelligenceModule.register({
|
|
284
|
-
validateOnModuleInit: false,
|
|
285
|
-
}),
|
|
286
|
-
],
|
|
287
|
-
})
|
|
288
|
-
export class RawAiSdkModule {}
|
|
289
|
-
|
|
290
|
-
@Injectable()
|
|
291
|
-
export class RawAiSdkRecipeService {
|
|
292
|
-
private readonly _textGenerator: IntelligenceTextGenerator;
|
|
293
|
-
|
|
294
|
-
public constructor(textGenerator: IntelligenceTextGenerator) {
|
|
295
|
-
this._textGenerator = textGenerator;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
public async generateWithNativeAiSdkOptions(): Promise<IIntelligenceTextCompletion> {
|
|
299
|
-
return this._textGenerator.generateText(
|
|
300
|
-
{
|
|
301
|
-
system: 'Answer concisely and include assumptions.',
|
|
302
|
-
prompt: 'Compare the operational risks of outdoor work tomorrow.',
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
model: openai.responses('gpt-5'),
|
|
306
|
-
headers: { 'x-use-case': 'outdoor-risk' },
|
|
307
|
-
providerOptions: {
|
|
308
|
-
openai: {
|
|
309
|
-
reasoningEffort: 'medium',
|
|
310
|
-
},
|
|
311
|
-
},
|
|
312
|
-
seed: 42,
|
|
313
|
-
},
|
|
314
|
-
);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
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.
|
|
320
|
-
|
|
321
|
-
### Additional OpenAI Tool Recipes
|
|
322
|
-
|
|
323
|
-
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`.
|
|
131
|
+
`IntelligenceAgentFactory.create()` builds a reusable bounded agent on the same
|
|
132
|
+
language facade:
|
|
324
133
|
|
|
325
134
|
```typescript
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
import {
|
|
332
|
-
createOpenAICodeInterpreterTool,
|
|
333
|
-
createOpenAICustomTool,
|
|
334
|
-
createOpenAIImageGenerationTool,
|
|
335
|
-
createOpenAIToolSearchTool,
|
|
336
|
-
} from '@breadstone/archipel-platform-intelligence/providers/openai/tools';
|
|
337
|
-
|
|
338
|
-
@Injectable()
|
|
339
|
-
export class OpenAIToolRecipeService {
|
|
340
|
-
private readonly _textGenerator: IntelligenceTextGenerator;
|
|
341
|
-
|
|
342
|
-
public constructor(textGenerator: IntelligenceTextGenerator) {
|
|
343
|
-
this._textGenerator = textGenerator;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
public async analyseSpreadsheet(fileId: string): Promise<IIntelligenceTextCompletion> {
|
|
347
|
-
return this._textGenerator.generateText(
|
|
348
|
-
{
|
|
349
|
-
system: 'You analyze uploaded spreadsheets and explain unusual values clearly.',
|
|
350
|
-
messages: [
|
|
351
|
-
{
|
|
352
|
-
role: 'user',
|
|
353
|
-
content: 'Analyze the file, detect unusual values, and summarize the most important findings as a table.',
|
|
354
|
-
},
|
|
355
|
-
],
|
|
356
|
-
},
|
|
357
|
-
{
|
|
358
|
-
activeTools: [OpenAIIntelligenceToolNames.CodeInterpreter],
|
|
359
|
-
tools: {
|
|
360
|
-
[OpenAIIntelligenceToolNames.CodeInterpreter]: createOpenAICodeInterpreterTool({
|
|
361
|
-
container: { fileIds: [fileId] },
|
|
362
|
-
}).tool,
|
|
363
|
-
},
|
|
364
|
-
},
|
|
365
|
-
);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
public async generateIllustration(description: string): Promise<IIntelligenceTextCompletion> {
|
|
369
|
-
return this._textGenerator.generateText(
|
|
370
|
-
{
|
|
371
|
-
prompt: description,
|
|
372
|
-
},
|
|
373
|
-
{
|
|
374
|
-
activeTools: [OpenAIIntelligenceToolNames.ImageGeneration],
|
|
375
|
-
tools: {
|
|
376
|
-
[OpenAIIntelligenceToolNames.ImageGeneration]: createOpenAIImageGenerationTool({
|
|
377
|
-
quality: 'medium',
|
|
378
|
-
size: '1024x1024',
|
|
379
|
-
}).tool,
|
|
380
|
-
},
|
|
381
|
-
},
|
|
382
|
-
);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
public async answerWithDeferredTools(prompt: string): Promise<IIntelligenceTextCompletion> {
|
|
386
|
-
return this._textGenerator.generateText(
|
|
387
|
-
{
|
|
388
|
-
prompt: prompt,
|
|
389
|
-
},
|
|
390
|
-
{
|
|
391
|
-
stopWhen: stepCountIs(10),
|
|
392
|
-
tools: {
|
|
393
|
-
[OpenAIIntelligenceToolNames.ToolSearch]: createOpenAIToolSearchTool().tool,
|
|
394
|
-
get_birthdays: tool({
|
|
395
|
-
description: 'Returns employee birthdays in a date range.',
|
|
396
|
-
inputSchema: z.object({
|
|
397
|
-
from: z.string(),
|
|
398
|
-
to: z.string(),
|
|
399
|
-
}),
|
|
400
|
-
execute: async (input) => ({ from: input.from, to: input.to, employees: [] }),
|
|
401
|
-
providerOptions: {
|
|
402
|
-
openai: { deferLoading: true },
|
|
403
|
-
},
|
|
404
|
-
}),
|
|
405
|
-
search_orders: tool({
|
|
406
|
-
description: 'Searches orders using domain-specific filters.',
|
|
407
|
-
inputSchema: z.object({
|
|
408
|
-
query: z.string(),
|
|
409
|
-
}),
|
|
410
|
-
execute: async (input) => ({ query: input.query, orders: [] }),
|
|
411
|
-
providerOptions: {
|
|
412
|
-
openai: { deferLoading: true },
|
|
413
|
-
},
|
|
414
|
-
}),
|
|
415
|
-
},
|
|
416
|
-
},
|
|
417
|
-
);
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
public async createReadOnlyReportQuery(prompt: string): Promise<IIntelligenceTextCompletion> {
|
|
421
|
-
return this._textGenerator.generateText(
|
|
422
|
-
{
|
|
423
|
-
system: 'Create only read-only reporting queries. The query must start with SELECT.',
|
|
424
|
-
messages: [{ role: 'user', content: prompt }],
|
|
425
|
-
},
|
|
426
|
-
{
|
|
427
|
-
toolChoice: 'required',
|
|
428
|
-
stopWhen: stepCountIs(3),
|
|
429
|
-
activeTools: ['report_query'],
|
|
430
|
-
tools: {
|
|
431
|
-
report_query: createOpenAICustomTool({
|
|
432
|
-
name: 'report_query',
|
|
433
|
-
description: 'Create a strictly read-only reporting query.',
|
|
434
|
-
format: {
|
|
435
|
-
type: 'grammar',
|
|
436
|
-
syntax: 'regex',
|
|
437
|
-
definition: 'SELECT .+',
|
|
438
|
-
},
|
|
439
|
-
}).tool,
|
|
440
|
-
},
|
|
441
|
-
},
|
|
442
|
-
);
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
```
|
|
446
|
-
|
|
447
|
-
`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.
|
|
448
|
-
|
|
449
|
-
### Outdoor Order Weather Risk Example
|
|
450
|
-
|
|
451
|
-
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`.
|
|
452
|
-
|
|
453
|
-
```typescript
|
|
454
|
-
import { Injectable, Module } from '@nestjs/common';
|
|
455
|
-
import { stepCountIs, tool, type Tool } from 'ai';
|
|
456
|
-
import { z } from 'zod';
|
|
457
|
-
import {
|
|
458
|
-
IntelligenceModule,
|
|
459
|
-
IntelligenceProviderNames,
|
|
460
|
-
IntelligenceTextGenerator,
|
|
461
|
-
IntelligenceToolBase,
|
|
462
|
-
type IIntelligenceTextCompletion,
|
|
463
|
-
} from '@breadstone/archipel-platform-intelligence';
|
|
464
|
-
import { OpenAIIntelligenceToolNames, loadOpenAILanguageModel } from '@breadstone/archipel-platform-intelligence/providers/openai';
|
|
465
|
-
import { createOpenAIWebSearchTool } from '@breadstone/archipel-platform-intelligence/providers/openai/tools';
|
|
466
|
-
|
|
467
|
-
interface IOutdoorOrderLookupInput {
|
|
468
|
-
readonly date: string;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
interface IOutdoorOrder {
|
|
472
|
-
readonly id: string;
|
|
473
|
-
readonly location: string;
|
|
474
|
-
readonly scheduledAt: string;
|
|
475
|
-
readonly outdoorWork: boolean;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
interface IOutdoorOrderLookupOutput {
|
|
479
|
-
readonly date: string;
|
|
480
|
-
readonly orders: ReadonlyArray<IOutdoorOrder>;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
@Injectable()
|
|
484
|
-
export class OutdoorOrdersTool extends IntelligenceToolBase<IOutdoorOrderLookupInput, IOutdoorOrderLookupOutput> {
|
|
485
|
-
public override get name(): string {
|
|
486
|
-
return 'get_outdoor_orders';
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
public override get tool(): Tool<IOutdoorOrderLookupInput, IOutdoorOrderLookupOutput> {
|
|
490
|
-
return tool({
|
|
491
|
-
description: 'Returns outdoor field orders for the current tenant and date.',
|
|
492
|
-
inputSchema: z.object({
|
|
493
|
-
date: z.string().describe('Date in YYYY-MM-DD format'),
|
|
494
|
-
}),
|
|
495
|
-
execute: async (input: IOutdoorOrderLookupInput) => this.loadOutdoorOrders(input.date),
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
private async loadOutdoorOrders(date: string): Promise<IOutdoorOrderLookupOutput> {
|
|
500
|
-
return {
|
|
501
|
-
date: date,
|
|
502
|
-
orders: [
|
|
503
|
-
{
|
|
504
|
-
id: 'ord_4711',
|
|
505
|
-
location: 'Berlin',
|
|
506
|
-
scheduledAt: `${date}T08:00:00+02:00`,
|
|
507
|
-
outdoorWork: true,
|
|
508
|
-
},
|
|
509
|
-
],
|
|
510
|
-
};
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
@Injectable()
|
|
515
|
-
export class OutdoorOrderRiskAnalysisService {
|
|
516
|
-
private readonly _textGenerator: IntelligenceTextGenerator;
|
|
517
|
-
|
|
518
|
-
public constructor(textGenerator: IntelligenceTextGenerator) {
|
|
519
|
-
this._textGenerator = textGenerator;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
public async analyseOutdoorOrders(date: string): Promise<{ readonly text: string; readonly sources: IIntelligenceTextCompletion['sources'] }> {
|
|
523
|
-
const result = await this._textGenerator.generateText(
|
|
524
|
-
{
|
|
525
|
-
system: 'You assess weather-related risks for tenant outdoor field orders.',
|
|
526
|
-
messages: [
|
|
527
|
-
{
|
|
528
|
-
role: 'user',
|
|
529
|
-
content: `Review outdoor field orders for ${date} and flag weather-related risks.`,
|
|
530
|
-
},
|
|
531
|
-
],
|
|
532
|
-
},
|
|
533
|
-
{
|
|
534
|
-
toolChoice: 'auto',
|
|
535
|
-
activeTools: ['get_outdoor_orders', OpenAIIntelligenceToolNames.WebSearch],
|
|
536
|
-
stopWhen: stepCountIs(3),
|
|
537
|
-
},
|
|
538
|
-
);
|
|
539
|
-
|
|
540
|
-
return {
|
|
541
|
-
text: result.text,
|
|
542
|
-
sources: result.sources,
|
|
543
|
-
};
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
@Module({
|
|
548
|
-
imports: [
|
|
549
|
-
IntelligenceModule.register({
|
|
550
|
-
providerLoaders: {
|
|
551
|
-
[IntelligenceProviderNames.OpenAI]: loadOpenAILanguageModel,
|
|
552
|
-
},
|
|
553
|
-
tools: [
|
|
554
|
-
OutdoorOrdersTool,
|
|
555
|
-
createOpenAIWebSearchTool({
|
|
556
|
-
externalWebAccess: true,
|
|
557
|
-
searchContextSize: 'medium',
|
|
558
|
-
filters: {
|
|
559
|
-
allowedDomains: ['dwd.de'],
|
|
560
|
-
},
|
|
561
|
-
}),
|
|
562
|
-
],
|
|
563
|
-
}),
|
|
564
|
-
],
|
|
565
|
-
providers: [OutdoorOrderRiskAnalysisService],
|
|
566
|
-
})
|
|
567
|
-
export class OutdoorOrderRiskAnalysisModule {}
|
|
568
|
-
```
|
|
569
|
-
|
|
570
|
-
Use AI SDK request options to constrain tool use per call:
|
|
571
|
-
|
|
572
|
-
```typescript
|
|
573
|
-
const completion = await this._textGenerator.generateText(prompt, {
|
|
574
|
-
toolChoice: 'auto',
|
|
575
|
-
activeTools: ['recommendWorkout'],
|
|
576
|
-
});
|
|
577
|
-
```
|
|
578
|
-
|
|
579
|
-
> **Capacity limit:** The registry enforces a maximum of **128** registered tools.
|
|
580
|
-
|
|
581
|
-
---
|
|
582
|
-
|
|
583
|
-
## Streaming Text
|
|
584
|
-
|
|
585
|
-
`streamText()` uses the same provider configuration and registered tools as `generateText()` and returns the native AI SDK stream result.
|
|
586
|
-
|
|
587
|
-
```typescript
|
|
588
|
-
const stream = await this._textGenerator.streamText(prompt, {
|
|
589
|
-
activeTools: ['recommendWorkout'],
|
|
590
|
-
stopWhen: stepCountIs(3),
|
|
591
|
-
});
|
|
592
|
-
|
|
593
|
-
return stream.toUIMessageStreamResponse();
|
|
594
|
-
```
|
|
595
|
-
|
|
596
|
-
---
|
|
597
|
-
|
|
598
|
-
## Inspecting Configuration
|
|
599
|
-
|
|
600
|
-
Retrieve the resolved provider configuration at runtime:
|
|
601
|
-
|
|
602
|
-
```typescript
|
|
603
|
-
const config = this._textGenerator.getConfiguration();
|
|
604
|
-
console.log(config.provider); // 'openai'
|
|
605
|
-
console.log(config.model); // 'gpt-4o-mini'
|
|
606
|
-
```
|
|
607
|
-
|
|
608
|
-
---
|
|
609
|
-
|
|
610
|
-
## Error Handling
|
|
611
|
-
|
|
612
|
-
`IntelligenceTextGenerator` wraps all provider errors in `IntelligenceProviderError`, which includes `provider`, `model`, and `retryable` metadata. The generator automatically retries retryable failures (e.g. transient network errors) with exponential backoff before giving up.
|
|
613
|
-
|
|
614
|
-
Two additional error classes handle configuration and validation failures:
|
|
615
|
-
|
|
616
|
-
| Error class | Code | When thrown |
|
|
617
|
-
| ---------------------------------- | ----------------------------- | --------------------------------------------------------------------- |
|
|
618
|
-
| `IntelligenceProviderError` | `INTELLIGENCE_PROVIDER` | Provider SDK failures during text generation |
|
|
619
|
-
| `IntelligenceValidationError` | `INTELLIGENCE_VALIDATION` | Invalid generation parameters (temperature, topP, maxOutputTokens) |
|
|
620
|
-
| `IntelligenceConfigurationError` | `INTELLIGENCE_CONFIGURATION` | Unsupported provider, missing API key, or missing provider loader |
|
|
621
|
-
|
|
622
|
-
### Timeout & Retry Defaults
|
|
623
|
-
|
|
624
|
-
| Setting | Default | Description |
|
|
625
|
-
| ----------- | -------- | ----------------------------------------------------------- |
|
|
626
|
-
| `timeoutMs` | `30000` | Abort the provider request after this many milliseconds |
|
|
627
|
-
| Max retries | `2` | Retryable errors are retried up to 2 times |
|
|
628
|
-
| Backoff | 1s → 4s | Exponential backoff with a 4-second cap between retries |
|
|
629
|
-
|
|
630
|
-
Override the timeout per call:
|
|
631
|
-
|
|
632
|
-
```typescript
|
|
633
|
-
const result = await this._textGenerator.generateText(prompt, {
|
|
634
|
-
timeoutMs: 15_000, // 15-second timeout for this call
|
|
135
|
+
const agent = agents.create({
|
|
136
|
+
name: 'researcher',
|
|
137
|
+
instructions: 'Use approved sources and report uncertainty.',
|
|
138
|
+
activeToolNames: ['web_search', 'document_search'],
|
|
139
|
+
maxSteps: 6,
|
|
635
140
|
});
|
|
636
|
-
```
|
|
637
|
-
|
|
638
|
-
### Catching Errors
|
|
639
|
-
|
|
640
|
-
```typescript
|
|
641
|
-
import { IntelligenceProviderError } from '@breadstone/archipel-platform-intelligence';
|
|
642
141
|
|
|
643
|
-
|
|
644
|
-
const result = await this._textGenerator.generateText(prompt);
|
|
645
|
-
return result.text;
|
|
646
|
-
} catch (error) {
|
|
647
|
-
if (error instanceof IntelligenceProviderError) {
|
|
648
|
-
this._logger.error(`Provider ${error.provider}/${error.model} failed`, {
|
|
649
|
-
retryable: error.retryable,
|
|
650
|
-
message: error.message,
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
return 'Sorry, I could not generate a response right now.';
|
|
654
|
-
}
|
|
142
|
+
const answer = await agent.generate({ prompt: question });
|
|
655
143
|
```
|
|
656
144
|
|
|
657
|
-
|
|
145
|
+
Agents do not create a second provider abstraction. They compose language,
|
|
146
|
+
tools, model policy, and step limits already owned by Archipel.
|
|
658
147
|
|
|
659
|
-
|
|
148
|
+
## Results and Failures
|
|
660
149
|
|
|
661
|
-
|
|
150
|
+
Language completions expose provider, model, text, typed output, finish reason,
|
|
151
|
+
reasoning text, normalized sources and files, tool calls/results, warnings, and
|
|
152
|
+
usage. The default total-operation timeout is 30 seconds.
|
|
662
153
|
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
TextGenerator[IntelligenceTextGenerator\nConfigService -> provider]
|
|
667
|
-
ToolRegistry[IntelligenceToolRegistry]
|
|
668
|
-
end
|
|
669
|
-
|
|
670
|
-
GenerateText["generateText(prompt, options?)"]
|
|
671
|
-
StreamText["streamText(prompt, options?)"]
|
|
672
|
-
ResolveTools["toToolSet()\nregister(tool)"]
|
|
673
|
-
ProviderLoaders[Registered Provider Loaders\nproviders/openai, providers/anthropic, providers/google, providers/grok]
|
|
674
|
-
FeatureTools[Feature Tools\nnative AI SDK tools]
|
|
675
|
-
|
|
676
|
-
TextGenerator --> GenerateText
|
|
677
|
-
TextGenerator --> StreamText
|
|
678
|
-
ToolRegistry --> ResolveTools
|
|
679
|
-
TextGenerator --> ProviderLoaders
|
|
680
|
-
ToolRegistry --> FeatureTools
|
|
681
|
-
GenerateText --> ToolRegistry
|
|
682
|
-
StreamText --> ToolRegistry
|
|
683
|
-
```
|
|
154
|
+
Provider failures use `IntelligenceProviderError`; invalid prompts and options
|
|
155
|
+
use `IntelligenceValidationError`; missing adapters or capability defaults use
|
|
156
|
+
`IntelligenceConfigurationError`.
|