@breadstone/archipel-mcp 0.0.55 → 0.0.57
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 +52 -47
- package/data/guides/ai-realtime-voice.md +48 -41
- package/data/guides/ai-text-generation.md +54 -60
- package/data/guides/health-indicators.md +67 -66
- package/data/guides/intelligence-prompts-warm-up.md +52 -63
- package/data/packages/platform-intelligence/api/Class.AnthropicIntelligenceProviderAdapter.md +57 -13
- package/data/packages/platform-intelligence/api/Class.GatewayIntelligenceProviderAdapter.md +57 -13
- package/data/packages/platform-intelligence/api/Class.GoogleIntelligenceProviderAdapter.md +57 -13
- package/data/packages/platform-intelligence/api/Class.GrokIntelligenceProviderAdapter.md +57 -13
- package/data/packages/platform-intelligence/api/Class.IntelligenceAgent.md +5 -5
- package/data/packages/platform-intelligence/api/Class.IntelligenceEmbeddingGenerator.md +4 -4
- package/data/packages/platform-intelligence/api/Class.IntelligenceHealthIndicator.md +10 -9
- package/data/packages/platform-intelligence/api/Class.IntelligenceImageGenerator.md +117 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceLanguageGenerator.md +7 -7
- package/data/packages/platform-intelligence/api/Class.IntelligenceModule.md +2 -2
- 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.IntelligenceProviderDiagnostics.md +3 -3
- package/data/packages/platform-intelligence/api/Class.IntelligenceProviderRegistry.md +5 -5
- package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeMeteringPort.md +1 -1
- package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeSessionFactory.md +5 -5
- package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeSessionPort.md +15 -15
- package/data/packages/platform-intelligence/api/Class.IntelligenceReranker.md +3 -3
- package/data/packages/platform-intelligence/api/Class.IntelligenceSpeechGenerator.md +117 -0
- package/data/packages/platform-intelligence/api/Class.IntelligenceToolRegistry.md +5 -5
- 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 +57 -13
- package/data/packages/platform-intelligence/api/Class.OpenAIIntelligenceProviderAdapter.md +38 -18
- package/data/packages/platform-intelligence/api/Function.createIntelligenceJsonSchema.md +1 -1
- package/data/packages/platform-intelligence/api/Function.defineIntelligenceTool.md +1 -1
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceAgentConfiguration.md +7 -7
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingBatchOptions.md +25 -9
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingBatchResult.md +7 -7
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingOptions.md +24 -8
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingResult.md +7 -7
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceFileUploadOptions.md +23 -7
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceFileUploadResult.md +6 -6
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceGeneratedFile.md +4 -4
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceGenerationStepStartEvent.md +5 -5
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceImageGenerationOptions.md +29 -13
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceImageGenerationResult.md +6 -6
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceLanguageCompletion.md +13 -13
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceLanguageGenerationOptions.md +33 -17
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceLanguageStream.md +5 -5
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModelReference.md +3 -3
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModelRequestOptions.md +24 -4
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModelStatus.md +3 -3
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceModuleOptions.md +30 -8
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceObjectStream.md +5 -5
- package/data/packages/platform-intelligence/api/Interface.IIntelligencePrompt.md +5 -5
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderLoadRequest.md +20 -6
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderProbeResult.md +7 -7
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeSessionOptions.md +21 -9
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeUsage.md +174 -10
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRequestOptions.md +22 -6
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRerankingOptions.md +26 -10
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceRerankingResult.md +4 -4
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSkillUploadOptions.md +22 -6
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSkillUploadResult.md +8 -8
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSpeechGenerationOptions.md +29 -13
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceSpeechGenerationResult.md +5 -5
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceStreamingTranscriptionOptions.md +25 -9
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolCall.md +4 -4
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolDefinition.md +7 -7
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolExecutionEndEvent.md +5 -5
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolExecutionStartEvent.md +3 -3
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTranscriptionOptions.md +24 -8
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTranscriptionResult.md +8 -8
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceTranscriptionStream.md +9 -9
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceUsage.md +161 -4
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceVideoGenerationOptions.md +34 -18
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceVideoGenerationResult.md +5 -5
- package/data/packages/platform-intelligence/api/TypeAlias.IIntelligenceModelMessage.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IIntelligenceSchema.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceCapability.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceDefaultModels.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceJsonValue.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceProviderName.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceProviderOptions.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceProviderProbeStatus.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceProviderToolOptions.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRequestTimeouts.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceToolChoice.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceToolOutput.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceToolSet.md +1 -1
- package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceTranscriptionStreamPart.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.AI_GATEWAY_API_KEY.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.AI_GATEWAY_BASE_URL.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.AI_GATEWAY_CONFIG_ENTRIES.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_API_KEY.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_BASE_URL.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_MAX_OUTPUT_TOKENS.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_MODEL.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_PROVIDER.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_TEMPERATURE.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_TOP_P.md +1 -1
- package/data/packages/platform-intelligence/api/Variable.IntelligenceCapabilityNames.md +11 -11
- package/data/packages/platform-intelligence/api/Variable.PLATFORM_INTELLIGENCE_CONFIG_ENTRIES.md +2 -2
- package/data/packages/platform-intelligence/api/index.md +8 -5
- package/data/packages/platform-intelligence/index.md +92 -0
- package/package.json +1 -1
- package/data/packages/platform-intelligence/api/Class.IntelligenceMediaGenerator.md +0 -140
- package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderAdapter.md +0 -73
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: AI Image Generation
|
|
3
|
-
description: Generate and edit images through the provider-neutral Archipel
|
|
3
|
+
description: Generate and edit images through the provider-neutral Archipel image generator.
|
|
4
4
|
order: 16
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AI Image Generation
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
`IntelligenceImageGenerator` owns image generation and editing. Speech,
|
|
10
|
+
transcription, and video use their own capability-specific generators while
|
|
11
|
+
sharing Archipel's provider resolution, timeout, cancellation, error, and file
|
|
12
|
+
infrastructure.
|
|
13
13
|
|
|
14
14
|
Applications install only Archipel:
|
|
15
15
|
|
|
@@ -24,28 +24,25 @@ not import `ai`, `@ai-sdk/*`, or provider clients.
|
|
|
24
24
|
|
|
25
25
|
```typescript
|
|
26
26
|
import { Module } from '@nestjs/common';
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
IntelligenceModule,
|
|
30
|
-
IntelligenceProviderNames,
|
|
31
|
-
} from '@breadstone/archipel-platform-intelligence';
|
|
32
|
-
import { OpenAIIntelligenceProviderAdapter } from '@breadstone/archipel-platform-intelligence/openai';
|
|
27
|
+
import { IntelligenceCapabilityNames, IntelligenceModule, IntelligenceProviderNames } from '@breadstone/archipel-platform-intelligence';
|
|
28
|
+
import { OPENAI_CONFIG_ENTRIES, OpenAIIntelligenceProviderAdapter } from '@breadstone/archipel-platform-intelligence/provider/openai';
|
|
33
29
|
|
|
34
30
|
@Module({
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
31
|
+
imports: [
|
|
32
|
+
IntelligenceModule.register({
|
|
33
|
+
configEntries: OPENAI_CONFIG_ENTRIES,
|
|
34
|
+
providerAdapters: [OpenAIIntelligenceProviderAdapter],
|
|
35
|
+
defaultModels: {
|
|
36
|
+
[IntelligenceCapabilityNames.Image]: {
|
|
37
|
+
provider: IntelligenceProviderNames.OpenAI,
|
|
38
|
+
model: 'gpt-image-1.5',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
requestTimeouts: {
|
|
42
|
+
[IntelligenceCapabilityNames.Image]: 120_000,
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
],
|
|
49
46
|
})
|
|
50
47
|
export class ApplicationModule {}
|
|
51
48
|
```
|
|
@@ -54,35 +51,39 @@ export class ApplicationModule {}
|
|
|
54
51
|
|
|
55
52
|
```typescript
|
|
56
53
|
import { Injectable } from '@nestjs/common';
|
|
57
|
-
import {
|
|
54
|
+
import { IntelligenceImageGenerator } from '@breadstone/archipel-platform-intelligence';
|
|
58
55
|
|
|
59
56
|
@Injectable()
|
|
60
57
|
export class ProductPosterService {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
58
|
+
public constructor(private readonly _images: IntelligenceImageGenerator) {}
|
|
59
|
+
|
|
60
|
+
public generate() {
|
|
61
|
+
return this._images.generate({
|
|
62
|
+
prompt: 'A clean editorial product photograph without text or logos.',
|
|
63
|
+
count: 3,
|
|
64
|
+
size: '1536x1024',
|
|
65
|
+
maxRetries: 2,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public edit(referenceImage: Uint8Array, mask: Uint8Array) {
|
|
70
|
+
return this._images.generate({
|
|
71
|
+
prompt: {
|
|
72
|
+
images: [referenceImage],
|
|
73
|
+
mask,
|
|
74
|
+
text: 'Replace the background with a neutral studio wall.',
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
81
78
|
}
|
|
82
79
|
```
|
|
83
80
|
|
|
84
81
|
The result contains normalized generated files, provider, model, warnings, and
|
|
85
|
-
usage.
|
|
82
|
+
usage. The usage contract distinguishes text input, image input, and generated
|
|
83
|
+
image output tokens when the provider reports enough detail. For a text-only
|
|
84
|
+
prompt, an otherwise undifferentiated input total is safely classified as text;
|
|
85
|
+
for an edit request, missing modality details remain `null` rather than being
|
|
86
|
+
invented. Generated bytes are not persisted by Archipel.
|
|
86
87
|
|
|
87
88
|
## Safety Boundary
|
|
88
89
|
|
|
@@ -90,6 +91,10 @@ Before calling the facade, the application must complete authentication,
|
|
|
90
91
|
authorization, tenant ownership, AI enablement, entitlement, quota, and rate
|
|
91
92
|
limit checks. It owns usage charging and persistence after success.
|
|
92
93
|
|
|
94
|
+
The application must price usage by the resolved provider and model. Archipel
|
|
95
|
+
does not convert token counters into money or product credits, and a missing
|
|
96
|
+
counter must not be treated as zero-cost usage.
|
|
97
|
+
|
|
93
98
|
Provider failures become `IntelligenceProviderError`. Invalid provider,
|
|
94
99
|
capability, model, or timeout configuration fails before a remote generation
|
|
95
100
|
call. The 120-second default is a total-operation bound and can be overridden
|
|
@@ -10,8 +10,7 @@ order: 17
|
|
|
10
10
|
audio/text sessions. Provider credentials and upstream sockets remain in the
|
|
11
11
|
backend.
|
|
12
12
|
|
|
13
|
-
Realtime is separate from
|
|
14
|
-
`IntelligenceMediaGenerator.streamTranscription()`:
|
|
13
|
+
Realtime is separate from `IntelligenceTranscriptionGenerator.stream()`:
|
|
15
14
|
|
|
16
15
|
- streaming transcription accepts raw audio and emits transcript updates;
|
|
17
16
|
- realtime is a bidirectional conversational session with input/output audio,
|
|
@@ -22,32 +21,33 @@ Realtime is separate from
|
|
|
22
21
|
```typescript
|
|
23
22
|
import { Module } from '@nestjs/common';
|
|
24
23
|
import { IntelligenceModule } from '@breadstone/archipel-platform-intelligence';
|
|
25
|
-
import { GatewayIntelligenceProviderAdapter } from '@breadstone/archipel-platform-intelligence/gateway';
|
|
26
|
-
import { GoogleIntelligenceProviderAdapter } from '@breadstone/archipel-platform-intelligence/google';
|
|
27
|
-
import { GrokIntelligenceProviderAdapter } from '@breadstone/archipel-platform-intelligence/grok';
|
|
28
|
-
import { OpenAIIntelligenceProviderAdapter } from '@breadstone/archipel-platform-intelligence/openai';
|
|
24
|
+
import { AI_GATEWAY_CONFIG_ENTRIES, GatewayIntelligenceProviderAdapter } from '@breadstone/archipel-platform-intelligence/provider/gateway';
|
|
25
|
+
import { GOOGLE_CONFIG_ENTRIES, GoogleIntelligenceProviderAdapter } from '@breadstone/archipel-platform-intelligence/provider/google';
|
|
26
|
+
import { GROK_CONFIG_ENTRIES, GrokIntelligenceProviderAdapter } from '@breadstone/archipel-platform-intelligence/provider/grok';
|
|
27
|
+
import { OPENAI_CONFIG_ENTRIES, OpenAIIntelligenceProviderAdapter } from '@breadstone/archipel-platform-intelligence/provider/openai';
|
|
29
28
|
|
|
30
29
|
@Module({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
30
|
+
imports: [
|
|
31
|
+
IntelligenceModule.register({
|
|
32
|
+
configEntries: [...OPENAI_CONFIG_ENTRIES, ...GOOGLE_CONFIG_ENTRIES, ...GROK_CONFIG_ENTRIES, ...AI_GATEWAY_CONFIG_ENTRIES],
|
|
33
|
+
providerAdapters: [
|
|
34
|
+
OpenAIIntelligenceProviderAdapter,
|
|
35
|
+
GoogleIntelligenceProviderAdapter,
|
|
36
|
+
GrokIntelligenceProviderAdapter,
|
|
37
|
+
GatewayIntelligenceProviderAdapter,
|
|
38
|
+
],
|
|
39
|
+
realtime: {
|
|
40
|
+
connectionTimeoutMs: 5_000,
|
|
41
|
+
idleTimeoutMs: 120_000,
|
|
42
|
+
absoluteSessionTimeoutMs: 1_800_000,
|
|
43
|
+
maxActiveSessions: 100,
|
|
44
|
+
maxBufferedAmountBytes: 1_048_576,
|
|
45
|
+
maxMessageBytes: 1_048_576,
|
|
46
|
+
meteringIntervalMs: 30_000,
|
|
47
|
+
meteringAdapter: ApplicationRealtimeMeteringAdapter,
|
|
48
|
+
},
|
|
49
|
+
}),
|
|
50
|
+
],
|
|
51
51
|
})
|
|
52
52
|
export class ApplicationModule {}
|
|
53
53
|
```
|
|
@@ -59,25 +59,25 @@ or import provider SDKs.
|
|
|
59
59
|
|
|
60
60
|
```typescript
|
|
61
61
|
const session = await sessions.createSession({
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
62
|
+
sessionId: applicationSessionId,
|
|
63
|
+
provider: 'openai',
|
|
64
|
+
model: 'gpt-realtime',
|
|
65
|
+
metadata: {
|
|
66
|
+
tenantId,
|
|
67
|
+
userId,
|
|
68
|
+
},
|
|
69
|
+
activeToolNames: ['customer_search'],
|
|
70
|
+
sessionConfiguration: {
|
|
71
|
+
instructions: 'Help with the authenticated tenant context only.',
|
|
72
|
+
modalities: ['text', 'audio'],
|
|
73
|
+
},
|
|
74
|
+
onEvent: (event) => forwardToApplicationSocket(event),
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
await session.connect();
|
|
78
78
|
await session.send({
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
type: 'input_audio_buffer.append',
|
|
80
|
+
audio: base64AudioChunk,
|
|
81
81
|
});
|
|
82
82
|
```
|
|
83
83
|
|
|
@@ -96,6 +96,13 @@ idempotently. Session-start, interval, provider-usage, and session-end events
|
|
|
96
96
|
carry stable event IDs for deduplication. Business-critical charging should be
|
|
97
97
|
transactional with the application usage ledger.
|
|
98
98
|
|
|
99
|
+
Provider-usage events expose the common `IIntelligenceUsage` dimensions for
|
|
100
|
+
text, image, audio, cache reads/writes, reasoning, input, and output. Missing
|
|
101
|
+
provider dimensions remain `null`; raw provider usage is retained only as
|
|
102
|
+
diagnostic event data. The application owns provider/model pricing and billing
|
|
103
|
+
units so lifecycle intervals and token-based provider cost cannot accidentally
|
|
104
|
+
charge the same product entitlement twice.
|
|
105
|
+
|
|
99
106
|
## Runtime Guarantees
|
|
100
107
|
|
|
101
108
|
The factory enforces:
|
|
@@ -20,29 +20,23 @@ yarn add @breadstone/archipel-platform-intelligence
|
|
|
20
20
|
|
|
21
21
|
```typescript
|
|
22
22
|
import { Module } from '@nestjs/common';
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
|
|
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';
|
|
23
|
+
import { IntelligenceCapabilityNames, IntelligenceModule, IntelligenceProviderNames } from '@breadstone/archipel-platform-intelligence';
|
|
24
|
+
import { ANTHROPIC_CONFIG_ENTRIES, AnthropicIntelligenceProviderAdapter } from '@breadstone/archipel-platform-intelligence/provider/anthropic';
|
|
25
|
+
import { OPENAI_CONFIG_ENTRIES, OpenAIIntelligenceProviderAdapter } from '@breadstone/archipel-platform-intelligence/provider/openai';
|
|
30
26
|
|
|
31
27
|
@Module({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
}),
|
|
45
|
-
],
|
|
28
|
+
imports: [
|
|
29
|
+
IntelligenceModule.register({
|
|
30
|
+
configEntries: [...OPENAI_CONFIG_ENTRIES, ...ANTHROPIC_CONFIG_ENTRIES],
|
|
31
|
+
providerAdapters: [OpenAIIntelligenceProviderAdapter, AnthropicIntelligenceProviderAdapter],
|
|
32
|
+
defaultModels: {
|
|
33
|
+
[IntelligenceCapabilityNames.Language]: {
|
|
34
|
+
provider: IntelligenceProviderNames.OpenAI,
|
|
35
|
+
model: 'gpt-5.4-mini',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
],
|
|
46
40
|
})
|
|
47
41
|
export class ApplicationModule {}
|
|
48
42
|
```
|
|
@@ -51,22 +45,22 @@ export class ApplicationModule {}
|
|
|
51
45
|
|
|
52
46
|
```typescript
|
|
53
47
|
const completion = await language.generateText(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
{
|
|
49
|
+
system: 'Answer using the supplied application context only.',
|
|
50
|
+
prompt: 'Summarize the open tasks.',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
maxOutputTokens: 800,
|
|
54
|
+
maxRetries: 2,
|
|
55
|
+
},
|
|
62
56
|
);
|
|
63
57
|
|
|
64
58
|
const structured = await language.generateObject(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
59
|
+
{ prompt: 'Classify the customer request.' },
|
|
60
|
+
z.object({
|
|
61
|
+
category: z.enum(['billing', 'technical', 'other']),
|
|
62
|
+
urgency: z.enum(['low', 'normal', 'high']),
|
|
63
|
+
}),
|
|
70
64
|
);
|
|
71
65
|
```
|
|
72
66
|
|
|
@@ -80,7 +74,7 @@ model.
|
|
|
80
74
|
const stream = await language.streamText({ prompt: 'Explain the result.' });
|
|
81
75
|
|
|
82
76
|
for await (const delta of stream.textStream) {
|
|
83
|
-
|
|
77
|
+
sendToAuthenticatedClient(delta);
|
|
84
78
|
}
|
|
85
79
|
|
|
86
80
|
const finalText = await stream.text;
|
|
@@ -94,26 +88,23 @@ All stream iterables and result promises normalize provider failures as
|
|
|
94
88
|
## Application Tools
|
|
95
89
|
|
|
96
90
|
```typescript
|
|
97
|
-
export class CustomerSearchTool extends IntelligenceToolBase<
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
execute: async ({ query }) => this._customers.search(query),
|
|
115
|
-
});
|
|
116
|
-
}
|
|
91
|
+
export class CustomerSearchTool extends IntelligenceToolBase<ICustomerSearchInput, ReadonlyArray<ICustomerSummary>> {
|
|
92
|
+
public override get name(): string {
|
|
93
|
+
return 'customer_search';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public override get tool() {
|
|
97
|
+
return defineIntelligenceTool({
|
|
98
|
+
description: 'Searches customers visible to the authenticated tenant.',
|
|
99
|
+
inputSchema: createIntelligenceJsonSchema<ICustomerSearchInput>({
|
|
100
|
+
type: 'object',
|
|
101
|
+
properties: { query: { type: 'string' } },
|
|
102
|
+
required: ['query'],
|
|
103
|
+
additionalProperties: false,
|
|
104
|
+
}),
|
|
105
|
+
execute: async ({ query }) => this._customers.search(query),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
117
108
|
}
|
|
118
109
|
```
|
|
119
110
|
|
|
@@ -133,10 +124,10 @@ language facade:
|
|
|
133
124
|
|
|
134
125
|
```typescript
|
|
135
126
|
const agent = agents.create({
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
127
|
+
name: 'researcher',
|
|
128
|
+
instructions: 'Use approved sources and report uncertainty.',
|
|
129
|
+
activeToolNames: ['web_search', 'document_search'],
|
|
130
|
+
maxSteps: 6,
|
|
140
131
|
});
|
|
141
132
|
|
|
142
133
|
const answer = await agent.generate({ prompt: question });
|
|
@@ -149,7 +140,10 @@ tools, model policy, and step limits already owned by Archipel.
|
|
|
149
140
|
|
|
150
141
|
Language completions expose provider, model, text, typed output, finish reason,
|
|
151
142
|
reasoning text, normalized sources and files, tool calls/results, warnings, and
|
|
152
|
-
usage.
|
|
143
|
+
usage. Usage contains provider-neutral input, output, total, cache-read,
|
|
144
|
+
cache-write, reasoning, and available modality counters. A `null` counter means
|
|
145
|
+
the provider did not report it and must not be interpreted as measured zero.
|
|
146
|
+
The default total-operation timeout is 30 seconds.
|
|
153
147
|
|
|
154
148
|
Provider failures use `IntelligenceProviderError`; invalid prompts and options
|
|
155
149
|
use `IntelligenceValidationError`; missing adapters or capability defaults use
|
|
@@ -51,11 +51,11 @@ Every health indicator implements this contract:
|
|
|
51
51
|
|
|
52
52
|
```typescript
|
|
53
53
|
interface IHealthIndicator {
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
/** Unique key identifying this indicator in the health response. */
|
|
55
|
+
readonly key: string;
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
/** Run the health check and return a Terminus HealthIndicatorResult. */
|
|
58
|
+
check(): HealthIndicatorResult | Promise<HealthIndicatorResult>;
|
|
59
59
|
}
|
|
60
60
|
```
|
|
61
61
|
|
|
@@ -63,37 +63,40 @@ interface IHealthIndicator {
|
|
|
63
63
|
|
|
64
64
|
All 12 platform libraries provide a health indicator via their `/health` subpath:
|
|
65
65
|
|
|
66
|
-
| Library
|
|
67
|
-
|
|
|
68
|
-
| `platform-database`
|
|
69
|
-
| `platform-blob-storage`
|
|
70
|
-
| `platform-mailing`
|
|
71
|
-
| `platform-caching`
|
|
72
|
-
| `platform-queue`
|
|
73
|
-
| `platform-payments`
|
|
74
|
-
| `platform-esigning`
|
|
75
|
-
| `platform-intelligence`
|
|
76
|
-
| `platform-analytics`
|
|
77
|
-
| `platform-telemetry`
|
|
78
|
-
| `platform-authentication` | `@breadstone/archipel-platform-authentication/health` | `AuthenticationHealthIndicator` | `authentication` | Always `up`
|
|
79
|
-
| `platform-mcp`
|
|
66
|
+
| Library | Subpath Import | Class | Key | Check Behavior |
|
|
67
|
+
| ------------------------- | ----------------------------------------------------- | ------------------------------- | ---------------- | --------------------------------------------------------------------------------------- |
|
|
68
|
+
| `platform-database` | `@breadstone/archipel-platform-database/health` | `DatabaseHealthIndicator` | `database` | Prisma `SELECT 1` ping |
|
|
69
|
+
| `platform-blob-storage` | `@breadstone/archipel-platform-blob-storage/health` | `BlobHealthIndicator` | `blob` | HTTP ping to blob URL (or `disabled` if unconfigured) |
|
|
70
|
+
| `platform-mailing` | `@breadstone/archipel-platform-mailing/health` | `MailHealthIndicator` | `mail` | Validates mail host, user, and port config |
|
|
71
|
+
| `platform-caching` | `@breadstone/archipel-platform-caching/health` | `CachingHealthIndicator` | `caching` | Always `up` |
|
|
72
|
+
| `platform-queue` | `@breadstone/archipel-platform-queue/health` | `QueueHealthIndicator` | `queue` | Always `up` |
|
|
73
|
+
| `platform-payments` | `@breadstone/archipel-platform-payments/health` | `PaymentHealthIndicator` | `payment` | Calls `PaymentClientPort.ping()` to verify provider connectivity |
|
|
74
|
+
| `platform-esigning` | `@breadstone/archipel-platform-esigning/health` | `EsigningHealthIndicator` | `esigning` | Calls `EsigningClientPort.ping()` to verify provider connectivity, reports `providerId` |
|
|
75
|
+
| `platform-intelligence` | `@breadstone/archipel-platform-intelligence/health` | `IntelligenceHealthIndicator` | `intelligence` | Runs a bounded provider probe and reports capability plus realtime state |
|
|
76
|
+
| `platform-analytics` | `@breadstone/archipel-platform-analytics/health` | `AnalyticsHealthIndicator` | `analytics` | Calls `AnalyticsClientPort.ping()` to verify provider readiness |
|
|
77
|
+
| `platform-telemetry` | `@breadstone/archipel-platform-telemetry/health` | `TelemetryHealthIndicator` | `telemetry` | Checks `OtelSdkHolder.isInitialized` for SDK presence |
|
|
78
|
+
| `platform-authentication` | `@breadstone/archipel-platform-authentication/health` | `AuthenticationHealthIndicator` | `authentication` | Always `up` |
|
|
79
|
+
| `platform-mcp` | `@breadstone/archipel-platform-mcp/health` | `McpHealthIndicator` | `mcp` | Checks tool/resource/prompt registry counts, reports breakdown |
|
|
80
80
|
|
|
81
81
|
### Indicator Categories
|
|
82
82
|
|
|
83
83
|
**Active checks** — perform a real probe:
|
|
84
|
+
|
|
84
85
|
- `DatabaseHealthIndicator` — executes a SQL ping
|
|
85
86
|
- `BlobHealthIndicator` — sends an HTTP request to the blob URL
|
|
86
87
|
- `MailHealthIndicator` — validates configuration values
|
|
87
88
|
- `PaymentHealthIndicator` — calls `PaymentClientPort.ping()` (adapters can override for real API calls)
|
|
88
89
|
- `EsigningHealthIndicator` — calls `EsigningClientPort.ping()` (adapters can override for real API calls)
|
|
90
|
+
- `IntelligenceHealthIndicator` — probes the default language provider with an independent three-second timeout
|
|
89
91
|
- `AnalyticsHealthIndicator` — calls `AnalyticsClientPort.ping()` (adapters can override for SDK readiness checks)
|
|
90
92
|
|
|
91
93
|
**State checks** — inspect in-memory state (zero-cost, no I/O):
|
|
92
|
-
|
|
94
|
+
|
|
93
95
|
- `TelemetryHealthIndicator` — checks whether the OpenTelemetry SDK has been initialized
|
|
94
96
|
- `McpHealthIndicator` — verifies at least one tool/resource/prompt handler is registered
|
|
95
97
|
|
|
96
98
|
**Stub checks** — always report `up`:
|
|
99
|
+
|
|
97
100
|
- `CachingHealthIndicator`, `QueueHealthIndicator`, `AuthenticationHealthIndicator`
|
|
98
101
|
|
|
99
102
|
## Quick Start
|
|
@@ -111,15 +114,10 @@ import { PaymentHealthIndicator } from '@breadstone/archipel-platform-payments/h
|
|
|
111
114
|
import { CachingHealthIndicator } from '@breadstone/archipel-platform-caching/health';
|
|
112
115
|
|
|
113
116
|
@Module({
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
MailHealthIndicator,
|
|
119
|
-
PaymentHealthIndicator,
|
|
120
|
-
CachingHealthIndicator,
|
|
121
|
-
]),
|
|
122
|
-
],
|
|
117
|
+
imports: [
|
|
118
|
+
// ... your feature modules
|
|
119
|
+
HealthModule.withIndicators([DatabaseHealthIndicator, MailHealthIndicator, PaymentHealthIndicator, CachingHealthIndicator]),
|
|
120
|
+
],
|
|
123
121
|
})
|
|
124
122
|
export class AppModule {}
|
|
125
123
|
```
|
|
@@ -134,12 +132,12 @@ import { HealthOrchestrator } from '@breadstone/archipel-platform-health';
|
|
|
134
132
|
|
|
135
133
|
@Controller('health')
|
|
136
134
|
export class HealthController {
|
|
137
|
-
|
|
135
|
+
constructor(private readonly _health: HealthOrchestrator) {}
|
|
138
136
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
137
|
+
@Get()
|
|
138
|
+
public async check() {
|
|
139
|
+
return this._health.check();
|
|
140
|
+
}
|
|
143
141
|
}
|
|
144
142
|
```
|
|
145
143
|
|
|
@@ -147,25 +145,27 @@ export class HealthController {
|
|
|
147
145
|
|
|
148
146
|
```json
|
|
149
147
|
{
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
148
|
+
"status": "ok",
|
|
149
|
+
"details": {
|
|
150
|
+
"database": { "status": "up" },
|
|
151
|
+
"mail": { "status": "up" },
|
|
152
|
+
"payment": { "status": "up" },
|
|
153
|
+
"caching": { "status": "up" },
|
|
154
|
+
"intelligence": {
|
|
155
|
+
"status": "up",
|
|
156
|
+
"providerStatus": "operational",
|
|
157
|
+
"provider": "openai",
|
|
158
|
+
"model": "gpt-5.4-mini",
|
|
159
|
+
"failureCode": null,
|
|
160
|
+
"realtime": {
|
|
161
|
+
"enabled": true,
|
|
162
|
+
"providers": ["openai", "google"],
|
|
163
|
+
"activeSessions": 2
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
"mcp": { "status": "up", "tools": 5, "resources": 2, "prompts": 1 },
|
|
167
|
+
"telemetry": { "status": "up", "sdkInitialized": true }
|
|
168
|
+
}
|
|
169
169
|
}
|
|
170
170
|
```
|
|
171
171
|
|
|
@@ -173,15 +173,19 @@ When a provider is not registered (e.g., no `PaymentClientPort` injected), the i
|
|
|
173
173
|
|
|
174
174
|
```json
|
|
175
175
|
{
|
|
176
|
-
|
|
176
|
+
"payment": { "status": "up", "disabled": true }
|
|
177
177
|
}
|
|
178
178
|
```
|
|
179
179
|
|
|
180
|
-
When
|
|
180
|
+
When an intelligence probe fails unexpectedly, the indicator reports a stable
|
|
181
|
+
failure code without leaking provider transport details:
|
|
181
182
|
|
|
182
183
|
```json
|
|
183
184
|
{
|
|
184
|
-
|
|
185
|
+
"intelligence": {
|
|
186
|
+
"status": "down",
|
|
187
|
+
"failureCode": "INTELLIGENCE_HEALTH_CHECK_FAILED"
|
|
188
|
+
}
|
|
185
189
|
}
|
|
186
190
|
```
|
|
187
191
|
|
|
@@ -196,21 +200,18 @@ import type { HealthIndicatorResult } from '@nestjs/terminus';
|
|
|
196
200
|
|
|
197
201
|
@Injectable()
|
|
198
202
|
export class SearchHealthIndicator implements IHealthIndicator {
|
|
199
|
-
|
|
203
|
+
public readonly key = 'search';
|
|
200
204
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
205
|
+
public check(): HealthIndicatorResult<'search'> {
|
|
206
|
+
return { search: { status: 'up' } };
|
|
207
|
+
}
|
|
204
208
|
}
|
|
205
209
|
```
|
|
206
210
|
|
|
207
211
|
Register it alongside built-in indicators:
|
|
208
212
|
|
|
209
213
|
```typescript
|
|
210
|
-
HealthModule.withIndicators([
|
|
211
|
-
DatabaseHealthIndicator,
|
|
212
|
-
SearchHealthIndicator,
|
|
213
|
-
]);
|
|
214
|
+
HealthModule.withIndicators([DatabaseHealthIndicator, SearchHealthIndicator]);
|
|
214
215
|
```
|
|
215
216
|
|
|
216
217
|
## Tree-Shaking
|
|
@@ -221,9 +222,9 @@ Health indicators are **not** included in the main library entry point. They are
|
|
|
221
222
|
|
|
222
223
|
Each health indicator requires these optional peer dependencies:
|
|
223
224
|
|
|
224
|
-
| Package
|
|
225
|
-
|
|
|
225
|
+
| Package | Notes |
|
|
226
|
+
| -------------------------------------- | ----------------------------------------------- |
|
|
226
227
|
| `@breadstone/archipel-platform-health` | `IHealthIndicator` interface and `HealthModule` |
|
|
227
|
-
| `@nestjs/terminus`
|
|
228
|
+
| `@nestjs/terminus` | `HealthIndicatorResult` type |
|
|
228
229
|
|
|
229
230
|
Both are listed as optional peer dependencies in each library's `package.json`.
|