@breadstone/archipel-mcp 0.0.51 → 0.0.53

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 (98) hide show
  1. package/data/guides/ai-realtime-voice.md +506 -0
  2. package/data/guides/ai-text-generation.md +5 -0
  3. package/data/guides/health-indicators.md +12 -3
  4. package/data/guides/index.md +5 -4
  5. package/data/packages/platform-health/index.md +1 -1
  6. package/data/packages/platform-intelligence/api/Class.IntelligenceAgentFactory.md +5 -5
  7. package/data/packages/platform-intelligence/api/Class.IntelligenceEmbeddingGenerator.md +3 -3
  8. package/data/packages/platform-intelligence/api/Class.IntelligenceHealthIndicator.md +6 -5
  9. package/data/packages/platform-intelligence/api/Class.IntelligenceMediaGenerator.md +5 -5
  10. package/data/packages/platform-intelligence/api/Class.IntelligenceModule.md +2 -2
  11. package/data/packages/platform-intelligence/api/Class.IntelligenceProviderAssetUploader.md +7 -5
  12. package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeError.md +110 -0
  13. package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeMeteringPort.md +47 -0
  14. package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeSessionFactory.md +129 -0
  15. package/data/packages/platform-intelligence/api/Class.IntelligenceRealtimeSessionPort.md +308 -0
  16. package/data/packages/platform-intelligence/api/Class.IntelligenceStructuredGenerator.md +5 -5
  17. package/data/packages/platform-intelligence/api/Class.IntelligenceTelemetryRegistry.md +4 -4
  18. package/data/packages/platform-intelligence/api/Class.IntelligenceTextGenerator.md +8 -8
  19. package/data/packages/platform-intelligence/api/Function.createAnthropicAdvisor20260301Tool.md +3 -3
  20. package/data/packages/platform-intelligence/api/Function.createAnthropicBash20241022Tool.md +3 -3
  21. package/data/packages/platform-intelligence/api/Function.createAnthropicBash20250124Tool.md +3 -3
  22. package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20250522Tool.md +3 -3
  23. package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20250825Tool.md +3 -3
  24. package/data/packages/platform-intelligence/api/Function.createAnthropicCodeExecution20260120Tool.md +3 -3
  25. package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20241022Tool.md +3 -3
  26. package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20250124Tool.md +3 -3
  27. package/data/packages/platform-intelligence/api/Function.createAnthropicComputer20251124Tool.md +3 -3
  28. package/data/packages/platform-intelligence/api/Function.createAnthropicMemory20250818Tool.md +3 -3
  29. package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20241022Tool.md +3 -3
  30. package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250124Tool.md +3 -3
  31. package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250429Tool.md +3 -3
  32. package/data/packages/platform-intelligence/api/Function.createAnthropicTextEditor20250728Tool.md +3 -3
  33. package/data/packages/platform-intelligence/api/Function.createAnthropicToolSearchBM2520251119Tool.md +3 -3
  34. package/data/packages/platform-intelligence/api/Function.createAnthropicToolSearchRegex20251119Tool.md +3 -3
  35. package/data/packages/platform-intelligence/api/Function.createAnthropicWebFetch20250910Tool.md +3 -3
  36. package/data/packages/platform-intelligence/api/Function.createAnthropicWebFetch20260209Tool.md +3 -3
  37. package/data/packages/platform-intelligence/api/Function.createAnthropicWebSearch20250305Tool.md +3 -3
  38. package/data/packages/platform-intelligence/api/Function.createAnthropicWebSearch20260209Tool.md +3 -3
  39. package/data/packages/platform-intelligence/api/Function.createGoogleCodeExecutionTool.md +3 -3
  40. package/data/packages/platform-intelligence/api/Function.createGoogleEnterpriseWebSearchTool.md +3 -3
  41. package/data/packages/platform-intelligence/api/Function.createGoogleFileSearchTool.md +3 -3
  42. package/data/packages/platform-intelligence/api/Function.createGoogleGoogleMapsTool.md +3 -3
  43. package/data/packages/platform-intelligence/api/Function.createGoogleGoogleSearchTool.md +3 -3
  44. package/data/packages/platform-intelligence/api/Function.createGoogleUrlContextTool.md +3 -3
  45. package/data/packages/platform-intelligence/api/Function.createGoogleVertexRagStoreTool.md +3 -3
  46. package/data/packages/platform-intelligence/api/Function.createGrokCodeExecutionTool.md +3 -3
  47. package/data/packages/platform-intelligence/api/Function.createGrokFileSearchTool.md +3 -3
  48. package/data/packages/platform-intelligence/api/Function.createGrokMcpServerTool.md +3 -3
  49. package/data/packages/platform-intelligence/api/Function.createGrokViewImageTool.md +3 -3
  50. package/data/packages/platform-intelligence/api/Function.createGrokViewXVideoTool.md +3 -3
  51. package/data/packages/platform-intelligence/api/Function.createGrokWebSearchTool.md +3 -3
  52. package/data/packages/platform-intelligence/api/Function.createGrokXSearchTool.md +3 -3
  53. package/data/packages/platform-intelligence/api/Function.createMimoCustomTool.md +3 -3
  54. package/data/packages/platform-intelligence/api/Function.createOpenAIApplyPatchTool.md +3 -3
  55. package/data/packages/platform-intelligence/api/Function.createOpenAICodeInterpreterTool.md +3 -3
  56. package/data/packages/platform-intelligence/api/Function.createOpenAICustomTool.md +3 -3
  57. package/data/packages/platform-intelligence/api/Function.createOpenAIFileSearchTool.md +3 -3
  58. package/data/packages/platform-intelligence/api/Function.createOpenAIImageGenerationTool.md +3 -3
  59. package/data/packages/platform-intelligence/api/Function.createOpenAILocalShellTool.md +3 -3
  60. package/data/packages/platform-intelligence/api/Function.createOpenAIMcpTool.md +3 -3
  61. package/data/packages/platform-intelligence/api/Function.createOpenAIShellTool.md +3 -3
  62. package/data/packages/platform-intelligence/api/Function.createOpenAIToolSearchTool.md +3 -3
  63. package/data/packages/platform-intelligence/api/Function.createOpenAIWebSearchPreviewTool.md +3 -3
  64. package/data/packages/platform-intelligence/api/Function.createOpenAIWebSearchTool.md +3 -3
  65. package/data/packages/platform-intelligence/api/Function.loadAnthropicLanguageModel.md +2 -2
  66. package/data/packages/platform-intelligence/api/Function.loadGoogleLanguageModel.md +2 -2
  67. package/data/packages/platform-intelligence/api/Function.loadGoogleRealtimeModel.md +25 -0
  68. package/data/packages/platform-intelligence/api/Function.loadGrokLanguageModel.md +2 -2
  69. package/data/packages/platform-intelligence/api/Function.loadGrokRealtimeModel.md +25 -0
  70. package/data/packages/platform-intelligence/api/Function.loadMimoLanguageModel.md +3 -3
  71. package/data/packages/platform-intelligence/api/Function.loadOpenAILanguageModel.md +2 -2
  72. package/data/packages/platform-intelligence/api/Function.loadOpenAIRealtimeModel.md +25 -0
  73. package/data/packages/platform-intelligence/api/Interface.IIntelligenceModuleOptions.md +20 -7
  74. package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeAudioFormat.md +34 -0
  75. package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeCloseEvent.md +40 -0
  76. package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeModuleOptions.md +120 -0
  77. package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeSessionConfiguration.md +135 -0
  78. package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeSessionOptions.md +148 -0
  79. package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeToolDefinition.md +58 -0
  80. package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeTranscriptionConfiguration.md +46 -0
  81. package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeTurnDetectionConfiguration.md +58 -0
  82. package/data/packages/platform-intelligence/api/Interface.IIntelligenceRealtimeUsage.md +103 -0
  83. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceLanguageModelLoader.md +2 -2
  84. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeClientEvent.md +64 -0
  85. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeMetadataValue.md +14 -0
  86. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeMeteringEvent.md +44 -0
  87. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeModelLoader.md +25 -0
  88. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeModelLoaders.md +14 -0
  89. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeServerEvent.md +159 -0
  90. package/data/packages/platform-intelligence/api/TypeAlias.IntelligenceRealtimeStatus.md +14 -0
  91. package/data/packages/platform-intelligence/api/Variable.MIMO_API_KEY.md +1 -1
  92. package/data/packages/platform-intelligence/api/Variable.MIMO_BASE_URL.md +1 -1
  93. package/data/packages/platform-intelligence/api/Variable.MIMO_CONFIG_ENTRIES.md +1 -1
  94. package/data/packages/platform-intelligence/api/index.md +23 -0
  95. package/data/packages/platform-intelligence/index.md +133 -7
  96. package/data/patterns/index.md +1 -0
  97. package/data/patterns/realtime-session-pattern.md +309 -0
  98. package/package.json +1 -1
@@ -0,0 +1,14 @@
1
+ ---
2
+ title: 'Type Alias: IntelligenceRealtimeModelLoaders'
3
+ generated: true
4
+ editUrl: false
5
+ ---
6
+ # Type Alias: IntelligenceRealtimeModelLoaders
7
+
8
+ ```ts
9
+ type IntelligenceRealtimeModelLoaders = Partial<Record<IntelligenceProviderName, IntelligenceRealtimeModelLoader>>;
10
+ ```
11
+
12
+ Defined in: providers/IntelligenceRealtimeModelLoaders.ts:13
13
+
14
+ Maps configured intelligence providers to tree-shakable realtime model loaders.
@@ -0,0 +1,159 @@
1
+ ---
2
+ title: 'Type Alias: IntelligenceRealtimeServerEvent'
3
+ generated: true
4
+ editUrl: false
5
+ ---
6
+ # Type Alias: IntelligenceRealtimeServerEvent
7
+
8
+ ```ts
9
+ type IntelligenceRealtimeServerEvent =
10
+ | {
11
+ raw: unknown;
12
+ sessionId?: string;
13
+ type: "session-created";
14
+ }
15
+ | {
16
+ raw: unknown;
17
+ type: "session-updated";
18
+ }
19
+ | {
20
+ itemId?: string;
21
+ raw: unknown;
22
+ type: "speech-started";
23
+ }
24
+ | {
25
+ itemId?: string;
26
+ raw: unknown;
27
+ type: "speech-stopped";
28
+ }
29
+ | {
30
+ itemId?: string;
31
+ previousItemId?: string;
32
+ raw: unknown;
33
+ type: "audio-committed";
34
+ }
35
+ | {
36
+ item: unknown;
37
+ itemId: string;
38
+ raw: unknown;
39
+ type: "conversation-item-added";
40
+ }
41
+ | {
42
+ itemId: string;
43
+ raw: unknown;
44
+ transcript: string;
45
+ type: "input-transcription-completed";
46
+ }
47
+ | {
48
+ raw: unknown;
49
+ responseId: string;
50
+ type: "response-created";
51
+ }
52
+ | {
53
+ raw: unknown;
54
+ responseId: string;
55
+ status: string;
56
+ type: "response-done";
57
+ }
58
+ | {
59
+ itemId: string;
60
+ raw: unknown;
61
+ responseId: string;
62
+ type: "output-item-added";
63
+ }
64
+ | {
65
+ itemId: string;
66
+ raw: unknown;
67
+ responseId: string;
68
+ type: "output-item-done";
69
+ }
70
+ | {
71
+ itemId: string;
72
+ raw: unknown;
73
+ responseId: string;
74
+ type: "content-part-added";
75
+ }
76
+ | {
77
+ itemId: string;
78
+ raw: unknown;
79
+ responseId: string;
80
+ type: "content-part-done";
81
+ }
82
+ | {
83
+ delta: string;
84
+ itemId: string;
85
+ raw: unknown;
86
+ responseId: string;
87
+ type: "audio-delta";
88
+ }
89
+ | {
90
+ itemId: string;
91
+ raw: unknown;
92
+ responseId: string;
93
+ type: "audio-done";
94
+ }
95
+ | {
96
+ delta: string;
97
+ itemId: string;
98
+ raw: unknown;
99
+ responseId: string;
100
+ type: "audio-transcript-delta";
101
+ }
102
+ | {
103
+ itemId: string;
104
+ raw: unknown;
105
+ responseId: string;
106
+ transcript?: string;
107
+ type: "audio-transcript-done";
108
+ }
109
+ | {
110
+ delta: string;
111
+ itemId: string;
112
+ raw: unknown;
113
+ responseId: string;
114
+ type: "text-delta";
115
+ }
116
+ | {
117
+ itemId: string;
118
+ raw: unknown;
119
+ responseId: string;
120
+ text?: string;
121
+ type: "text-done";
122
+ }
123
+ | {
124
+ callId: string;
125
+ delta: string;
126
+ itemId: string;
127
+ raw: unknown;
128
+ responseId: string;
129
+ type: "function-call-arguments-delta";
130
+ }
131
+ | {
132
+ arguments: string;
133
+ callId: string;
134
+ itemId: string;
135
+ name: string;
136
+ raw: unknown;
137
+ responseId: string;
138
+ type: "function-call-arguments-done";
139
+ }
140
+ | {
141
+ code?: string;
142
+ message: string;
143
+ raw: unknown;
144
+ type: "error";
145
+ }
146
+ | {
147
+ raw: unknown;
148
+ rawType: string;
149
+ type: "custom";
150
+ };
151
+ ```
152
+
153
+ Defined in: realtime/contracts/IntelligenceRealtimeServerEvent.ts:10
154
+
155
+ Provider-neutral event emitted by a realtime model.
156
+
157
+ The original provider event remains available through `raw` for audited
158
+ provider-specific diagnostics without leaking provider contracts into the
159
+ normal application flow.
@@ -0,0 +1,14 @@
1
+ ---
2
+ title: 'Type Alias: IntelligenceRealtimeStatus'
3
+ generated: true
4
+ editUrl: false
5
+ ---
6
+ # Type Alias: IntelligenceRealtimeStatus
7
+
8
+ ```ts
9
+ type IntelligenceRealtimeStatus = "idle" | "connecting" | "connected" | "closing" | "closed" | "error";
10
+ ```
11
+
12
+ Defined in: realtime/contracts/IntelligenceRealtimeStatus.ts:6
13
+
14
+ Describes the lifecycle state of an upstream realtime model connection.
@@ -9,6 +9,6 @@ editUrl: false
9
9
  const MIMO_API_KEY: IConfigKey<string>;
10
10
  ```
11
11
 
12
- Defined in: providers/mimo/env.ts:10
12
+ Defined in: [providers/mimo/env.ts:10](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-intelligence/src/providers/mimo/env.ts#L10)
13
13
 
14
14
  MiMo-specific API key.
@@ -9,6 +9,6 @@ editUrl: false
9
9
  const MIMO_BASE_URL: IConfigKey<string>;
10
10
  ```
11
11
 
12
- Defined in: providers/mimo/env.ts:13
12
+ Defined in: [providers/mimo/env.ts:13](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-intelligence/src/providers/mimo/env.ts#L13)
13
13
 
14
14
  MiMo-specific base URL.
@@ -9,6 +9,6 @@ editUrl: false
9
9
  const MIMO_CONFIG_ENTRIES: ReadonlyArray<Omit<IConfigRegistryEntry, "module">>;
10
10
  ```
11
11
 
12
- Defined in: providers/mimo/env.ts:16
12
+ Defined in: [providers/mimo/env.ts:16](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-intelligence/src/providers/mimo/env.ts#L16)
13
13
 
14
14
  Configuration entries used by the MiMo intelligence provider.
@@ -17,6 +17,10 @@ editUrl: false
17
17
  | [IntelligenceModule](Class.IntelligenceModule) | Core module exposing the shared intelligence infrastructure. |
18
18
  | [IntelligenceProviderAssetUploader](Class.IntelligenceProviderAssetUploader) | Uploads provider-managed files and skills for reuse in AI SDK calls. |
19
19
  | [IntelligenceProviderError](Class.IntelligenceProviderError) | Error thrown when an intelligence provider call fails. |
20
+ | [IntelligenceRealtimeError](Class.IntelligenceRealtimeError) | Error raised by a realtime session, transport, or metering adapter. |
21
+ | [IntelligenceRealtimeMeteringPort](Class.IntelligenceRealtimeMeteringPort) | Application port for idempotently persisting realtime billing and audit events. |
22
+ | [IntelligenceRealtimeSessionFactory](Class.IntelligenceRealtimeSessionFactory) | Creates and owns server-side, provider-neutral realtime AI sessions. |
23
+ | [IntelligenceRealtimeSessionPort](Class.IntelligenceRealtimeSessionPort) | Provider-neutral control surface for one realtime model connection. |
20
24
  | [IntelligenceStructuredGenerator](Class.IntelligenceStructuredGenerator) | Executes AI SDK structured-output generation. |
21
25
  | [IntelligenceTelemetryRegistry](Class.IntelligenceTelemetryRegistry) | Registers AI SDK telemetry integrations for the current process. |
22
26
  | [IntelligenceTextGenerator](Class.IntelligenceTextGenerator) | Executes text completions using the configured intelligence provider. |
@@ -31,6 +35,15 @@ editUrl: false
31
35
  | [IIntelligenceCompletionUsage](Interface.IIntelligenceCompletionUsage) | Captures usage telemetry returned by the intelligence provider. |
32
36
  | [IIntelligenceModuleOptions](Interface.IIntelligenceModuleOptions) | Options for configuring the intelligence module. |
33
37
  | [IIntelligenceProviderConfiguration](Interface.IIntelligenceProviderConfiguration) | Describes the resolved configuration for the intelligence provider. |
38
+ | [IIntelligenceRealtimeAudioFormat](Interface.IIntelligenceRealtimeAudioFormat) | Provider-neutral audio format configuration. |
39
+ | [IIntelligenceRealtimeCloseEvent](Interface.IIntelligenceRealtimeCloseEvent) | Describes why an upstream realtime connection closed. |
40
+ | [IIntelligenceRealtimeModuleOptions](Interface.IIntelligenceRealtimeModuleOptions) | Module-level resilience and resource limits for realtime intelligence. |
41
+ | [IIntelligenceRealtimeSessionConfiguration](Interface.IIntelligenceRealtimeSessionConfiguration) | Provider-neutral configuration for a realtime AI session. |
42
+ | [IIntelligenceRealtimeSessionOptions](Interface.IIntelligenceRealtimeSessionOptions) | Options used to create one server-owned realtime model connection. |
43
+ | [IIntelligenceRealtimeToolDefinition](Interface.IIntelligenceRealtimeToolDefinition) | Provider-neutral function definition exposed to a realtime model. |
44
+ | [IIntelligenceRealtimeTranscriptionConfiguration](Interface.IIntelligenceRealtimeTranscriptionConfiguration) | Provider-neutral transcription configuration. |
45
+ | [IIntelligenceRealtimeTurnDetectionConfiguration](Interface.IIntelligenceRealtimeTurnDetectionConfiguration) | Provider-neutral voice activity detection configuration. |
46
+ | [IIntelligenceRealtimeUsage](Interface.IIntelligenceRealtimeUsage) | Normalized token usage reported by a realtime provider. |
34
47
  | [IIntelligenceTextCompletion](Interface.IIntelligenceTextCompletion) | Represents the normalized completion result produced by the intelligence provider. |
35
48
  | [IIntelligenceTextGenerationOptions](Interface.IIntelligenceTextGenerationOptions) | Options that can be supplied when generating text with the intelligence provider. |
36
49
  | [IIntelligenceTextGenerator](Interface.IIntelligenceTextGenerator) | Abstraction responsible for executing text completions using the configured provider. |
@@ -45,6 +58,13 @@ editUrl: false
45
58
  | [IntelligenceLanguageModelLoader](TypeAlias.IntelligenceLanguageModelLoader) | Represents a factory responsible for creating a configured language model instance. |
46
59
  | [IntelligenceLanguageModelLoaders](TypeAlias.IntelligenceLanguageModelLoaders) | Maps configured intelligence providers to their tree-shakable model loader. |
47
60
  | [IntelligenceProviderName](TypeAlias.IntelligenceProviderName) | Represents the union of supported intelligence provider identifiers. |
61
+ | [IntelligenceRealtimeClientEvent](TypeAlias.IntelligenceRealtimeClientEvent) | Provider-neutral event sent from an application to a realtime model. |
62
+ | [IntelligenceRealtimeMetadataValue](TypeAlias.IntelligenceRealtimeMetadataValue) | Serializable metadata copied into realtime metering events. |
63
+ | [IntelligenceRealtimeMeteringEvent](TypeAlias.IntelligenceRealtimeMeteringEvent) | Durable metering event emitted by an Archipel realtime session. |
64
+ | [IntelligenceRealtimeModelLoader](TypeAlias.IntelligenceRealtimeModelLoader) | Creates a configured Vercel AI SDK realtime model behind the Archipel facade. |
65
+ | [IntelligenceRealtimeModelLoaders](TypeAlias.IntelligenceRealtimeModelLoaders) | Maps configured intelligence providers to tree-shakable realtime model loaders. |
66
+ | [IntelligenceRealtimeServerEvent](TypeAlias.IntelligenceRealtimeServerEvent) | Provider-neutral event emitted by a realtime model. |
67
+ | [IntelligenceRealtimeStatus](TypeAlias.IntelligenceRealtimeStatus) | Describes the lifecycle state of an upstream realtime model connection. |
48
68
  | [IntelligenceTextStream](TypeAlias.IntelligenceTextStream) | Native AI SDK streaming result returned by the intelligence text generator. |
49
69
 
50
70
  ## Variables
@@ -137,6 +157,9 @@ editUrl: false
137
157
  | [createProviderOptions](Function.createProviderOptions) | Creates the provider options object consumed by the AI SDK model factories. |
138
158
  | [loadAnthropicLanguageModel](Function.loadAnthropicLanguageModel) | Creates the Anthropic language model from the resolved provider configuration. |
139
159
  | [loadGoogleLanguageModel](Function.loadGoogleLanguageModel) | Creates the Google Gemini language model from the resolved provider configuration. |
160
+ | [loadGoogleRealtimeModel](Function.loadGoogleRealtimeModel) | Creates a Google Gemini Live model exclusively through the Vercel AI SDK provider. |
140
161
  | [loadGrokLanguageModel](Function.loadGrokLanguageModel) | Creates the Grok language model through the native xAI provider. |
162
+ | [loadGrokRealtimeModel](Function.loadGrokRealtimeModel) | Creates an xAI Grok voice model exclusively through the Vercel AI SDK provider. |
141
163
  | [loadMimoLanguageModel](Function.loadMimoLanguageModel) | Creates the Xiaomi MiMo language model from the resolved provider configuration. |
142
164
  | [loadOpenAILanguageModel](Function.loadOpenAILanguageModel) | Creates the OpenAI language model from the resolved provider configuration. |
165
+ | [loadOpenAIRealtimeModel](Function.loadOpenAIRealtimeModel) | Creates an OpenAI realtime model exclusively through the Vercel AI SDK provider. |
@@ -1,14 +1,14 @@
1
1
  ---
2
2
  title: platform-intelligence
3
- description: Multi-provider AI text generation, streaming, and tool calling.
3
+ description: Multi-provider AI text generation, streaming, realtime voice, metering, and tool calling.
4
4
  order: 16
5
- tags: [intelligence, ai, openai, anthropic, google, grok, text-generation, streaming, tool-calling, health]
5
+ tags: [intelligence, ai, openai, anthropic, google, grok, text-generation, streaming, realtime, voice, metering, tool-calling, health]
6
6
  package: '@breadstone/archipel-platform-intelligence'
7
7
  ---
8
8
 
9
9
  # platform-intelligence
10
10
 
11
- Multi-provider AI text generation library supporting OpenAI, Anthropic, Google Generative AI, and Grok. Tool orchestration is delegated to the AI SDK through native and provider-defined tool definitions, `toolChoice`, `activeTools`, and `stopWhen`. Advanced use cases can pass native AI SDK prompts, request-level models, provider options, headers, telemetry, output settings, and step hooks through the platform generator.
11
+ Multi-provider AI library supporting text generation and server-owned realtime voice sessions through OpenAI, Anthropic, Google Generative AI, and Grok. Tool orchestration is delegated to the AI SDK through native and provider-defined tool definitions, `toolChoice`, `activeTools`, and `stopWhen`. Advanced use cases can pass native AI SDK prompts, request-level models, provider options, headers, telemetry, output settings, and step hooks through the platform generator.
12
12
 
13
13
  **Package:** `@breadstone/archipel-platform-intelligence`
14
14
 
@@ -35,6 +35,126 @@ export class AppModule {}
35
35
 
36
36
  ---
37
37
 
38
+ ## Realtime Voice
39
+
40
+ Archipel owns the upstream provider WebSocket and exposes normalized audio,
41
+ text, transcription, response, and tool events through
42
+ `IntelligenceRealtimeSessionPort`. The consuming backend can place its normal
43
+ authentication, authorization, tenant isolation, persistence, and client
44
+ WebSocket in front of this port. Provider credentials and short-lived tokens
45
+ never need to reach the browser.
46
+
47
+ The complete application integration is documented in
48
+ [AI Realtime Voice](/guides/ai-realtime-voice); the reusable ownership,
49
+ durability, and recovery rules are documented in the
50
+ [Realtime Session Pattern](/patterns/realtime-session-pattern).
51
+
52
+ The implementation uses the experimental realtime model contract in Vercel AI
53
+ SDK 7. OpenAI, Google, and xAI are loaded through Archipel provider subpaths;
54
+ consuming applications do not import the official OpenAI SDK or make direct
55
+ provider calls.
56
+
57
+ ```typescript
58
+ import { Injectable, Module } from '@nestjs/common';
59
+ import {
60
+ IntelligenceModule,
61
+ IntelligenceProviderNames,
62
+ } from '@breadstone/archipel-platform-intelligence';
63
+ import {
64
+ IntelligenceRealtimeMeteringPort,
65
+ IntelligenceRealtimeSessionFactory,
66
+ type IntelligenceRealtimeMeteringEvent,
67
+ } from '@breadstone/archipel-platform-intelligence/realtime';
68
+ import { loadOpenAIRealtimeModel } from '@breadstone/archipel-platform-intelligence/providers/openai';
69
+ import { loadGoogleRealtimeModel } from '@breadstone/archipel-platform-intelligence/providers/google';
70
+ import { loadGrokRealtimeModel } from '@breadstone/archipel-platform-intelligence/providers/grok';
71
+
72
+ @Injectable()
73
+ export class RealtimeMeteringAdapter extends IntelligenceRealtimeMeteringPort {
74
+ public async report(event: IntelligenceRealtimeMeteringEvent): Promise<void> {
75
+ await persistIdempotently(event.eventId, event);
76
+ }
77
+ }
78
+
79
+ @Module({
80
+ imports: [
81
+ IntelligenceModule.register({
82
+ validateOnModuleInit: false,
83
+ realtime: {
84
+ providerLoaders: {
85
+ [IntelligenceProviderNames.OpenAI]: loadOpenAIRealtimeModel,
86
+ [IntelligenceProviderNames.Google]: loadGoogleRealtimeModel,
87
+ [IntelligenceProviderNames.Grok]: loadGrokRealtimeModel,
88
+ },
89
+ meteringAdapter: RealtimeMeteringAdapter,
90
+ meteringIntervalMs: 30_000,
91
+ },
92
+ }),
93
+ ],
94
+ })
95
+ export class RealtimeModule {}
96
+
97
+ @Injectable()
98
+ export class RealtimeConsultationService {
99
+ public constructor(private readonly sessions: IntelligenceRealtimeSessionFactory) {}
100
+
101
+ public async open(consultationId: string): Promise<void> {
102
+ const session = await this.sessions.createSession({
103
+ sessionId: consultationId,
104
+ model: 'gpt-realtime',
105
+ sessionConfiguration: {
106
+ instructions: 'Transcribe the consultation and answer concisely.',
107
+ inputAudioFormat: { type: 'audio/pcm', rate: 24_000 },
108
+ inputAudioTranscription: {},
109
+ outputModalities: ['text', 'audio'],
110
+ turnDetection: { type: 'server-vad' },
111
+ },
112
+ onEvent: forwardToAuthenticatedClient,
113
+ });
114
+
115
+ await session.connect();
116
+ }
117
+ }
118
+ ```
119
+
120
+ | Provider | Archipel loader | Example model |
121
+ | --- | --- | --- |
122
+ | OpenAI | `loadOpenAIRealtimeModel` | `gpt-realtime` |
123
+ | Google | `loadGoogleRealtimeModel` | `gemini-3.1-flash-live-preview` |
124
+ | xAI / Grok | `loadGrokRealtimeModel` | `grok-voice-latest` |
125
+
126
+ ### Metering and audit
127
+
128
+ The application-supplied `IntelligenceRealtimeMeteringPort` receives four
129
+ idempotently identifiable event types:
130
+
131
+ | Event | Meaning |
132
+ | --- | --- |
133
+ | `session-started` | One upstream provider connection opened |
134
+ | `billing-interval` | Elapsed provider-independent usage, every 30 seconds by default and once more for the final partial interval |
135
+ | `provider-usage` | Exact token and modality counts when present in the raw provider event |
136
+ | `session-ended` | Connection duration and close reason |
137
+
138
+ An application can debit its own token ledger and append its AI audit log in
139
+ the same transaction keyed by `eventId`. Time-based charging remains available
140
+ when a provider omits exact usage; exact token usage remains available for cost
141
+ reconciliation when reported.
142
+
143
+ ### Failure and persistence rules
144
+
145
+ - Provider token requests and WebSocket setup are capped at five seconds and
146
+ transient token creation is retried at most twice.
147
+ - Inbound, outbound, metering, and WebSocket buffers are bounded.
148
+ - Normalized events preserve provider wire order.
149
+ - Nest shutdown closes all owned sessions and flushes metering.
150
+ - Archipel does not silently reconnect a lost provider conversation because a
151
+ new connection has different conversational state.
152
+ - The consuming application must persist audio chunks and transcript progress
153
+ durably before acknowledging them, then reconstruct context when it opens a
154
+ replacement provider session.
155
+
156
+ ---
157
+
38
158
  ## Provider Subpaths
39
159
 
40
160
  Import only the providers you need:
@@ -359,11 +479,12 @@ All errors are wrapped in `IntelligenceProviderError` with `provider`, `model`,
359
479
 
360
480
  ## Error Handling
361
481
 
362
- The library provides three domain error classes for different failure scenarios:
482
+ The library provides domain error classes for different failure scenarios:
363
483
 
364
484
  | Error class | Code | When thrown |
365
485
  | ---------------------------------- | ----------------------------- | --------------------------------------------------------------------- |
366
486
  | `IntelligenceProviderError` | `INTELLIGENCE_PROVIDER` | Provider SDK failures during text generation |
487
+ | `IntelligenceRealtimeError` | Realtime phase metadata | Configuration, token, connect, send, receive, metering, or close failures |
367
488
  | `IntelligenceValidationError` | `INTELLIGENCE_VALIDATION` | Invalid generation parameters (temperature, topP, maxOutputTokens) |
368
489
  | `IntelligenceConfigurationError` | `INTELLIGENCE_CONFIGURATION` | Unsupported provider, missing API key, or missing provider loader |
369
490
 
@@ -379,7 +500,12 @@ import {
379
500
 
380
501
  ## Lifecycle
381
502
 
382
- `IntelligenceTextGenerator` implements `OnModuleInit` and validates the provider configuration plus registered provider loader eagerly at startup. Missing API keys, unsupported providers, or missing loaders throw `IntelligenceConfigurationError` before the first request is processed.
503
+ `IntelligenceTextGenerator` implements `OnModuleInit` and validates the provider configuration plus registered provider loader eagerly at startup. Missing API keys, unsupported providers, or missing loaders throw `IntelligenceConfigurationError` before the first request is processed. `IntelligenceRealtimeSessionFactory` implements `OnModuleDestroy`, closes all owned provider WebSockets, and flushes queued metering on shutdown.
504
+
505
+ Set `validateOnModuleInit: false` for a realtime-only module because that option
506
+ controls eager text-model initialization. When text and realtime are both
507
+ used, register the language-model loaders and keep the default eager
508
+ validation.
383
509
 
384
510
  ---
385
511
 
@@ -391,7 +517,7 @@ import {
391
517
 
392
518
  ## Health Check
393
519
 
394
- The `IntelligenceHealthIndicator` verifies that provider configuration can be resolved. If no text generator is available, it reports `disabled: true`. Import it from the `/health` subpath:
520
+ The `IntelligenceHealthIndicator` verifies that provider configuration can be resolved and reports registered realtime providers plus active session count. If neither text nor realtime infrastructure is available, it reports `disabled: true`. Import it from the `/health` subpath:
395
521
 
396
522
  ```typescript
397
523
  import { IntelligenceModule, IntelligenceProviderNames } from '@breadstone/archipel-platform-intelligence';
@@ -414,7 +540,7 @@ export class AppModule {}
414
540
 
415
541
  | Key | Check | Dependencies |
416
542
  | --- | ----- | ------------ |
417
- | `intelligence` | `up` when provider configuration resolves, else `down` | `@Optional() IntelligenceTextGenerator` |
543
+ | `intelligence` | `up` when provider configuration resolves, else `down`; includes realtime readiness when registered | `@Optional() IntelligenceTextGenerator`, `@Optional() IntelligenceRealtimeSessionFactory` |
418
544
 
419
545
  ---
420
546
 
@@ -19,3 +19,4 @@ These patterns document repeatable implementation shapes used across Archipel. U
19
19
  | [Repository Pattern](./repository-pattern) | `RepositoryBase` subclasses and Prisma delegate isolation. |
20
20
  | [Testing Pattern](./testing-pattern) | Vitest structure, mocks, and integration test conventions. |
21
21
  | [Bootstrap Pattern](./bootstrap-pattern) | Composable NestJS startup with `PlatformApplication` and `PlatformBootstrapStep`. |
22
+ | [Realtime Session Pattern](./realtime-session-pattern) | Long-lived connection ownership, per-fragment durability, metering, backpressure, and recovery. |