@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.
Files changed (216) hide show
  1. package/data/guides/ai-image-generation.md +101 -0
  2. package/data/guides/ai-realtime-voice.md +85 -473
  3. package/data/guides/ai-text-generation.md +98 -635
  4. package/data/guides/health-indicators.md +67 -66
  5. package/data/guides/index.md +2 -1
  6. package/data/guides/intelligence-prompts-warm-up.md +81 -312
  7. package/data/packages/platform-intelligence/api/Class.AnthropicIntelligenceProviderAdapter.md +122 -0
  8. package/data/packages/platform-intelligence/api/Class.GatewayIntelligenceProviderAdapter.md +122 -0
  9. package/data/packages/platform-intelligence/api/Class.GoogleIntelligenceProviderAdapter.md +122 -0
  10. package/data/packages/platform-intelligence/api/Class.GrokIntelligenceProviderAdapter.md +122 -0
  11. package/data/packages/platform-intelligence/api/Class.IntelligenceAgent.md +95 -0
  12. package/data/packages/platform-intelligence/api/Class.IntelligenceAgentFactory.md +11 -23
  13. package/data/packages/platform-intelligence/api/Class.IntelligenceEmbeddingGenerator.md +25 -21
  14. package/data/packages/platform-intelligence/api/Class.IntelligenceHealthIndicator.md +15 -10
  15. package/data/packages/platform-intelligence/api/Class.IntelligenceImageGenerator.md +117 -0
  16. package/data/packages/platform-intelligence/api/Class.IntelligenceLanguageGenerator.md +159 -0
  17. package/data/packages/platform-intelligence/api/Class.IntelligenceModule.md +2 -2
  18. package/data/packages/platform-intelligence/api/Class.IntelligencePromptExecutor.md +6 -6
  19. package/data/packages/platform-intelligence/api/Class.IntelligencePromptPolicyPort.md +1 -1
  20. package/data/packages/platform-intelligence/api/Class.IntelligenceProviderAdapterPort.md +104 -0
  21. package/data/packages/platform-intelligence/api/Class.IntelligenceProviderAssetUploader.md +21 -15
  22. package/data/packages/platform-intelligence/api/Class.IntelligenceProviderDiagnostics.md +55 -0
  23. package/data/packages/platform-intelligence/api/Class.IntelligenceProviderError.md +14 -4
  24. package/data/packages/platform-intelligence/api/Class.IntelligenceProviderRegistry.md +68 -0
  25. package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeError.md +9 -9
  26. package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeMeteringPort.md +1 -1
  27. package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeSessionFactory.md +8 -8
  28. package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeSessionPort.md +18 -18
  29. package/data/packages/platform-intelligence/api/Class.IntelligenceReranker.md +58 -0
  30. package/data/packages/platform-intelligence/api/Class.IntelligenceSpeechGenerator.md +117 -0
  31. package/data/packages/platform-intelligence/api/Class.IntelligenceToolBase.md +14 -16
  32. package/data/packages/platform-intelligence/api/Class.IntelligenceToolRegistry.md +14 -18
  33. package/data/packages/platform-intelligence/api/Class.IntelligenceTranscriptionGenerator.md +139 -0
  34. package/data/packages/platform-intelligence/api/Class.IntelligenceVideoGenerator.md +117 -0
  35. package/data/packages/platform-intelligence/api/Class.MiMoIntelligenceProviderAdapter.md +122 -0
  36. package/data/packages/platform-intelligence/api/Class.OpenAIIntelligenceProviderAdapter.md +122 -0
  37. package/data/packages/platform-intelligence/api/Function.createAnthropicAdvisor20260301Tool.md +1 -1
  38. package/data/packages/platform-intelligence/api/Function.createAnthropicBash20241022Tool.md +1 -1
  39. package/data/packages/platform-intelligence/api/Function.createAnthropicBash20250124Tool.md +1 -1
  40. package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20250522Tool.md +1 -1
  41. package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20250825Tool.md +1 -1
  42. package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20260120Tool.md +1 -1
  43. package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20241022Tool.md +1 -1
  44. package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20250124Tool.md +1 -1
  45. package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20251124Tool.md +1 -1
  46. package/data/packages/platform-intelligence/api/Function.createAnthropicMemory20250818Tool.md +1 -1
  47. package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20241022Tool.md +1 -1
  48. package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250124Tool.md +1 -1
  49. package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250429Tool.md +1 -1
  50. package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250728Tool.md +1 -1
  51. package/data/packages/platform-intelligence/api/Function.createAnthropicToolSearchBM2520251119Tool.md +1 -1
  52. package/data/packages/platform-intelligence/api/Function.createAnthropicToolSearchRegex20251119Tool.md +1 -1
  53. package/data/packages/platform-intelligence/api/Function.createAnthropicWebFetch20250910Tool.md +1 -1
  54. package/data/packages/platform-intelligence/api/Function.createAnthropicWebFetch20260209Tool.md +1 -1
  55. package/data/packages/platform-intelligence/api/Function.createAnthropicWebSearch20250305Tool.md +1 -1
  56. package/data/packages/platform-intelligence/api/Function.createAnthropicWebSearch20260209Tool.md +1 -1
  57. package/data/packages/platform-intelligence/api/Function.createGoogleCodeExecutionTool.md +1 -1
  58. package/data/packages/platform-intelligence/api/Function.createGoogleEnterpriseWebSearchTool.md +1 -1
  59. package/data/packages/platform-intelligence/api/Function.createGoogleFileSearchTool.md +1 -1
  60. package/data/packages/platform-intelligence/api/Function.createGoogleGoogleMapsTool.md +1 -1
  61. package/data/packages/platform-intelligence/api/Function.createGoogleGoogleSearchTool.md +1 -1
  62. package/data/packages/platform-intelligence/api/Function.createGoogleUrlContextTool.md +1 -1
  63. package/data/packages/platform-intelligence/api/Function.createGoogleVertexRagStoreTool.md +1 -1
  64. package/data/packages/platform-intelligence/api/Function.createGrokCodeExecutionTool.md +1 -1
  65. package/data/packages/platform-intelligence/api/Function.createGrokFileSearchTool.md +1 -1
  66. package/data/packages/platform-intelligence/api/Function.createGrokMcpServerTool.md +1 -1
  67. package/data/packages/platform-intelligence/api/Function.createGrokViewImageTool.md +1 -1
  68. package/data/packages/platform-intelligence/api/Function.createGrokViewXVideoTool.md +1 -1
  69. package/data/packages/platform-intelligence/api/Function.createGrokWebSearchTool.md +1 -1
  70. package/data/packages/platform-intelligence/api/Function.createGrokXSearchTool.md +1 -1
  71. package/data/packages/platform-intelligence/api/Function.createIntelligenceJsonSchema.md +31 -0
  72. package/data/packages/platform-intelligence/api/Function.createIntelligenceTool.md +2 -2
  73. package/data/packages/platform-intelligence/api/Function.createMimoCustomTool.md +5 -5
  74. package/data/packages/platform-intelligence/api/Function.createOpenAIApplyPatchTool.md +1 -1
  75. package/data/packages/platform-intelligence/api/Function.createOpenAICodeInterpreterTool.md +1 -1
  76. package/data/packages/platform-intelligence/api/Function.createOpenAICustomTool.md +1 -1
  77. package/data/packages/platform-intelligence/api/Function.createOpenAIFileSearchTool.md +1 -1
  78. package/data/packages/platform-intelligence/api/Function.createOpenAIImageGenerationTool.md +1 -1
  79. package/data/packages/platform-intelligence/api/Function.createOpenAILocalShellTool.md +1 -1
  80. package/data/packages/platform-intelligence/api/Function.createOpenAIMcpTool.md +1 -1
  81. package/data/packages/platform-intelligence/api/Function.createOpenAIShellTool.md +1 -1
  82. package/data/packages/platform-intelligence/api/Function.createOpenAIToolSearchTool.md +1 -1
  83. package/data/packages/platform-intelligence/api/Function.createOpenAIWebSearchPreviewTool.md +1 -1
  84. package/data/packages/platform-intelligence/api/Function.createOpenAIWebSearchTool.md +1 -1
  85. package/data/packages/platform-intelligence/api/Function.defineIntelligenceTool.md +31 -0
  86. package/data/packages/platform-intelligence/api/Interface.IIntelligenceAgentConfiguration.md +70 -0
  87. package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingBatchOptions.md +140 -0
  88. package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingBatchResult.md +70 -0
  89. package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingOptions.md +130 -0
  90. package/data/packages/platform-intelligence/api/Interface.IIntelligenceEmbeddingResult.md +70 -0
  91. package/data/packages/platform-intelligence/api/Interface.IIntelligenceFileUploadOptions.md +118 -0
  92. package/data/packages/platform-intelligence/api/Interface.IIntelligenceFileUploadResult.md +60 -0
  93. package/data/packages/platform-intelligence/api/Interface.IIntelligenceGeneratedFile.md +40 -0
  94. package/data/packages/platform-intelligence/api/Interface.IIntelligenceGenerationStepStartEvent.md +50 -0
  95. package/data/packages/platform-intelligence/api/Interface.IIntelligenceImageGenerationOptions.md +186 -0
  96. package/data/packages/platform-intelligence/api/Interface.IIntelligenceImageGenerationResult.md +60 -0
  97. package/data/packages/platform-intelligence/api/Interface.IIntelligenceLanguageCompletion.md +141 -0
  98. package/data/packages/platform-intelligence/api/Interface.IIntelligenceLanguageGenerationOptions.md +250 -0
  99. package/data/packages/platform-intelligence/api/Interface.IIntelligenceLanguageStream.md +50 -0
  100. package/data/packages/platform-intelligence/api/Interface.IIntelligenceModelReference.md +34 -0
  101. package/data/packages/platform-intelligence/api/Interface.IIntelligenceModelRequestOptions.md +72 -0
  102. package/data/packages/platform-intelligence/api/Interface.IIntelligenceModelStatus.md +30 -0
  103. package/data/packages/platform-intelligence/api/Interface.IIntelligenceModuleOptions.md +54 -26
  104. package/data/packages/platform-intelligence/api/Interface.IIntelligenceObjectStream.md +56 -0
  105. package/data/packages/platform-intelligence/api/Interface.IIntelligencePrompt.md +50 -0
  106. package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptDefinition.md +14 -14
  107. package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptEffectivePolicy.md +1 -1
  108. package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptExecutionPolicy.md +1 -1
  109. package/data/packages/platform-intelligence/api/Interface.IIntelligencePromptExecutionResult.md +15 -27
  110. package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderConfiguration.md +10 -10
  111. package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderLoadRequest.md +54 -0
  112. package/data/packages/platform-intelligence/api/Interface.IIntelligenceProviderProbeResult.md +70 -0
  113. package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeModuleOptions.md +9 -21
  114. package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeSessionOptions.md +23 -11
  115. package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeUsage.md +174 -10
  116. package/data/packages/platform-intelligence/api/Interface.IIntelligenceRequestOptions.md +114 -0
  117. package/data/packages/platform-intelligence/api/Interface.IIntelligenceRerankingOptions.md +156 -0
  118. package/data/packages/platform-intelligence/api/Interface.IIntelligenceRerankingResult.md +50 -0
  119. package/data/packages/platform-intelligence/api/Interface.IIntelligenceSkillUploadOptions.md +110 -0
  120. package/data/packages/platform-intelligence/api/Interface.IIntelligenceSkillUploadResult.md +80 -0
  121. package/data/packages/platform-intelligence/api/Interface.IIntelligenceSpeechGenerationOptions.md +180 -0
  122. package/data/packages/platform-intelligence/api/Interface.IIntelligenceSpeechGenerationResult.md +50 -0
  123. package/data/packages/platform-intelligence/api/Interface.IIntelligenceStreamingTranscriptionOptions.md +155 -0
  124. package/data/packages/platform-intelligence/api/Interface.IIntelligenceTool.md +7 -10
  125. package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolCall.md +40 -0
  126. package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolDefinition.md +91 -0
  127. package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolExecutionEndEvent.md +50 -0
  128. package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolExecutionStartEvent.md +30 -0
  129. package/data/packages/platform-intelligence/api/Interface.IIntelligenceToolRegistry.md +4 -4
  130. package/data/packages/platform-intelligence/api/Interface.IIntelligenceTranscriptionOptions.md +130 -0
  131. package/data/packages/platform-intelligence/api/Interface.IIntelligenceTranscriptionResult.md +84 -0
  132. package/data/packages/platform-intelligence/api/Interface.IIntelligenceTranscriptionStream.md +97 -0
  133. package/data/packages/platform-intelligence/api/Interface.IIntelligenceUsage.md +197 -0
  134. package/data/packages/platform-intelligence/api/Interface.IIntelligenceVideoGenerationOptions.md +245 -0
  135. package/data/packages/platform-intelligence/api/Interface.IIntelligenceVideoGenerationResult.md +50 -0
  136. package/data/packages/platform-intelligence/api/TypeAlias.IIntelligenceModelMessage.md +43 -0
  137. package/data/packages/platform-intelligence/api/TypeAlias.IIntelligencePromptModelRequirement.md +2 -2
  138. package/data/packages/platform-intelligence/api/TypeAlias.IIntelligenceSchema.md +70 -0
  139. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceCapability.md +14 -0
  140. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceDefaultModels.md +14 -0
  141. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceJsonValue.md +22 -0
  142. package/data/packages/platform-intelligence/api/TypeAlias.IntelligencePromptDefinitionConfiguration.md +2 -2
  143. package/data/packages/platform-intelligence/api/TypeAlias.IntelligencePromptGenerationOptions.md +1 -1
  144. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceProviderName.md +1 -1
  145. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceProviderOptions.md +14 -0
  146. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceProviderProbeStatus.md +14 -0
  147. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceProviderToolOptions.md +17 -0
  148. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeMeteringEvent.md +1 -1
  149. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRequestTimeouts.md +14 -0
  150. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceToolChoice.md +21 -0
  151. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceToolOutput.md +22 -0
  152. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceToolSet.md +14 -0
  153. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceTranscriptionStreamPart.md +46 -0
  154. package/data/packages/platform-intelligence/api/Variable.AI_GATEWAY_API_KEY.md +14 -0
  155. package/data/packages/platform-intelligence/api/Variable.AI_GATEWAY_BASE_URL.md +14 -0
  156. package/data/packages/platform-intelligence/api/Variable.AI_GATEWAY_CONFIG_ENTRIES.md +14 -0
  157. package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_API_KEY.md +1 -1
  158. package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_BASE_URL.md +1 -1
  159. package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_MAX_OUTPUT_TOKENS.md +1 -1
  160. package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_MODEL.md +1 -1
  161. package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_PROVIDER.md +2 -2
  162. package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_TEMPERATURE.md +1 -1
  163. package/data/packages/platform-intelligence/api/Variable.INTELLIGENCE_TOP_P.md +1 -1
  164. package/data/packages/platform-intelligence/api/Variable.IntelligenceCapabilityNames.md +40 -0
  165. package/data/packages/platform-intelligence/api/Variable.IntelligenceProviderNames.md +2 -0
  166. package/data/packages/platform-intelligence/api/Variable.PLATFORM_INTELLIGENCE_CONFIG_ENTRIES.md +2 -2
  167. package/data/packages/platform-intelligence/api/index.md +83 -32
  168. package/data/packages/platform-intelligence/index.md +81 -622
  169. package/package.json +1 -1
  170. package/data/packages/index.md +0 -8
  171. package/data/packages/platform-analytics/index.md +0 -209
  172. package/data/packages/platform-authentication/index.md +0 -725
  173. package/data/packages/platform-blob-storage/index.md +0 -416
  174. package/data/packages/platform-bootstrap/index.md +0 -162
  175. package/data/packages/platform-caching/index.md +0 -167
  176. package/data/packages/platform-configuration/index.md +0 -226
  177. package/data/packages/platform-core/index.md +0 -504
  178. package/data/packages/platform-cryptography/index.md +0 -142
  179. package/data/packages/platform-database/index.md +0 -337
  180. package/data/packages/platform-documents/index.md +0 -255
  181. package/data/packages/platform-esigning/index.md +0 -710
  182. package/data/packages/platform-feature-flags/index.md +0 -103
  183. package/data/packages/platform-health/index.md +0 -141
  184. package/data/packages/platform-intelligence/api/Class.IntelligenceMediaGenerator.md +0 -118
  185. package/data/packages/platform-intelligence/api/Class.IntelligenceStructuredGenerator.md +0 -70
  186. package/data/packages/platform-intelligence/api/Class.IntelligenceTelemetryRegistry.md +0 -44
  187. package/data/packages/platform-intelligence/api/Class.IntelligenceTextGenerator.md +0 -138
  188. package/data/packages/platform-intelligence/api/Function.createProviderOptions.md +0 -39
  189. package/data/packages/platform-intelligence/api/Function.loadAnthropicLanguageModel.md +0 -26
  190. package/data/packages/platform-intelligence/api/Function.loadGoogleLanguageModel.md +0 -26
  191. package/data/packages/platform-intelligence/api/Function.loadGoogleRealtimeModel.md +0 -25
  192. package/data/packages/platform-intelligence/api/Function.loadGrokLanguageModel.md +0 -26
  193. package/data/packages/platform-intelligence/api/Function.loadGrokRealtimeModel.md +0 -25
  194. package/data/packages/platform-intelligence/api/Function.loadMimoLanguageModel.md +0 -26
  195. package/data/packages/platform-intelligence/api/Function.loadOpenAILanguageModel.md +0 -26
  196. package/data/packages/platform-intelligence/api/Function.loadOpenAIRealtimeModel.md +0 -25
  197. package/data/packages/platform-intelligence/api/Interface.IIntelligenceCompletionUsage.md +0 -46
  198. package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextCompletion.md +0 -180
  199. package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextGenerationOptions.md +0 -144
  200. package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextGenerator.md +0 -78
  201. package/data/packages/platform-intelligence/api/Interface.IIntelligenceTextStreamingOptions.md +0 -170
  202. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceLanguageModelLoader.md +0 -24
  203. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceLanguageModelLoaders.md +0 -14
  204. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeModelLoader.md +0 -25
  205. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeModelLoaders.md +0 -14
  206. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceTextStream.md +0 -14
  207. package/data/packages/platform-logging/index.md +0 -150
  208. package/data/packages/platform-mailing/index.md +0 -470
  209. package/data/packages/platform-mapping/index.md +0 -123
  210. package/data/packages/platform-mcp/index.md +0 -335
  211. package/data/packages/platform-openapi/index.md +0 -207
  212. package/data/packages/platform-payments/index.md +0 -610
  213. package/data/packages/platform-queue/index.md +0 -192
  214. package/data/packages/platform-reporting/index.md +0 -233
  215. package/data/packages/platform-resources/index.md +0 -137
  216. 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, live audio and text sessions with Vercel AI SDK providers, durable application gateways, metering, and explicit recovery.
4
- order: 27
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
- This guide covers long-lived, bidirectional AI sessions with
10
- `platform-intelligence`: provider registration, live audio forwarding,
11
- normalized events, silent and spoken interaction modes, tools, metering, and
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 sessions are not hour-long uploads. The client and application move
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
- For the reusable ownership and recovery rules behind this integration, see the
20
- [Realtime Session Pattern](../patterns/realtime-session-pattern).
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
- IntelligenceModule,
109
- IntelligenceProviderNames,
110
- } from '@breadstone/archipel-platform-intelligence';
111
- import { loadGoogleRealtimeModel } from '@breadstone/archipel-platform-intelligence/providers/google';
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
- imports: [
118
- IntelligenceModule.register({
119
- // Use false when this module is realtime-only. Applications that also
120
- // register text-generation loaders can retain the default eager check.
121
- validateOnModuleInit: false,
122
- realtime: {
123
- providerLoaders: {
124
- [IntelligenceProviderNames.OpenAI]: loadOpenAIRealtimeModel,
125
- [IntelligenceProviderNames.Google]: loadGoogleRealtimeModel,
126
- [IntelligenceProviderNames.Grok]: loadGrokRealtimeModel,
127
- },
128
- meteringAdapter: ApplicationRealtimeMeteringAdapter,
129
- meteringIntervalMs: 30_000,
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 RealtimeIntelligenceModule {}
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
- `INTELLIGENCE_API_KEY` can provide a global override. Google accepts
149
- `GOOGLE_API_KEY` or `GEMINI_API_KEY`; xAI accepts `GROK_API_KEY` or
150
- `XAI_API_KEY`.
55
+ The package owns all provider runtime dependencies. Applications do not install
56
+ or import provider SDKs.
151
57
 
152
- `validateOnModuleInit` controls eager text-model initialization. It does not
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
- interface IClientAudioChunk {
252
- readonly chunkId: string;
253
- readonly sequence: number;
254
- readonly audio: string;
255
- }
256
- ```
257
-
258
- For each fragment:
259
-
260
- 1. The client writes the fragment to its local durable queue before sending.
261
- 2. The application authenticates the socket and validates the logical session.
262
- 3. The application persists `(sessionId, chunkId, sequence, audio)`
263
- idempotently.
264
- 4. The application calls `session.appendAudio(audio)` immediately after that
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.appendAudio(audioChunk);
294
- await session.commitAudio();
295
- await session.requestResponse();
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 transaction should:
394
-
395
- 1. insert the metering event with a unique constraint on `eventId`;
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
- ## Limits and Backpressure
88
+ ## Tools and Metering
422
89
 
423
- Module-level limits are normalized when `IntelligenceModule.register()` runs:
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
- | Option | Default | Behavior |
426
- | --- | --- | --- |
427
- | `maxActiveSessions` | `1_000` | Maximum upstream sessions per Nest module instance |
428
- | `maxPendingEvents` | `512` | Maximum inbound, outbound, or metering queue depth per session |
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
- Limits apply per process, not across a cluster. Enforce tenant and account
436
- quotas in the application before creating a session. When the client sends
437
- faster than `appendAudio()` can drain, apply backpressure at the client gateway
438
- instead of building another unbounded queue.
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
- ## Production Checklist
108
+ The factory enforces:
490
109
 
491
- - Provider loaders come only from `@ai-sdk/*`-backed Archipel subpaths.
492
- - Provider credentials remain in backend configuration.
493
- - The application authenticates and authorizes every client gateway message.
494
- - Each audio fragment has a logical chunk ID and sequence outside Archipel.
495
- - Client and backend persistence happen per fragment, not after the complete recording.
496
- - Transcript and final response events are persisted before client acknowledgement.
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
- See the [platform-intelligence package page](../packages/platform-intelligence/)
505
- and the [realtime API reference](../packages/platform-intelligence/api/Class.IntelligenceRealtimeSessionFactory)
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.