@crossworks/voice-client 0.400.31 → 0.400.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossworks/voice-client",
3
- "version": "0.400.31",
3
+ "version": "0.400.35",
4
4
  "description": "Browser-safe surface of the voice/model layer — provider catalogue, model catalogs, audio tags, and the adapter type/metadata contract. Zero deps by design: nothing here may reach the network adapters or node builtins (the jackdaw-repo-split P0 boundary).",
5
5
  "type": "module",
6
6
  "exports": {
@@ -56,6 +56,7 @@ export const WIRED_PROVIDERS: Record<WiredCapability, ReadonlySet<ProviderId>> =
56
56
  'huggingface',
57
57
  'deepseek',
58
58
  'mammouth',
59
+ 'foundry',
59
60
  'copilot',
60
61
  'custom',
61
62
  'local',
@@ -547,6 +547,12 @@ export interface ChatDispatcher extends AdapterMeta {
547
547
  /** Adapters expose their static catalog for the UI to render before
548
548
  * discovery completes (or when discovery isn't supported). */
549
549
  staticCatalog?(): readonly ChatModelInfo[];
550
+ /** Optional. A box-level credential from the environment, for a route with
551
+ * no vault key (Microsoft Foundry's MANTLE_FOUNDRY_API_KEY). `baseUrl` is
552
+ * the route's own host: an adapter returns null when it is set, so an
553
+ * environment key only ever goes to the environment's endpoint. Read by
554
+ * the one chat key resolver (@mantle/runtime chat-failover resolveChatKey). */
555
+ envCredential?(baseUrl: string | null): ProviderCredential | null;
550
556
  }
551
557
 
552
558
  export interface SttDispatcher extends AdapterMeta {
@@ -931,6 +937,12 @@ export type DecisionAnswer =
931
937
  }
932
938
  | { type: 'noul'; probability: number };
933
939
 
940
+ /** The decider's privacy level. `zdr`: zero-data-retention routing and no
941
+ * data collection (the default). `no_training`: no data collection only, for
942
+ * a model with no zero-retention route. An adapter never loosens it by
943
+ * itself after a failure: an admin chooses `no_training`. */
944
+ export type DecisionPrivacy = 'zdr' | 'no_training';
945
+
934
946
  export interface DecisionOptions {
935
947
  apiKey: string;
936
948
  model: string;
@@ -938,9 +950,9 @@ export interface DecisionOptions {
938
950
  * name the questions can point at) or an array. Text only. */
939
951
  state: unknown;
940
952
  questions: Record<string, DecisionQuestion>;
941
- /** Ask the provider for zero-data-retention routing and no data
942
- * collection. The state can hold the owner's documents. */
943
- zeroDataRetention?: boolean;
953
+ /** What the provider may do with the state, which can hold the owner's
954
+ * documents. Unset = `zdr`. */
955
+ privacy?: DecisionPrivacy;
944
956
  /** Hard ceiling; the adapter aborts and throws past it. */
945
957
  timeoutMs?: number;
946
958
  }
@@ -0,0 +1,199 @@
1
+ /**
2
+ * Microsoft Foundry (Azure AI Foundry, Azure OpenAI) static catalog and
3
+ * endpoint rules. docs/foundry.md has the API as checked against Microsoft
4
+ * Learn and the v1 OpenAPI file.
5
+ *
6
+ * Pure data and pure functions: this contract package has no dependencies,
7
+ * so the env reads (MANTLE_FOUNDRY_*) live in the adapter
8
+ * (`@mantle/voice` adapters/foundry-chat.ts), which passes the values in.
9
+ *
10
+ * Model ids are DEPLOYMENT names. The owner names each deployment in the
11
+ * Foundry portal; the portal suggests the model id, so the seed below lists
12
+ * model ids as the likely deployment names. Any other name the owner types
13
+ * works the same. No prices: Foundry bills by deployment type (Global, Data
14
+ * Zone, Regional) and region, and the API answers with no cost, so a seed
15
+ * price would be a guess. No context windows for the same reason a
16
+ * deployment can be set below the model's own.
17
+ */
18
+
19
+ import type { ChatModelInfo } from '../adapters/types';
20
+
21
+ /** The path the v1 API lives under, on either host form. */
22
+ export const FOUNDRY_V1_PATH = '/openai/v1';
23
+
24
+ /** The oldest date version the adapter speaks to (`stream_options` and
25
+ * `max_completion_tokens` arrived in 2024-09-01-preview). */
26
+ export const FOUNDRY_OLDEST_DATED = '2024-09-01';
27
+
28
+ /** The API version the v1 route needs no query for. */
29
+ export const FOUNDRY_DEFAULT_API_VERSION = 'v1';
30
+
31
+ /** How an endpoint or API version can be wrong, in fixed words. Never echoes
32
+ * the value: an endpoint a login typed is not ours to repeat in a log. */
33
+ export const FOUNDRY_ENDPOINT_PROBLEM =
34
+ 'Microsoft Foundry needs an endpoint: set the route Base URL or MANTLE_FOUNDRY_ENDPOINT to the resource URL (https://<resource>.openai.azure.com or https://<resource>.services.ai.azure.com).';
35
+ export const FOUNDRY_ENDPOINT_INVALID =
36
+ 'The Microsoft Foundry endpoint is not a plain https URL (no user, query or fragment). Use the resource URL, e.g. https://<resource>.openai.azure.com.';
37
+ export const FOUNDRY_API_VERSION_INVALID =
38
+ "MANTLE_FOUNDRY_API_VERSION must be 'v1', 'preview' or a date version from 2024-09-01 on, such as 2024-10-21 or 2025-04-01-preview.";
39
+
40
+ /** A parsed MANTLE_FOUNDRY_API_VERSION. `v1` and `preview` use the v1 route;
41
+ * a date version uses the older per-deployment route. */
42
+ export type FoundryApiVersion =
43
+ { kind: 'v1'; query: null } | { kind: 'v1'; query: 'preview' } | { kind: 'dated'; query: string };
44
+
45
+ /**
46
+ * Parse an API version. Blank or unset is `v1`. Returns null for anything
47
+ * else that is not `v1`, `preview` or `YYYY-MM-DD` (from
48
+ * FOUNDRY_OLDEST_DATED on) with an optional `-preview`, so a stray value can
49
+ * never reach the URL.
50
+ */
51
+ export function parseFoundryApiVersion(raw: string | null | undefined): FoundryApiVersion | null {
52
+ const v = (raw ?? '').trim();
53
+ if (!v || v === FOUNDRY_DEFAULT_API_VERSION) return { kind: 'v1', query: null };
54
+ if (v === 'preview') return { kind: 'v1', query: 'preview' };
55
+ // Date versions from 2024-09-01 on: older ones refuse `stream_options`,
56
+ // which every stream sends, and `max_completion_tokens`.
57
+ if (/^\d{4}-\d{2}-\d{2}(?:-preview)?$/.test(v) && v.slice(0, 10) >= FOUNDRY_OLDEST_DATED) {
58
+ return { kind: 'dated', query: v };
59
+ }
60
+ return null;
61
+ }
62
+
63
+ /**
64
+ * The resource root of an endpoint: `https://host[/gateway-path]` with any
65
+ * trailing `/openai/v1` or `/openai` (and slashes) taken off, so the owner
66
+ * can paste the root or the v1 base URL the portal shows. Null when it is
67
+ * not an https URL, or carries a user, a query or a fragment (a key in a
68
+ * URL would end up in logs). A path other than the openai suffix stays: an
69
+ * API Management gateway fronts the resource under its own prefix.
70
+ */
71
+ export function foundryResourceRoot(endpoint: string | null | undefined): string | null {
72
+ const raw = (endpoint ?? '').trim();
73
+ if (!raw) return null;
74
+ let url: URL;
75
+ try {
76
+ url = new URL(raw);
77
+ } catch {
78
+ return null;
79
+ }
80
+ if (url.protocol !== 'https:') return null;
81
+ if (url.username || url.password || url.search || url.hash) return null;
82
+ const path = url.pathname
83
+ .replace(/\/+$/, '')
84
+ .replace(/\/openai(?:\/v1)?$/i, '')
85
+ .replace(/\/+$/, '');
86
+ return `${url.origin}${path}`;
87
+ }
88
+
89
+ /** The chat completions URL for a deployment. */
90
+ export function foundryChatUrl(
91
+ root: string,
92
+ deployment: string,
93
+ version: FoundryApiVersion,
94
+ ): string {
95
+ if (version.kind === 'dated') {
96
+ return `${root}/openai/deployments/${encodeURIComponent(deployment)}/chat/completions?api-version=${version.query}`;
97
+ }
98
+ const q = version.query ? `?api-version=${version.query}` : '';
99
+ return `${root}${FOUNDRY_V1_PATH}/chat/completions${q}`;
100
+ }
101
+
102
+ /** The model list URL for an API version: the base models the resource can
103
+ * use (NOT its deployments; no data plane call lists those). */
104
+ export function foundryModelsUrl(root: string, version: FoundryApiVersion): string {
105
+ return version.kind === 'dated'
106
+ ? `${root}/openai/models?api-version=${version.query}`
107
+ : `${root}${FOUNDRY_V1_PATH}/models`;
108
+ }
109
+
110
+ const TOOLS = ['function_calling', 'json_mode'] as const;
111
+ const TOOLS_VISION = ['function_calling', 'json_mode', 'vision'] as const;
112
+ const TOOLS_VISION_REASONING = ['function_calling', 'json_mode', 'vision', 'reasoning'] as const;
113
+ const TOOLS_REASONING = ['function_calling', 'json_mode', 'reasoning'] as const;
114
+ const REASONING = ['reasoning'] as const;
115
+
116
+ const HINT = 'The deployment name, if you named it after the model.';
117
+
118
+ /**
119
+ * The seed the model dropdown shows. Each id is the model id, which is the
120
+ * deployment name only when the owner kept the portal's suggestion. Live
121
+ * discovery adds the base model ids the resource reports, as hints of the
122
+ * same kind.
123
+ */
124
+ export const FOUNDRY_CHAT_MODELS: readonly ChatModelInfo[] = [
125
+ // ── OpenAI (Azure OpenAI) ────────────────────────────────────────
126
+ {
127
+ id: 'gpt-5',
128
+ label: 'GPT-5',
129
+ description: `OpenAI reasoning flagship. ${HINT}`,
130
+ capabilities: TOOLS_VISION_REASONING,
131
+ },
132
+ {
133
+ id: 'gpt-5-mini',
134
+ label: 'GPT-5 mini',
135
+ description: `OpenAI reasoning, lower cost. ${HINT}`,
136
+ capabilities: TOOLS_VISION_REASONING,
137
+ },
138
+ {
139
+ id: 'gpt-5-nano',
140
+ label: 'GPT-5 nano',
141
+ description: `OpenAI reasoning, cheapest. ${HINT}`,
142
+ capabilities: TOOLS_VISION_REASONING,
143
+ },
144
+ {
145
+ id: 'gpt-4.1',
146
+ label: 'GPT-4.1',
147
+ description: `OpenAI non-reasoning, long context. ${HINT}`,
148
+ capabilities: TOOLS_VISION,
149
+ },
150
+ {
151
+ id: 'gpt-4.1-mini',
152
+ label: 'GPT-4.1 mini',
153
+ description: `OpenAI non-reasoning, fast. ${HINT}`,
154
+ capabilities: TOOLS_VISION,
155
+ },
156
+ {
157
+ id: 'gpt-4o',
158
+ label: 'GPT-4o',
159
+ description: `OpenAI multimodal. ${HINT}`,
160
+ capabilities: TOOLS_VISION,
161
+ },
162
+ {
163
+ id: 'gpt-4o-mini',
164
+ label: 'GPT-4o mini',
165
+ description: `OpenAI multimodal, cheap. ${HINT}`,
166
+ capabilities: TOOLS_VISION,
167
+ },
168
+ {
169
+ id: 'o4-mini',
170
+ label: 'o4-mini',
171
+ description: `OpenAI reasoning (o-series). ${HINT}`,
172
+ capabilities: TOOLS_VISION_REASONING,
173
+ },
174
+ // ── Foundry models from other vendors (v1 chat completions) ──────
175
+ {
176
+ id: 'DeepSeek-V3.1',
177
+ label: 'DeepSeek V3.1',
178
+ description: `DeepSeek, sold by Azure. ${HINT}`,
179
+ capabilities: TOOLS,
180
+ },
181
+ {
182
+ id: 'DeepSeek-R1',
183
+ label: 'DeepSeek R1',
184
+ description: `DeepSeek reasoning, sold by Azure. No tool calling. ${HINT}`,
185
+ capabilities: REASONING,
186
+ },
187
+ {
188
+ id: 'grok-4',
189
+ label: 'Grok 4',
190
+ description: `xAI, sold by Azure. ${HINT}`,
191
+ capabilities: TOOLS_REASONING,
192
+ },
193
+ {
194
+ id: 'Llama-3.3-70B-Instruct',
195
+ label: 'Llama 3.3 70B Instruct',
196
+ description: `Meta open model. ${HINT}`,
197
+ capabilities: TOOLS,
198
+ },
199
+ ];
package/src/index.ts CHANGED
@@ -37,6 +37,7 @@ export * from './catalogs/deepgram';
37
37
  export * from './catalogs/assemblyai';
38
38
  export * from './catalogs/deepseek';
39
39
  export * from './catalogs/mammouth';
40
+ export * from './catalogs/foundry';
40
41
 
41
42
  // Pure wiring metadata (no adapter modules pulled: registry.ts imports types
42
43
  // only).
package/src/providers.ts CHANGED
@@ -34,6 +34,7 @@ export type ProviderId =
34
34
  | 'huggingface'
35
35
  | 'deepseek'
36
36
  | 'mammouth'
37
+ | 'foundry'
37
38
  | 'copilot'
38
39
  | 'mistral'
39
40
  | 'cohere'
@@ -213,6 +214,15 @@ export const SUPPORTED_PROVIDERS: readonly Provider[] = [
213
214
  signupUrl: 'https://www.assemblyai.com/dashboard',
214
215
  docsUrl: 'https://www.assemblyai.com/docs',
215
216
  },
217
+ {
218
+ id: 'foundry',
219
+ label: 'Microsoft Foundry',
220
+ description:
221
+ 'Azure AI Foundry and Azure OpenAI: your own deployments of OpenAI, DeepSeek, Grok, Llama and other models on your Azure resource. The model id is the deployment name. Endpoint per route (Base URL) or MANTLE_FOUNDRY_ENDPOINT; key from the resource’s Keys and Endpoint page.',
222
+ capabilities: ['chat'],
223
+ signupUrl: 'https://ai.azure.com',
224
+ docsUrl: 'https://learn.microsoft.com/azure/ai-foundry/openai/api-version-lifecycle',
225
+ },
216
226
  {
217
227
  id: 'custom',
218
228
  label: 'Custom (OpenAI-compatible)',