@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,506 +1,118 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: AI Realtime Voice
|
|
3
|
-
description: Build server-owned
|
|
4
|
-
order:
|
|
3
|
+
description: Build server-owned bidirectional audio and text sessions with provider-neutral events, limits, cleanup, and metering.
|
|
4
|
+
order: 17
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AI Realtime Voice
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
failure recovery.
|
|
9
|
+
`IntelligenceRealtimeSessionFactory` creates provider-neutral, server-owned
|
|
10
|
+
audio/text sessions. Provider credentials and upstream sockets remain in the
|
|
11
|
+
backend.
|
|
13
12
|
|
|
14
|
-
Realtime
|
|
15
|
-
small audio fragments continuously while each layer persists only the data it
|
|
16
|
-
owns. This preserves live interaction without making the complete recording a
|
|
17
|
-
single point of failure.
|
|
13
|
+
Realtime is separate from `IntelligenceTranscriptionGenerator.stream()`:
|
|
18
14
|
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
- streaming transcription accepts raw audio and emits transcript updates;
|
|
16
|
+
- realtime is a bidirectional conversational session with input/output audio,
|
|
17
|
+
text, tools, turn detection, interruption, and session state.
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
## Architecture and SDK Boundary
|
|
25
|
-
|
|
26
|
-
Archipel owns the upstream provider connection. A consuming application puts
|
|
27
|
-
its authenticated client transport and domain workflow in front of the stable
|
|
28
|
-
Archipel port.
|
|
29
|
-
|
|
30
|
-
```mermaid
|
|
31
|
-
flowchart LR
|
|
32
|
-
Client[Browser or native client\nMicrophone, playback, local chunk queue]
|
|
33
|
-
Gateway[Application realtime gateway\nAuth, tenant, sequencing, acknowledgements]
|
|
34
|
-
Persistence[Application persistence\nAudio, transcript, session state]
|
|
35
|
-
Factory[IntelligenceRealtimeSessionFactory]
|
|
36
|
-
Port[IntelligenceRealtimeSessionPort]
|
|
37
|
-
AiSdk[Vercel AI SDK 7\nRealtime provider model]
|
|
38
|
-
Socket[Generic server WebSocket transport]
|
|
39
|
-
Provider[OpenAI, Google, or xAI]
|
|
40
|
-
|
|
41
|
-
Client <--> Gateway
|
|
42
|
-
Gateway <--> Persistence
|
|
43
|
-
Gateway <--> Port
|
|
44
|
-
Factory --> Port
|
|
45
|
-
Port --> AiSdk
|
|
46
|
-
AiSdk --> Socket
|
|
47
|
-
Socket <--> Provider
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Provider-specific token creation, event serialization, event parsing, and
|
|
51
|
-
model selection use the Vercel AI SDK provider packages. Archipel uses the
|
|
52
|
-
generic `ws` transport to open the WebSocket configuration returned by the AI
|
|
53
|
-
SDK model adapter. It does not install the official OpenAI SDK, expose an
|
|
54
|
-
OpenAI client, or make provider-specific calls outside the AI SDK adapter.
|
|
55
|
-
|
|
56
|
-
The AI SDK realtime model contract is experimental. Archipel isolates that
|
|
57
|
-
contract behind its own `/realtime` entry point so application code depends on
|
|
58
|
-
the normalized ports and events. The `raw` field on server events remains an
|
|
59
|
-
escape hatch for audited provider-specific diagnostics.
|
|
60
|
-
|
|
61
|
-
### Responsibility boundary
|
|
62
|
-
|
|
63
|
-
| Layer | Owns |
|
|
64
|
-
| --- | --- |
|
|
65
|
-
| Client | Microphone permission, capture, playback, local durable chunk queue, UI state |
|
|
66
|
-
| Application | Authentication, authorization, tenant context, client WebSocket, durable audio/transcript state, tool execution, reconnect policy |
|
|
67
|
-
| Archipel | Provider configuration, short-lived provider token, upstream WebSocket, event normalization, bounded queues, metering emission, shutdown |
|
|
68
|
-
| Provider | Model conversation state and provider-native usage reporting |
|
|
69
|
-
|
|
70
|
-
Archipel never exposes provider credentials to the client and does not own the
|
|
71
|
-
application's audio recording or consultation record.
|
|
72
|
-
|
|
73
|
-
---
|
|
74
|
-
|
|
75
|
-
## Installation
|
|
76
|
-
|
|
77
|
-
Install Archipel, the AI SDK core, and only the provider packages used by the
|
|
78
|
-
application:
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
yarn add @breadstone/archipel-platform-intelligence ai
|
|
82
|
-
|
|
83
|
-
# Add one or more Vercel AI SDK providers
|
|
84
|
-
yarn add @ai-sdk/openai
|
|
85
|
-
yarn add @ai-sdk/google
|
|
86
|
-
yarn add @ai-sdk/xai
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
| Provider | Vercel AI SDK package | Archipel loader |
|
|
90
|
-
| --- | --- | --- |
|
|
91
|
-
| OpenAI | `@ai-sdk/openai` | `loadOpenAIRealtimeModel` |
|
|
92
|
-
| Google Gemini Live | `@ai-sdk/google` | `loadGoogleRealtimeModel` |
|
|
93
|
-
| xAI / Grok Voice | `@ai-sdk/xai` | `loadGrokRealtimeModel` |
|
|
94
|
-
|
|
95
|
-
Do not add the official `openai` package for this integration.
|
|
96
|
-
|
|
97
|
-
---
|
|
98
|
-
|
|
99
|
-
## Register Realtime Providers
|
|
100
|
-
|
|
101
|
-
Register realtime loaders under the existing `IntelligenceModule`. The root
|
|
102
|
-
package stays provider-neutral; each loader is imported from a tree-shakable
|
|
103
|
-
provider subpath.
|
|
19
|
+
## Registration
|
|
104
20
|
|
|
105
21
|
```typescript
|
|
106
22
|
import { Module } from '@nestjs/common';
|
|
107
|
-
import {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
} from '@breadstone/archipel-platform-intelligence';
|
|
111
|
-
import {
|
|
112
|
-
import { loadGrokRealtimeModel } from '@breadstone/archipel-platform-intelligence/providers/grok';
|
|
113
|
-
import { loadOpenAIRealtimeModel } from '@breadstone/archipel-platform-intelligence/providers/openai';
|
|
114
|
-
import { ApplicationRealtimeMeteringAdapter } from './ApplicationRealtimeMeteringAdapter';
|
|
23
|
+
import { IntelligenceModule } from '@breadstone/archipel-platform-intelligence';
|
|
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';
|
|
115
28
|
|
|
116
29
|
@Module({
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
+
],
|
|
133
51
|
})
|
|
134
|
-
export class
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
Configure the default provider and its credentials through the normal Archipel
|
|
138
|
-
configuration registry:
|
|
139
|
-
|
|
140
|
-
```dotenv
|
|
141
|
-
INTELLIGENCE_PROVIDER=openai
|
|
142
|
-
OPENAI_API_KEY=sk-...
|
|
143
|
-
|
|
144
|
-
# Optional when every createSession() call supplies its model
|
|
145
|
-
INTELLIGENCE_MODEL=gpt-realtime
|
|
52
|
+
export class ApplicationModule {}
|
|
146
53
|
```
|
|
147
54
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
`XAI_API_KEY`.
|
|
55
|
+
The package owns all provider runtime dependencies. Applications do not install
|
|
56
|
+
or import provider SDKs.
|
|
151
57
|
|
|
152
|
-
|
|
153
|
-
disable realtime configuration validation when a session is created. If the
|
|
154
|
-
same module also uses text generation, register the normal language-model
|
|
155
|
-
loaders and leave validation enabled.
|
|
156
|
-
|
|
157
|
-
The provider and API key still come from the normal intelligence
|
|
158
|
-
configuration. `createSession()` may override the provider and model per
|
|
159
|
-
logical session.
|
|
160
|
-
|
|
161
|
-
---
|
|
162
|
-
|
|
163
|
-
## Create and Connect a Session
|
|
164
|
-
|
|
165
|
-
`createSession()` validates the application-owned session identifier, resolves
|
|
166
|
-
the configured provider, loads the AI SDK realtime model, and returns an idle
|
|
167
|
-
port. `connect()` then creates the short-lived provider token, opens the
|
|
168
|
-
upstream WebSocket, and applies the session configuration.
|
|
169
|
-
|
|
170
|
-
```typescript
|
|
171
|
-
import { Injectable } from '@nestjs/common';
|
|
172
|
-
import { IntelligenceProviderNames } from '@breadstone/archipel-platform-intelligence';
|
|
173
|
-
import {
|
|
174
|
-
IntelligenceRealtimeSessionFactory,
|
|
175
|
-
type IntelligenceRealtimeServerEvent,
|
|
176
|
-
type IntelligenceRealtimeSessionPort,
|
|
177
|
-
} from '@breadstone/archipel-platform-intelligence/realtime';
|
|
178
|
-
|
|
179
|
-
@Injectable()
|
|
180
|
-
export class RealtimeConsultationCoordinator {
|
|
181
|
-
public constructor(
|
|
182
|
-
private readonly _sessions: IntelligenceRealtimeSessionFactory,
|
|
183
|
-
private readonly _events: ConsultationEventStore,
|
|
184
|
-
) {}
|
|
185
|
-
|
|
186
|
-
public async start(consultationId: string): Promise<IntelligenceRealtimeSessionPort> {
|
|
187
|
-
const session = await this._sessions.createSession({
|
|
188
|
-
sessionId: consultationId,
|
|
189
|
-
provider: IntelligenceProviderNames.OpenAI,
|
|
190
|
-
model: 'gpt-realtime',
|
|
191
|
-
metadata: {
|
|
192
|
-
feature: 'consultation',
|
|
193
|
-
consultationId,
|
|
194
|
-
},
|
|
195
|
-
sessionConfiguration: {
|
|
196
|
-
instructions: 'Transcribe the discussion and suggest concise next questions.',
|
|
197
|
-
inputAudioFormat: {
|
|
198
|
-
type: 'audio/pcm',
|
|
199
|
-
rate: 24_000,
|
|
200
|
-
},
|
|
201
|
-
inputAudioTranscription: {},
|
|
202
|
-
outputModalities: ['text', 'audio'],
|
|
203
|
-
turnDetection: {
|
|
204
|
-
type: 'server-vad',
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
onEvent: async (event: IntelligenceRealtimeServerEvent): Promise<void> => {
|
|
208
|
-
await this._events.persistThenPublish(consultationId, event);
|
|
209
|
-
},
|
|
210
|
-
onError: async (error: Error): Promise<void> => {
|
|
211
|
-
await this._events.persistError(consultationId, error);
|
|
212
|
-
},
|
|
213
|
-
onClose: async (event): Promise<void> => {
|
|
214
|
-
await this._events.persistClose(consultationId, event);
|
|
215
|
-
},
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
await session.connect();
|
|
219
|
-
|
|
220
|
-
return session;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
The application must retain the returned port for the lifetime of its client
|
|
226
|
-
gateway connection. The factory tracks ports internally for resource limits
|
|
227
|
-
and Nest shutdown, but deliberately does not act as an application session
|
|
228
|
-
repository.
|
|
229
|
-
|
|
230
|
-
### Two identifiers
|
|
231
|
-
|
|
232
|
-
| Identifier | Lifetime | Purpose |
|
|
233
|
-
| --- | --- | --- |
|
|
234
|
-
| `sessionId` | Application-defined logical conversation | Persistence, authorization, billing account, recovery |
|
|
235
|
-
| `connectionId` | One Archipel/provider WebSocket | Idempotency, audit correlation, distinguishing reconnects |
|
|
236
|
-
|
|
237
|
-
A reconnect keeps the logical `sessionId` and creates a new `connectionId`.
|
|
238
|
-
|
|
239
|
-
---
|
|
240
|
-
|
|
241
|
-
## Forward Audio Live and Durably
|
|
242
|
-
|
|
243
|
-
`appendAudio()` accepts one base64-encoded fragment and forwards it immediately
|
|
244
|
-
to the active provider input buffer. A fragment may contain at most 1,500,000
|
|
245
|
-
base64 characters. The configured sample rate and format must match the bytes
|
|
246
|
-
produced by the client.
|
|
247
|
-
|
|
248
|
-
Use a small, ordered application envelope around the Archipel payload:
|
|
58
|
+
## Create and Connect
|
|
249
59
|
|
|
250
60
|
```typescript
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
small persistence operation.
|
|
266
|
-
5. The application acknowledges the chunk only after durable persistence and
|
|
267
|
-
successful forwarding.
|
|
268
|
-
6. The client removes the locally queued fragment after acknowledgement.
|
|
269
|
-
|
|
270
|
-
This is persist-per-fragment, not record-for-an-hour-then-upload. If the client
|
|
271
|
-
or network fails, only unacknowledged fragments remain to be retried.
|
|
272
|
-
|
|
273
|
-
Archipel intentionally does not define `chunkId`, acknowledgements, IndexedDB,
|
|
274
|
-
or the application WebSocket protocol. Those belong to the consuming domain;
|
|
275
|
-
the upstream provider contract only needs the ordered base64 audio.
|
|
276
|
-
|
|
277
|
-
### Turn completion
|
|
278
|
-
|
|
279
|
-
With server voice-activity detection, the provider determines turn boundaries.
|
|
280
|
-
For push-to-talk, disable automatic turn detection and commit explicitly:
|
|
281
|
-
|
|
282
|
-
```typescript
|
|
283
|
-
const session = await this._sessions.createSession({
|
|
284
|
-
sessionId: consultationId,
|
|
285
|
-
model: 'gpt-realtime',
|
|
286
|
-
sessionConfiguration: {
|
|
287
|
-
inputAudioFormat: { type: 'audio/pcm', rate: 24_000 },
|
|
288
|
-
turnDetection: null,
|
|
289
|
-
},
|
|
61
|
+
const session = await sessions.createSession({
|
|
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),
|
|
290
75
|
});
|
|
291
76
|
|
|
292
77
|
await session.connect();
|
|
293
|
-
await session.
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
Use `clearAudio()` to discard the uncommitted provider input buffer.
|
|
299
|
-
|
|
300
|
-
---
|
|
301
|
-
|
|
302
|
-
## Choose the Interaction Mode
|
|
303
|
-
|
|
304
|
-
The application controls whether the model speaks. There is no separate
|
|
305
|
-
provider strategy or SDK for a silent assistant.
|
|
306
|
-
|
|
307
|
-
| Mode | Session behavior | Application behavior |
|
|
308
|
-
| --- | --- | --- |
|
|
309
|
-
| Spoken assistant | `outputModalities: ['text', 'audio']` | Stream `audio-delta` to playback and show transcript |
|
|
310
|
-
| Silent copilot | `outputModalities: ['text']` | Show suggestions, questions, or tasks; do not request/play audio |
|
|
311
|
-
| Push-to-talk | `turnDetection: null` | Commit audio and request a response explicitly |
|
|
312
|
-
| Passive capture | Enable input transcription and avoid response requests | Persist transcript events; verify provider-specific automatic-response behavior |
|
|
313
|
-
|
|
314
|
-
Providers do not all support identical voices, formats, transcription models,
|
|
315
|
-
or automatic-response controls. Keep the common workflow on Archipel contracts
|
|
316
|
-
and place unavoidable provider-specific values in `providerOptions`.
|
|
317
|
-
|
|
318
|
-
Text turns use the same session:
|
|
319
|
-
|
|
320
|
-
```typescript
|
|
321
|
-
await session.sendText('Summarize the unanswered requirements.');
|
|
322
|
-
await session.cancelResponse();
|
|
323
|
-
```
|
|
324
|
-
|
|
325
|
-
---
|
|
326
|
-
|
|
327
|
-
## Handle Normalized Events
|
|
328
|
-
|
|
329
|
-
`onEvent` receives events in provider wire order for the current connection.
|
|
330
|
-
The most relevant event families are:
|
|
331
|
-
|
|
332
|
-
| Family | Examples | Typical application action |
|
|
333
|
-
| --- | --- | --- |
|
|
334
|
-
| Speech | `speech-started`, `speech-stopped`, `audio-committed` | Update listening state and turn boundaries |
|
|
335
|
-
| Input transcript | `input-transcription-completed` | Persist the final customer/seller transcript item |
|
|
336
|
-
| Text output | `text-delta`, `text-done` | Render suggestions or assistant replies |
|
|
337
|
-
| Audio output | `audio-delta`, `audio-done` | Stream base64 audio to the client player |
|
|
338
|
-
| Audio transcript | `audio-transcript-delta`, `audio-transcript-done` | Persist spoken assistant text |
|
|
339
|
-
| Tools | `function-call-arguments-delta`, `function-call-arguments-done` | Validate, authorize, execute, and return output |
|
|
340
|
-
| Lifecycle | `response-created`, `response-done`, `error` | Track response state and diagnostics |
|
|
341
|
-
|
|
342
|
-
Persist final events and enough ordered deltas to recover the UI. Treat `raw`
|
|
343
|
-
as sensitive provider data: redact it according to the application's AI audit
|
|
344
|
-
and privacy policy before storing it.
|
|
345
|
-
|
|
346
|
-
### Tool calls
|
|
347
|
-
|
|
348
|
-
Tools registered on `IntelligenceModule` are converted to realtime function
|
|
349
|
-
definitions through the AI SDK when `sessionConfiguration.tools` is omitted.
|
|
350
|
-
Use `activeToolNames` as an allow-list per session.
|
|
351
|
-
|
|
352
|
-
When `function-call-arguments-done` arrives, the application remains
|
|
353
|
-
responsible for parsing and validating the arguments, checking tenant and user
|
|
354
|
-
permissions, invoking the domain operation, and returning the result:
|
|
355
|
-
|
|
356
|
-
```typescript
|
|
357
|
-
await session.addToolOutput(event.callId, toolResult, event.name);
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
Never execute provider-supplied arguments without the normal application
|
|
361
|
-
authorization and validation path.
|
|
362
|
-
|
|
363
|
-
---
|
|
364
|
-
|
|
365
|
-
## Metering, Tokens, and AI Audit
|
|
366
|
-
|
|
367
|
-
Realtime traffic does not pass through a request-scoped HTTP token
|
|
368
|
-
interceptor. `IntelligenceRealtimeMeteringPort` is the dedicated accounting
|
|
369
|
-
boundary for long-lived sessions.
|
|
370
|
-
|
|
371
|
-
```typescript
|
|
372
|
-
import { Injectable } from '@nestjs/common';
|
|
373
|
-
import {
|
|
374
|
-
IntelligenceRealtimeMeteringPort,
|
|
375
|
-
type IntelligenceRealtimeMeteringEvent,
|
|
376
|
-
} from '@breadstone/archipel-platform-intelligence/realtime';
|
|
377
|
-
|
|
378
|
-
@Injectable()
|
|
379
|
-
export class ApplicationRealtimeMeteringAdapter extends IntelligenceRealtimeMeteringPort {
|
|
380
|
-
public constructor(private readonly _ledger: AiUsageLedger) {
|
|
381
|
-
super();
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
public override async report(event: IntelligenceRealtimeMeteringEvent): Promise<void> {
|
|
385
|
-
await this._ledger.recordRealtimeEventAtomically({
|
|
386
|
-
idempotencyKey: event.eventId,
|
|
387
|
-
event,
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
}
|
|
78
|
+
await session.send({
|
|
79
|
+
type: 'input_audio_buffer.append',
|
|
80
|
+
audio: base64AudioChunk,
|
|
81
|
+
});
|
|
391
82
|
```
|
|
392
83
|
|
|
393
|
-
The application
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
2. debit the application's token or credit ledger when the event is billable;
|
|
397
|
-
3. append the normalized AI audit entry;
|
|
398
|
-
4. commit all three changes together.
|
|
399
|
-
|
|
400
|
-
| Event | Recommended use |
|
|
401
|
-
| --- | --- |
|
|
402
|
-
| `session-started` | Open one auditable provider connection |
|
|
403
|
-
| `billing-interval` | Provider-independent commercial charging every 30 seconds and for the final partial interval |
|
|
404
|
-
| `provider-usage` | Exact input/output, text/audio, cached, and total token reconciliation when supplied |
|
|
405
|
-
| `session-ended` | Final duration, close code, and close reason |
|
|
406
|
-
|
|
407
|
-
Choose one commercial charging basis. A common strategy debits credits from
|
|
408
|
-
`billing-interval` and stores `provider-usage` only for provider-cost
|
|
409
|
-
reconciliation. Do not debit both event types unless the pricing model
|
|
410
|
-
intentionally contains both dimensions.
|
|
411
|
-
|
|
412
|
-
The default metering adapter is a no-op. Production applications that charge
|
|
413
|
-
users or require AI audit completeness must register a durable adapter. Keep
|
|
414
|
-
that adapter fast and local—normally a database transaction or transactional
|
|
415
|
-
outbox. Archipel retries a failed adapter write twice and then reports a
|
|
416
|
-
realtime error; it cannot make a remote application datastore durable on the
|
|
417
|
-
application's behalf.
|
|
418
|
-
|
|
419
|
-
---
|
|
84
|
+
The application WebSocket authenticates the user, resolves tenant context,
|
|
85
|
+
checks permissions and AI availability, and forwards only normalized events.
|
|
86
|
+
Never expose provider credentials or an upstream provider socket to the browser.
|
|
420
87
|
|
|
421
|
-
##
|
|
88
|
+
## Tools and Metering
|
|
422
89
|
|
|
423
|
-
|
|
90
|
+
When explicit realtime tools are absent, Archipel converts registered
|
|
91
|
+
application tools to provider-neutral realtime definitions. `activeToolNames`
|
|
92
|
+
restricts the available set.
|
|
424
93
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
| `maxBufferedBytes` | `4 MiB` | Maximum provider WebSocket backpressure buffer |
|
|
430
|
-
| `connectionTimeoutMs` | `5_000` | Provider token/setup and socket-open timeout; capped at 5 seconds |
|
|
431
|
-
| `closeTimeoutMs` | `5_000` | Graceful close and metering-flush timeout; capped at 5 seconds |
|
|
432
|
-
| `meteringIntervalMs` | `30_000` | Provider-independent billing interval |
|
|
433
|
-
| `tokenRequestMaxRetries` | `2` | Additional transient token-creation attempts; capped at 2 |
|
|
94
|
+
Implement `IntelligenceRealtimeMeteringPort` to persist usage events
|
|
95
|
+
idempotently. Session-start, interval, provider-usage, and session-end events
|
|
96
|
+
carry stable event IDs for deduplication. Business-critical charging should be
|
|
97
|
+
transactional with the application usage ledger.
|
|
434
98
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
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.
|
|
439
105
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
## Failure and Recovery
|
|
443
|
-
|
|
444
|
-
Archipel retries transient provider-token creation, but it never silently
|
|
445
|
-
reconnects a dropped conversation. A new provider WebSocket has new
|
|
446
|
-
conversation state and a new `connectionId`; automatic reconnect would hide
|
|
447
|
-
that semantic break.
|
|
448
|
-
|
|
449
|
-
Handle failures by phase through `IntelligenceRealtimeError`:
|
|
450
|
-
|
|
451
|
-
| Phase | Meaning |
|
|
452
|
-
| --- | --- |
|
|
453
|
-
| `configuration` | Invalid provider or session configuration |
|
|
454
|
-
| `token` | Short-lived provider credential creation failed |
|
|
455
|
-
| `connect` | Upstream WebSocket could not open |
|
|
456
|
-
| `send` | Outbound serialization, state, queue, or socket failure |
|
|
457
|
-
| `receive` | Provider event parsing or inbound queue failure |
|
|
458
|
-
| `metering` | Application metering adapter failed |
|
|
459
|
-
| `close` | Graceful shutdown failed |
|
|
460
|
-
|
|
461
|
-
The error also contains `provider`, `model`, `sessionId`, and `isRetryable`.
|
|
462
|
-
Connect and send methods reject their promises; asynchronous receive and
|
|
463
|
-
metering failures arrive through `onError`. `onClose` is the terminal upstream
|
|
464
|
-
state.
|
|
465
|
-
|
|
466
|
-
Recovery belongs to the application:
|
|
467
|
-
|
|
468
|
-
1. stop acknowledging new client chunks for the failed connection;
|
|
469
|
-
2. keep unacknowledged chunks in the client's durable queue;
|
|
470
|
-
3. persist the terminal connection state and close reason;
|
|
471
|
-
4. create a new Archipel session with the same logical `sessionId`;
|
|
472
|
-
5. reconstruct safe context from the durable transcript or a compact summary;
|
|
473
|
-
6. resume with a new `connectionId` and explicit audit entry.
|
|
474
|
-
|
|
475
|
-
The normalized realtime contract does not promise lossless replay of arbitrary
|
|
476
|
-
provider-native conversation history. Rebuild only the context supported by
|
|
477
|
-
the selected provider and application policy.
|
|
478
|
-
|
|
479
|
-
For horizontal deployments, route all frames for one active upstream
|
|
480
|
-
connection to its owning process, for example through sticky routing or a
|
|
481
|
-
distributed ownership record. Never depend on the factory's in-memory map as a
|
|
482
|
-
cluster-wide registry.
|
|
483
|
-
|
|
484
|
-
Nest shutdown calls `close()` for all owned sessions and waits for queued
|
|
485
|
-
metering within the configured close timeout.
|
|
486
|
-
|
|
487
|
-
---
|
|
106
|
+
## Runtime Guarantees
|
|
488
107
|
|
|
489
|
-
|
|
108
|
+
The factory enforces:
|
|
490
109
|
|
|
491
|
-
-
|
|
492
|
-
-
|
|
493
|
-
-
|
|
494
|
-
-
|
|
495
|
-
-
|
|
496
|
-
-
|
|
497
|
-
- A durable `IntelligenceRealtimeMeteringPort` is registered.
|
|
498
|
-
- `eventId` has a database uniqueness constraint.
|
|
499
|
-
- Commercial interval charging and provider token reconciliation are not double-counted.
|
|
500
|
-
- Backpressure and tenant quotas are bounded outside the per-process Archipel limits.
|
|
501
|
-
- Reconnect creates a new connection and is visible in audit history.
|
|
502
|
-
- Shutdown hooks are enabled in the Nest application.
|
|
110
|
+
- active-session, metadata, instruction, tool, message, and buffer bounds;
|
|
111
|
+
- connection, idle, absolute-session, and close timeouts;
|
|
112
|
+
- upstream error normalization through `IntelligenceRealtimeError`;
|
|
113
|
+
- backpressure limits and deterministic cleanup;
|
|
114
|
+
- shutdown cleanup via `OnModuleDestroy`;
|
|
115
|
+
- server-owned provider/model resolution.
|
|
503
116
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
for the complete contracts.
|
|
117
|
+
OpenAI, Google, xAI/Grok, and Vercel AI Gateway currently expose realtime model
|
|
118
|
+
adapters. Unsupported provider/capability pairs fail before a socket is opened.
|