@opengeni/config 1.3.0 → 1.4.0
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/dist/index.d.ts +146 -4
- package/dist/index.js +1150 -541
- package/dist/index.js.map +1 -1
- package/dist/realtime-voice-pricing.d.ts +30 -0
- package/dist/web-search.d.ts +127 -0
- package/package.json +4 -4
- package/src/index.ts +545 -10
- package/src/realtime-voice-pricing.ts +83 -0
- package/src/web-search.ts +353 -0
package/src/index.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export { managedUserEmailAllowed } from "./managed-user-admission";
|
|
2
|
+
import {
|
|
3
|
+
parseRealtimeVoicePricingJson,
|
|
4
|
+
parseRealtimeVoicePricingTableJson,
|
|
5
|
+
} from "./realtime-voice-pricing";
|
|
6
|
+
export * from "./realtime-voice-pricing";
|
|
7
|
+
export * from "./web-search";
|
|
2
8
|
import { EnvCreditPromotionPolicy } from "./credit-promotions";
|
|
3
9
|
export {
|
|
4
10
|
CreditPromotionPolicy,
|
|
@@ -408,6 +414,11 @@ const SettingsSchema = z.object({
|
|
|
408
414
|
delegationSecret: z.string().optional(),
|
|
409
415
|
defaultFirstPartyMcpTools: EnvFirstPartyMcpTools,
|
|
410
416
|
allowedFirstPartyMcpTools: EnvFirstPartyMcpTools,
|
|
417
|
+
// Deployment fact: the isolated artifact materializer workload runs and
|
|
418
|
+
// drains export jobs. Without it an export is queued forever, so the export
|
|
419
|
+
// tools leave the first-party ceiling. Helm sets this from
|
|
420
|
+
// artifactMaterializer.enabled.
|
|
421
|
+
artifactMaterializerDeployed: EnvBoolean.default(false),
|
|
411
422
|
// sandbox workspace scoped stream-token HMAC secret (sandbox contract §C.3 / stream-token availability contract).
|
|
412
423
|
// When unset, the API falls back to `delegationSecret` (the same HMAC envelope
|
|
413
424
|
// family, `ogs_` vs `ogd_` prefix). REQUIRED-WHEN-DESKTOP, but the absence of
|
|
@@ -725,6 +736,35 @@ const SettingsSchema = z.object({
|
|
|
725
736
|
voiceInputAzureApiVersion: z.string().optional(),
|
|
726
737
|
voiceInputAzureApiKey: z.string().optional(),
|
|
727
738
|
voiceInputAzureAdToken: z.string().optional(),
|
|
739
|
+
// Hosted realtime voice is configured independently of dictation.
|
|
740
|
+
azureLiveEndpoint: z.string().url().optional(),
|
|
741
|
+
azureLiveApiKey: z.string().optional(),
|
|
742
|
+
azureLiveDeployment: z.string().default("gpt-live-1"),
|
|
743
|
+
azureLiveVoice: z.string().default("marin"),
|
|
744
|
+
// Credit price of deployment-funded live voice (RealtimeVoicePricing JSON).
|
|
745
|
+
// Required while credit billing is active, otherwise the model is withheld.
|
|
746
|
+
azureLivePricingJson: z.string().optional(),
|
|
747
|
+
// Managed AI Gateway live voice prices keyed by upstream model id.
|
|
748
|
+
aiGatewayRealtimePricingJson: z.string().optional(),
|
|
749
|
+
// Azure Speech credentials are explicit: a different resource can host MAI.
|
|
750
|
+
voiceInputMaiEndpoint: z.string().url().optional(),
|
|
751
|
+
voiceInputMaiApiKey: z.string().optional(),
|
|
752
|
+
voiceInputMaiApiVersion: z.string().default("2025-10-15"),
|
|
753
|
+
voiceInputMaiPricingJson: z.string().optional(),
|
|
754
|
+
voiceInputMaiModel: z.string().default("MAI-Transcribe-2"),
|
|
755
|
+
// Underlying model of the Azure deployment (for example gpt-4o-transcribe or
|
|
756
|
+
// whisper). Azure routes by deployment name, so this only selects built-in
|
|
757
|
+
// pricing and the provider-reported usage shape (Whisper requests
|
|
758
|
+
// verbose_json so Azure reports the billed audio duration). Defaults to the
|
|
759
|
+
// deployment name.
|
|
760
|
+
voiceInputAzureModel: z.string().trim().min(1).max(256).optional(),
|
|
761
|
+
// Opengeni credit pricing for deployment-funded voice input (`openai`,
|
|
762
|
+
// `azure-openai`). JSON VoiceInputPricing; overrides the built-in list price
|
|
763
|
+
// for the configured model. Validated at boot. When credit billing is active
|
|
764
|
+
// (OPENGENI_BILLING_MODE=stripe or OPENGENI_USAGE_LIMITS_MODE=managed) a
|
|
765
|
+
// deployment-funded provider without any pricing is not offered at all.
|
|
766
|
+
voiceInputOpenaiPricingJson: z.string().optional(),
|
|
767
|
+
voiceInputAzurePricingJson: z.string().optional(),
|
|
728
768
|
// Legacy opt-in for undocumented ChatGPT /backend-api/transcribe. When
|
|
729
769
|
// OPENGENI_CODEX_SUBSCRIPTION_ENABLED is true, Codex STT is included without
|
|
730
770
|
// this flag. Set false and omit codex-subscription from PROVIDER_ORDER to
|
|
@@ -847,6 +887,18 @@ const SettingsSchema = z.object({
|
|
|
847
887
|
// merged with the MCP-server tools (getAllTools = [...mcpTools, ...tools])
|
|
848
888
|
// and the sandbox capability tools, never replacing them.
|
|
849
889
|
webSearchEnabled: EnvBoolean.default(true),
|
|
890
|
+
// Provider-agnostic web search (`web_search` / `web_fetch` agent tools,
|
|
891
|
+
// see ./web-search.ts). Inert until a provider is named; validated lazily so
|
|
892
|
+
// a misconfiguration withholds the tools instead of failing boot.
|
|
893
|
+
webSearchProvider: z.string().optional(),
|
|
894
|
+
webSearchApiKey: z.string().optional(),
|
|
895
|
+
webSearchBaseUrl: z.string().optional(),
|
|
896
|
+
webFetchProvider: z.string().optional(),
|
|
897
|
+
webFetchApiKey: z.string().optional(),
|
|
898
|
+
webFetchBaseUrl: z.string().optional(),
|
|
899
|
+
webSearchProviderMode: z.string().optional(),
|
|
900
|
+
webSearchPricingJson: z.string().optional(),
|
|
901
|
+
webSearchRequestTimeoutMs: z.coerce.number().int().positive().max(120_000).default(20_000),
|
|
850
902
|
// Jev (TypeSafe's fast judge model) for worker-side agent tools. Without a
|
|
851
903
|
// usable key every Jev-backed feature is off. The key stays on the server
|
|
852
904
|
// (API and worker) and never reaches a sandbox or Connected Machine.
|
|
@@ -1665,16 +1717,28 @@ export function personalGitHubOAuthCallbackUrl(publicBaseUrl: string | undefined
|
|
|
1665
1717
|
export type VoiceInputProviderId =
|
|
1666
1718
|
| "openai"
|
|
1667
1719
|
| "azure-openai"
|
|
1720
|
+
| "azure-mai"
|
|
1668
1721
|
| "codex-subscription"
|
|
1669
1722
|
| "supergrok-subscription";
|
|
1670
1723
|
|
|
1671
1724
|
export type VoiceInputProviderConfig =
|
|
1725
|
+
| {
|
|
1726
|
+
id: "azure-mai";
|
|
1727
|
+
kind: "azure-mai";
|
|
1728
|
+
pricing: VoiceInputPricing | null;
|
|
1729
|
+
endpoint: string;
|
|
1730
|
+
apiKey: string;
|
|
1731
|
+
apiVersion: string;
|
|
1732
|
+
model: string;
|
|
1733
|
+
}
|
|
1672
1734
|
| {
|
|
1673
1735
|
id: "openai";
|
|
1674
1736
|
kind: "openai";
|
|
1675
1737
|
apiKey: string;
|
|
1676
1738
|
baseUrl: string;
|
|
1677
1739
|
model: string;
|
|
1740
|
+
/** Deployment-funded: Opengeni pays upstream and charges credits. */
|
|
1741
|
+
pricing: VoiceInputPricing | null;
|
|
1678
1742
|
}
|
|
1679
1743
|
| {
|
|
1680
1744
|
id: "azure-openai";
|
|
@@ -1684,6 +1748,10 @@ export type VoiceInputProviderConfig =
|
|
|
1684
1748
|
apiVersion: string;
|
|
1685
1749
|
apiKey: string | null;
|
|
1686
1750
|
adToken: string | null;
|
|
1751
|
+
/** Underlying model (pricing + response shape); defaults to the deployment name. */
|
|
1752
|
+
model: string;
|
|
1753
|
+
/** Deployment-funded: Opengeni pays upstream and charges credits. */
|
|
1754
|
+
pricing: VoiceInputPricing | null;
|
|
1687
1755
|
}
|
|
1688
1756
|
| {
|
|
1689
1757
|
id: "codex-subscription";
|
|
@@ -1707,10 +1775,7 @@ export function usableJevApiKey(settings: Pick<Settings, "jevApiKey">): string |
|
|
|
1707
1775
|
|
|
1708
1776
|
/** Deployment half of agent configuration: hard capability limits. */
|
|
1709
1777
|
export function agentConfigDeploymentPolicy(
|
|
1710
|
-
settings: Pick<
|
|
1711
|
-
Settings,
|
|
1712
|
-
"webSearchEnabled" | "defaultFirstPartyMcpTools" | "allowedFirstPartyMcpTools"
|
|
1713
|
-
>,
|
|
1778
|
+
settings: FirstPartyMcpToolPolicySettings & Pick<Settings, "webSearchEnabled">,
|
|
1714
1779
|
): AgentConfigDeploymentLimits {
|
|
1715
1780
|
return agentConfigDeploymentLimitsFromAllowlist(
|
|
1716
1781
|
resolveFirstPartyMcpToolPolicy(settings).allowed,
|
|
@@ -1767,6 +1832,58 @@ export function isUsableVoiceInputSecret(value: string | null | undefined): valu
|
|
|
1767
1832
|
* whether at least one non-experimental (or probed experimental) provider exists.
|
|
1768
1833
|
*/
|
|
1769
1834
|
export function resolveVoiceInputProviderRegistry(settings: Settings): VoiceInputProviderConfig[] {
|
|
1835
|
+
return voiceInputProviderRegistryWithIssues(settings).providers;
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
/** Why a credentialed deployment-funded voice provider is withheld. */
|
|
1839
|
+
export type VoiceInputPricingIssue = {
|
|
1840
|
+
providerId: "openai" | "azure-openai" | "azure-mai";
|
|
1841
|
+
env: string;
|
|
1842
|
+
reason: "malformed" | "unpriced";
|
|
1843
|
+
message: string;
|
|
1844
|
+
};
|
|
1845
|
+
|
|
1846
|
+
/**
|
|
1847
|
+
* Pricing problems that withhold a credentialed deployment-funded provider.
|
|
1848
|
+
* A malformed PRICING_JSON never fails boot (workers share this config and
|
|
1849
|
+
* must not crash-loop over a voice-only setting); the API logs each issue
|
|
1850
|
+
* once at startup and the provider stays unavailable.
|
|
1851
|
+
*/
|
|
1852
|
+
export function voiceInputPricingIssues(settings: Settings): VoiceInputPricingIssue[] {
|
|
1853
|
+
return voiceInputProviderRegistryWithIssues(settings).issues;
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
function voiceInputProviderPricing(
|
|
1857
|
+
settings: Settings,
|
|
1858
|
+
issues: VoiceInputPricingIssue[],
|
|
1859
|
+
providerId: VoiceInputPricingIssue["providerId"],
|
|
1860
|
+
env: string,
|
|
1861
|
+
raw: string | undefined,
|
|
1862
|
+
model: string,
|
|
1863
|
+
): { usable: true; pricing: VoiceInputPricing | null } | { usable: false } {
|
|
1864
|
+
const resolved = safeResolveVoiceInputPricing(raw, model, env);
|
|
1865
|
+
if (!resolved.ok) {
|
|
1866
|
+
issues.push({ providerId, env, reason: "malformed", message: resolved.error });
|
|
1867
|
+
return { usable: false };
|
|
1868
|
+
}
|
|
1869
|
+
if (!resolved.pricing && voiceInputCreditBillingActive(settings)) {
|
|
1870
|
+
// Never serve unpriced deployment-paid audio on a credit-billed deployment.
|
|
1871
|
+
issues.push({
|
|
1872
|
+
providerId,
|
|
1873
|
+
env,
|
|
1874
|
+
reason: "unpriced",
|
|
1875
|
+
message: `${env} is required: credit billing is active and model "${model}" has no built-in voice price`,
|
|
1876
|
+
});
|
|
1877
|
+
return { usable: false };
|
|
1878
|
+
}
|
|
1879
|
+
return { usable: true, pricing: resolved.pricing };
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
function voiceInputProviderRegistryWithIssues(settings: Settings): {
|
|
1883
|
+
providers: VoiceInputProviderConfig[];
|
|
1884
|
+
issues: VoiceInputPricingIssue[];
|
|
1885
|
+
} {
|
|
1886
|
+
const issues: VoiceInputPricingIssue[] = [];
|
|
1770
1887
|
const order = settings.voiceInputProviderOrder
|
|
1771
1888
|
.split(",")
|
|
1772
1889
|
.map((part) => part.trim())
|
|
@@ -1774,6 +1891,7 @@ export function resolveVoiceInputProviderRegistry(settings: Settings): VoiceInpu
|
|
|
1774
1891
|
(part): part is VoiceInputProviderId =>
|
|
1775
1892
|
part === "openai" ||
|
|
1776
1893
|
part === "azure-openai" ||
|
|
1894
|
+
part === "azure-mai" ||
|
|
1777
1895
|
part === "codex-subscription" ||
|
|
1778
1896
|
part === "supergrok-subscription",
|
|
1779
1897
|
);
|
|
@@ -1782,6 +1900,32 @@ export function resolveVoiceInputProviderRegistry(settings: Settings): VoiceInpu
|
|
|
1782
1900
|
for (const id of order) {
|
|
1783
1901
|
if (seen.has(id)) continue;
|
|
1784
1902
|
seen.add(id);
|
|
1903
|
+
if (id === "azure-mai") {
|
|
1904
|
+
if (
|
|
1905
|
+
!settings.voiceInputMaiEndpoint ||
|
|
1906
|
+
!isUsableVoiceInputSecret(settings.voiceInputMaiApiKey)
|
|
1907
|
+
)
|
|
1908
|
+
continue;
|
|
1909
|
+
const priced = voiceInputProviderPricing(
|
|
1910
|
+
settings,
|
|
1911
|
+
issues,
|
|
1912
|
+
"azure-mai",
|
|
1913
|
+
"OPENGENI_VOICE_INPUT_MAI_PRICING_JSON",
|
|
1914
|
+
settings.voiceInputMaiPricingJson,
|
|
1915
|
+
settings.voiceInputMaiModel,
|
|
1916
|
+
);
|
|
1917
|
+
if (!priced.usable) continue;
|
|
1918
|
+
providers.push({
|
|
1919
|
+
id,
|
|
1920
|
+
kind: "azure-mai",
|
|
1921
|
+
pricing: priced.pricing,
|
|
1922
|
+
endpoint: settings.voiceInputMaiEndpoint.replace(/\/+$/, ""),
|
|
1923
|
+
apiKey: settings.voiceInputMaiApiKey,
|
|
1924
|
+
apiVersion: settings.voiceInputMaiApiVersion,
|
|
1925
|
+
model: settings.voiceInputMaiModel,
|
|
1926
|
+
});
|
|
1927
|
+
continue;
|
|
1928
|
+
}
|
|
1785
1929
|
if (id === "openai") {
|
|
1786
1930
|
if (!settings.voiceInputOpenaiEnabled) continue;
|
|
1787
1931
|
const apiKey = settings.voiceInputOpenaiApiKey ?? settings.openaiApiKey;
|
|
@@ -1795,9 +1939,19 @@ export function resolveVoiceInputProviderRegistry(settings: Settings): VoiceInpu
|
|
|
1795
1939
|
) {
|
|
1796
1940
|
continue;
|
|
1797
1941
|
}
|
|
1942
|
+
const priced = voiceInputProviderPricing(
|
|
1943
|
+
settings,
|
|
1944
|
+
issues,
|
|
1945
|
+
"openai",
|
|
1946
|
+
"OPENGENI_VOICE_INPUT_OPENAI_PRICING_JSON",
|
|
1947
|
+
settings.voiceInputOpenaiPricingJson,
|
|
1948
|
+
settings.voiceInputOpenaiModel,
|
|
1949
|
+
);
|
|
1950
|
+
if (!priced.usable) continue;
|
|
1798
1951
|
providers.push({
|
|
1799
1952
|
id: "openai",
|
|
1800
1953
|
kind: "openai",
|
|
1954
|
+
pricing: priced.pricing,
|
|
1801
1955
|
apiKey,
|
|
1802
1956
|
baseUrl: (
|
|
1803
1957
|
settings.voiceInputOpenaiBaseUrl ??
|
|
@@ -1840,6 +1994,17 @@ export function resolveVoiceInputProviderRegistry(settings: Settings): VoiceInpu
|
|
|
1840
1994
|
) {
|
|
1841
1995
|
continue;
|
|
1842
1996
|
}
|
|
1997
|
+
const model = settings.voiceInputAzureModel ?? deployment;
|
|
1998
|
+
const priced = voiceInputProviderPricing(
|
|
1999
|
+
settings,
|
|
2000
|
+
issues,
|
|
2001
|
+
"azure-openai",
|
|
2002
|
+
"OPENGENI_VOICE_INPUT_AZURE_PRICING_JSON",
|
|
2003
|
+
settings.voiceInputAzurePricingJson,
|
|
2004
|
+
model,
|
|
2005
|
+
);
|
|
2006
|
+
if (!priced.usable) continue;
|
|
2007
|
+
const pricing = priced.pricing;
|
|
1843
2008
|
providers.push({
|
|
1844
2009
|
id: "azure-openai",
|
|
1845
2010
|
kind: "azure-openai",
|
|
@@ -1848,6 +2013,8 @@ export function resolveVoiceInputProviderRegistry(settings: Settings): VoiceInpu
|
|
|
1848
2013
|
apiVersion,
|
|
1849
2014
|
apiKey: isUsableVoiceInputSecret(apiKey) ? apiKey : null,
|
|
1850
2015
|
adToken: isUsableVoiceInputSecret(adToken) ? adToken : null,
|
|
2016
|
+
model,
|
|
2017
|
+
pricing,
|
|
1851
2018
|
});
|
|
1852
2019
|
continue;
|
|
1853
2020
|
}
|
|
@@ -1874,7 +2041,251 @@ export function resolveVoiceInputProviderRegistry(settings: Settings): VoiceInpu
|
|
|
1874
2041
|
});
|
|
1875
2042
|
}
|
|
1876
2043
|
}
|
|
1877
|
-
return providers;
|
|
2044
|
+
return { providers, issues };
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
/**
|
|
2048
|
+
* Opengeni credit price for one deployment-funded transcription provider.
|
|
2049
|
+
* Rates are upstream list prices in integer USD micros; `marginBps` (500 =
|
|
2050
|
+
* +5%) is added on top, exactly like model pricing. `microsPerMinute` prices
|
|
2051
|
+
* provider-reported audio duration (Whisper, `usage.type: "duration"`) and is
|
|
2052
|
+
* a server-measured WAV duration when provider usage is absent. Token
|
|
2053
|
+
* rates price `usage.type: "tokens"` (gpt-4o-transcribe family); `input`
|
|
2054
|
+
* covers text input tokens and, unless `audioInput` is set, audio tokens.
|
|
2055
|
+
*/
|
|
2056
|
+
export type VoiceInputPricing = {
|
|
2057
|
+
microsPerMinute: number;
|
|
2058
|
+
inputMicrosPerMillionTokens?: number | undefined;
|
|
2059
|
+
audioInputMicrosPerMillionTokens?: number | undefined;
|
|
2060
|
+
outputMicrosPerMillionTokens?: number | undefined;
|
|
2061
|
+
marginBps?: number | undefined;
|
|
2062
|
+
};
|
|
2063
|
+
|
|
2064
|
+
const VoiceInputPricingSchema = z
|
|
2065
|
+
.object({
|
|
2066
|
+
microsPerMinute: z.number().int().positive().max(100_000_000),
|
|
2067
|
+
inputMicrosPerMillionTokens: z.number().int().nonnegative().max(1_000_000_000).optional(),
|
|
2068
|
+
audioInputMicrosPerMillionTokens: z.number().int().nonnegative().max(1_000_000_000).optional(),
|
|
2069
|
+
outputMicrosPerMillionTokens: z.number().int().nonnegative().max(1_000_000_000).optional(),
|
|
2070
|
+
marginBps: z.number().int().min(0).max(100_000).optional(),
|
|
2071
|
+
})
|
|
2072
|
+
.strict()
|
|
2073
|
+
.superRefine((pricing, ctx) => {
|
|
2074
|
+
const input = pricing.inputMicrosPerMillionTokens !== undefined;
|
|
2075
|
+
const output = pricing.outputMicrosPerMillionTokens !== undefined;
|
|
2076
|
+
if (input !== output) {
|
|
2077
|
+
ctx.addIssue({
|
|
2078
|
+
code: "custom",
|
|
2079
|
+
message: "inputMicrosPerMillionTokens and outputMicrosPerMillionTokens are set together",
|
|
2080
|
+
});
|
|
2081
|
+
}
|
|
2082
|
+
if (pricing.audioInputMicrosPerMillionTokens !== undefined && !input) {
|
|
2083
|
+
ctx.addIssue({
|
|
2084
|
+
code: "custom",
|
|
2085
|
+
message: "audioInputMicrosPerMillionTokens requires the token input/output rates",
|
|
2086
|
+
});
|
|
2087
|
+
}
|
|
2088
|
+
});
|
|
2089
|
+
|
|
2090
|
+
/**
|
|
2091
|
+
* Built-in list prices (OpenAI API pricing, "Transcription models" table)
|
|
2092
|
+
* plus the default 5% Opengeni margin used for model pricing. Azure Global
|
|
2093
|
+
* Standard deployments use the same list prices; set the provider
|
|
2094
|
+
* PRICING_JSON when a deployment's contracted or regional price differs.
|
|
2095
|
+
*/
|
|
2096
|
+
export const defaultVoiceInputPricing: Readonly<Record<string, VoiceInputPricing>> = {
|
|
2097
|
+
// Audio tokens are listed separately from text tokens on the model pages;
|
|
2098
|
+
// set explicitly so the audio rate never silently follows a text-rate edit.
|
|
2099
|
+
"gpt-4o-transcribe": {
|
|
2100
|
+
microsPerMinute: 6_000,
|
|
2101
|
+
inputMicrosPerMillionTokens: 2_500_000,
|
|
2102
|
+
audioInputMicrosPerMillionTokens: 2_500_000,
|
|
2103
|
+
outputMicrosPerMillionTokens: 10_000_000,
|
|
2104
|
+
marginBps: 500,
|
|
2105
|
+
},
|
|
2106
|
+
"gpt-4o-transcribe-diarize": {
|
|
2107
|
+
microsPerMinute: 6_000,
|
|
2108
|
+
inputMicrosPerMillionTokens: 2_500_000,
|
|
2109
|
+
audioInputMicrosPerMillionTokens: 2_500_000,
|
|
2110
|
+
outputMicrosPerMillionTokens: 10_000_000,
|
|
2111
|
+
marginBps: 500,
|
|
2112
|
+
},
|
|
2113
|
+
"gpt-4o-mini-transcribe": {
|
|
2114
|
+
microsPerMinute: 3_000,
|
|
2115
|
+
inputMicrosPerMillionTokens: 1_250_000,
|
|
2116
|
+
audioInputMicrosPerMillionTokens: 1_250_000,
|
|
2117
|
+
outputMicrosPerMillionTokens: 5_000_000,
|
|
2118
|
+
marginBps: 500,
|
|
2119
|
+
},
|
|
2120
|
+
"gpt-transcribe": { microsPerMinute: 4_500, marginBps: 500 },
|
|
2121
|
+
whisper: { microsPerMinute: 6_000, marginBps: 500 },
|
|
2122
|
+
"whisper-1": { microsPerMinute: 6_000, marginBps: 500 },
|
|
2123
|
+
};
|
|
2124
|
+
|
|
2125
|
+
/** Lowercased model with a dated snapshot suffix (`-2025-03-20`) removed. */
|
|
2126
|
+
export function canonicalVoiceInputModel(model: string): string {
|
|
2127
|
+
return model
|
|
2128
|
+
.trim()
|
|
2129
|
+
.toLowerCase()
|
|
2130
|
+
.replace(/-\d{4}-\d{2}-\d{2}$/, "");
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
/** Whisper reports its billed audio duration only in `verbose_json`. */
|
|
2134
|
+
export function voiceInputModelReportsDurationOnly(model: string): boolean {
|
|
2135
|
+
return canonicalVoiceInputModel(model).startsWith("whisper");
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
/** Parse one provider pricing JSON. Throws a configuration error when malformed. */
|
|
2139
|
+
export function parseVoiceInputPricingJson(
|
|
2140
|
+
raw: string | undefined,
|
|
2141
|
+
env = "voice-input pricing JSON",
|
|
2142
|
+
): VoiceInputPricing | null {
|
|
2143
|
+
if (raw === undefined || raw.trim() === "") return null;
|
|
2144
|
+
let parsed: unknown;
|
|
2145
|
+
try {
|
|
2146
|
+
parsed = JSON.parse(raw);
|
|
2147
|
+
} catch {
|
|
2148
|
+
throw new Error(`${env} must be valid JSON`);
|
|
2149
|
+
}
|
|
2150
|
+
const result = VoiceInputPricingSchema.safeParse(parsed);
|
|
2151
|
+
if (!result.success) {
|
|
2152
|
+
throw new Error(
|
|
2153
|
+
`${env} is invalid: ${result.error.issues.map((issue) => issue.message).join("; ")}`,
|
|
2154
|
+
);
|
|
2155
|
+
}
|
|
2156
|
+
return result.data;
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
/** Explicit provider pricing JSON wins; otherwise the built-in list price for the model. */
|
|
2160
|
+
export function resolveVoiceInputPricing(
|
|
2161
|
+
raw: string | undefined,
|
|
2162
|
+
model: string,
|
|
2163
|
+
): VoiceInputPricing | null {
|
|
2164
|
+
return (
|
|
2165
|
+
parseVoiceInputPricingJson(raw) ??
|
|
2166
|
+
defaultVoiceInputPricing[canonicalVoiceInputModel(model)] ??
|
|
2167
|
+
null
|
|
2168
|
+
);
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
/** Non-throwing {@link resolveVoiceInputPricing} for registry resolution. */
|
|
2172
|
+
export function safeResolveVoiceInputPricing(
|
|
2173
|
+
raw: string | undefined,
|
|
2174
|
+
model: string,
|
|
2175
|
+
env?: string,
|
|
2176
|
+
): { ok: true; pricing: VoiceInputPricing | null } | { ok: false; error: string } {
|
|
2177
|
+
let explicit: VoiceInputPricing | null;
|
|
2178
|
+
try {
|
|
2179
|
+
explicit = parseVoiceInputPricingJson(raw, env);
|
|
2180
|
+
} catch (error) {
|
|
2181
|
+
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
2182
|
+
}
|
|
2183
|
+
return {
|
|
2184
|
+
ok: true,
|
|
2185
|
+
pricing: explicit ?? defaultVoiceInputPricing[canonicalVoiceInputModel(model)] ?? null,
|
|
2186
|
+
};
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
/** Same predicate as model/credit limits: credit balance and debits are enforced. */
|
|
2190
|
+
export function voiceInputCreditBillingActive(
|
|
2191
|
+
settings: Pick<Settings, "billingMode" | "usageLimitsMode">,
|
|
2192
|
+
): boolean {
|
|
2193
|
+
return settings.billingMode === "stripe" || settings.usageLimitsMode === "managed";
|
|
2194
|
+
}
|
|
2195
|
+
|
|
2196
|
+
/** Provider-reported transcription usage, normalized. Never client-reported. */
|
|
2197
|
+
export type VoiceInputUsage =
|
|
2198
|
+
| {
|
|
2199
|
+
kind: "tokens";
|
|
2200
|
+
inputTokens: number;
|
|
2201
|
+
audioInputTokens: number;
|
|
2202
|
+
textInputTokens: number;
|
|
2203
|
+
outputTokens: number;
|
|
2204
|
+
}
|
|
2205
|
+
| { kind: "duration"; seconds: number };
|
|
2206
|
+
|
|
2207
|
+
export type VoiceInputCost = {
|
|
2208
|
+
/** Upstream list cost before margin, rounded up to whole micros. */
|
|
2209
|
+
providerCostMicros: number;
|
|
2210
|
+
/** Opengeni credit price after margin, rounded up to whole micros. */
|
|
2211
|
+
creditCostMicros: number;
|
|
2212
|
+
};
|
|
2213
|
+
|
|
2214
|
+
/** True when token usage can be priced exactly. */
|
|
2215
|
+
export function voiceInputPricingHasTokenRates(pricing: VoiceInputPricing): boolean {
|
|
2216
|
+
return (
|
|
2217
|
+
pricing.inputMicrosPerMillionTokens !== undefined &&
|
|
2218
|
+
pricing.outputMicrosPerMillionTokens !== undefined
|
|
2219
|
+
);
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
/**
|
|
2223
|
+
* Exact integer credit math. Token usage needs token rates; duration usage
|
|
2224
|
+
* uses `microsPerMinute` at millisecond resolution. Both round up once, after
|
|
2225
|
+
* summing, so a positive use never becomes a free debit.
|
|
2226
|
+
*/
|
|
2227
|
+
export function calculateVoiceInputCost(
|
|
2228
|
+
pricing: VoiceInputPricing,
|
|
2229
|
+
usage: VoiceInputUsage,
|
|
2230
|
+
): VoiceInputCost {
|
|
2231
|
+
let numerator: bigint;
|
|
2232
|
+
let denominator: bigint;
|
|
2233
|
+
if (usage.kind === "tokens") {
|
|
2234
|
+
if (
|
|
2235
|
+
pricing.inputMicrosPerMillionTokens === undefined ||
|
|
2236
|
+
pricing.outputMicrosPerMillionTokens === undefined
|
|
2237
|
+
) {
|
|
2238
|
+
throw new Error("voice-input token usage requires token pricing");
|
|
2239
|
+
}
|
|
2240
|
+
for (const value of [
|
|
2241
|
+
usage.inputTokens,
|
|
2242
|
+
usage.audioInputTokens,
|
|
2243
|
+
usage.textInputTokens,
|
|
2244
|
+
usage.outputTokens,
|
|
2245
|
+
]) {
|
|
2246
|
+
if (!Number.isSafeInteger(value) || value < 0) {
|
|
2247
|
+
throw new Error("voice-input token usage must be non-negative integers");
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
const audioRate =
|
|
2251
|
+
pricing.audioInputMicrosPerMillionTokens ?? pricing.inputMicrosPerMillionTokens;
|
|
2252
|
+
// Input tokens the provider did not attribute are priced as audio (never cheaper).
|
|
2253
|
+
const unattributed = Math.max(
|
|
2254
|
+
0,
|
|
2255
|
+
usage.inputTokens - usage.audioInputTokens - usage.textInputTokens,
|
|
2256
|
+
);
|
|
2257
|
+
numerator =
|
|
2258
|
+
BigInt(usage.audioInputTokens + unattributed) * BigInt(audioRate) +
|
|
2259
|
+
BigInt(usage.textInputTokens) * BigInt(pricing.inputMicrosPerMillionTokens) +
|
|
2260
|
+
BigInt(usage.outputTokens) * BigInt(pricing.outputMicrosPerMillionTokens);
|
|
2261
|
+
denominator = 1_000_000n;
|
|
2262
|
+
} else {
|
|
2263
|
+
if (!Number.isFinite(usage.seconds) || usage.seconds < 0) {
|
|
2264
|
+
throw new Error("voice-input duration must be a non-negative number of seconds");
|
|
2265
|
+
}
|
|
2266
|
+
numerator = BigInt(Math.ceil(usage.seconds * 1_000)) * BigInt(pricing.microsPerMinute);
|
|
2267
|
+
denominator = 60_000n;
|
|
2268
|
+
}
|
|
2269
|
+
const margin = BigInt(10_000 + (pricing.marginBps ?? 0));
|
|
2270
|
+
const provider = (numerator + denominator - 1n) / denominator;
|
|
2271
|
+
const scaled = denominator * 10_000n;
|
|
2272
|
+
const credit = (numerator * margin + scaled - 1n) / scaled;
|
|
2273
|
+
if (credit > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
2274
|
+
throw new Error("voice-input cost exceeds the supported billing range");
|
|
2275
|
+
}
|
|
2276
|
+
return { providerCostMicros: Number(provider), creditCostMicros: Number(credit) };
|
|
2277
|
+
}
|
|
2278
|
+
|
|
2279
|
+
/**
|
|
2280
|
+
* Deployment-funded providers that have credentials but are withheld because
|
|
2281
|
+
* credit billing is active and no price is known. The API logs these (and
|
|
2282
|
+
* malformed pricing, see {@link voiceInputPricingIssues}) once at startup so
|
|
2283
|
+
* an operator sees why voice input stayed unavailable.
|
|
2284
|
+
*/
|
|
2285
|
+
export function unpricedVoiceInputProviders(settings: Settings): VoiceInputProviderId[] {
|
|
2286
|
+
return voiceInputPricingIssues(settings).flatMap((issue) =>
|
|
2287
|
+
issue.reason === "unpriced" ? [issue.providerId] : [],
|
|
2288
|
+
);
|
|
1878
2289
|
}
|
|
1879
2290
|
|
|
1880
2291
|
/** True when the deployment has at least one supported (non-experimental) provider. */
|
|
@@ -3487,6 +3898,7 @@ export function getSettings(source: NodeJS.ProcessEnv = process.env): Settings {
|
|
|
3487
3898
|
delegationSecret: optional("OPENGENI_DELEGATION_SECRET"),
|
|
3488
3899
|
defaultFirstPartyMcpTools: optional("OPENGENI_DEFAULT_FIRST_PARTY_MCP_TOOLS"),
|
|
3489
3900
|
allowedFirstPartyMcpTools: optional("OPENGENI_ALLOWED_FIRST_PARTY_MCP_TOOLS"),
|
|
3901
|
+
artifactMaterializerDeployed: optional("OPENGENI_ARTIFACT_MATERIALIZER_DEPLOYED"),
|
|
3490
3902
|
streamTokenSecret: optional("OPENGENI_STREAM_TOKEN_SECRET"),
|
|
3491
3903
|
streamControlEnabled: optional("OPENGENI_STREAM_CONTROL_ENABLED"),
|
|
3492
3904
|
workDiscoveryEnabled: optional("OPENGENI_WORK_DISCOVERY_ENABLED"),
|
|
@@ -3614,6 +4026,20 @@ export function getSettings(source: NodeJS.ProcessEnv = process.env): Settings {
|
|
|
3614
4026
|
voiceInputAzureApiVersion: optional("OPENGENI_VOICE_INPUT_AZURE_API_VERSION"),
|
|
3615
4027
|
voiceInputAzureApiKey: optional("OPENGENI_VOICE_INPUT_AZURE_API_KEY"),
|
|
3616
4028
|
voiceInputAzureAdToken: optional("OPENGENI_VOICE_INPUT_AZURE_AD_TOKEN"),
|
|
4029
|
+
azureLiveEndpoint: optional("OPENGENI_AZURE_LIVE_ENDPOINT"),
|
|
4030
|
+
azureLiveApiKey: optional("OPENGENI_AZURE_LIVE_API_KEY"),
|
|
4031
|
+
azureLiveDeployment: optional("OPENGENI_AZURE_LIVE_DEPLOYMENT"),
|
|
4032
|
+
azureLiveVoice: optional("OPENGENI_AZURE_LIVE_VOICE"),
|
|
4033
|
+
azureLivePricingJson: optional("OPENGENI_AZURE_LIVE_PRICING_JSON"),
|
|
4034
|
+
aiGatewayRealtimePricingJson: optional("OPENGENI_AI_GATEWAY_REALTIME_PRICING_JSON"),
|
|
4035
|
+
voiceInputMaiEndpoint: optional("OPENGENI_VOICE_INPUT_MAI_ENDPOINT"),
|
|
4036
|
+
voiceInputMaiApiKey: optional("OPENGENI_VOICE_INPUT_MAI_API_KEY"),
|
|
4037
|
+
voiceInputMaiApiVersion: optional("OPENGENI_VOICE_INPUT_MAI_API_VERSION"),
|
|
4038
|
+
voiceInputMaiPricingJson: optional("OPENGENI_VOICE_INPUT_MAI_PRICING_JSON"),
|
|
4039
|
+
voiceInputMaiModel: optional("OPENGENI_VOICE_INPUT_MAI_MODEL"),
|
|
4040
|
+
voiceInputAzureModel: optional("OPENGENI_VOICE_INPUT_AZURE_MODEL"),
|
|
4041
|
+
voiceInputOpenaiPricingJson: optional("OPENGENI_VOICE_INPUT_OPENAI_PRICING_JSON"),
|
|
4042
|
+
voiceInputAzurePricingJson: optional("OPENGENI_VOICE_INPUT_AZURE_PRICING_JSON"),
|
|
3617
4043
|
voiceInputCodexExperimentalEnabled: optional("OPENGENI_VOICE_INPUT_CODEX_EXPERIMENTAL"),
|
|
3618
4044
|
modelPricingJson: optional("OPENGENI_MODEL_PRICING_JSON"),
|
|
3619
4045
|
modelCatalogSource,
|
|
@@ -3644,6 +4070,15 @@ export function getSettings(source: NodeJS.ProcessEnv = process.env): Settings {
|
|
|
3644
4070
|
openaiReasoningEncryptedContent: optional("OPENGENI_OPENAI_REASONING_ENCRYPTED_CONTENT"),
|
|
3645
4071
|
openaiMaxRetries: optional("OPENGENI_OPENAI_MAX_RETRIES"),
|
|
3646
4072
|
webSearchEnabled: optional("OPENGENI_WEB_SEARCH_ENABLED"),
|
|
4073
|
+
webSearchProvider: optional("OPENGENI_WEB_SEARCH_PROVIDER"),
|
|
4074
|
+
webSearchApiKey: optional("OPENGENI_WEB_SEARCH_API_KEY"),
|
|
4075
|
+
webSearchBaseUrl: optional("OPENGENI_WEB_SEARCH_BASE_URL"),
|
|
4076
|
+
webFetchProvider: optional("OPENGENI_WEB_FETCH_PROVIDER"),
|
|
4077
|
+
webFetchApiKey: optional("OPENGENI_WEB_FETCH_API_KEY"),
|
|
4078
|
+
webFetchBaseUrl: optional("OPENGENI_WEB_FETCH_BASE_URL"),
|
|
4079
|
+
webSearchProviderMode: optional("OPENGENI_WEB_SEARCH_PROVIDER_MODE"),
|
|
4080
|
+
webSearchPricingJson: optional("OPENGENI_WEB_SEARCH_PRICING_JSON"),
|
|
4081
|
+
webSearchRequestTimeoutMs: optional("OPENGENI_WEB_SEARCH_REQUEST_TIMEOUT_MS"),
|
|
3647
4082
|
jevApiKey: optional("OPENGENI_JEV_API_KEY"),
|
|
3648
4083
|
jevBaseUrl: optional("OPENGENI_JEV_BASE_URL"),
|
|
3649
4084
|
jevModel: optional("OPENGENI_JEV_MODEL"),
|
|
@@ -3983,13 +4418,35 @@ export type FirstPartyMcpToolPolicy = {
|
|
|
3983
4418
|
allowed: FirstPartyMcpToolNameType[];
|
|
3984
4419
|
};
|
|
3985
4420
|
|
|
4421
|
+
export type FirstPartyMcpToolPolicySettings = Pick<
|
|
4422
|
+
Settings,
|
|
4423
|
+
"defaultFirstPartyMcpTools" | "allowedFirstPartyMcpTools" | "artifactMaterializerDeployed"
|
|
4424
|
+
>;
|
|
4425
|
+
|
|
4426
|
+
const EDITABLE_ARTIFACT_EXPORT_TOOLS: readonly FirstPartyMcpToolNameType[] = [
|
|
4427
|
+
"editable_artifact_export",
|
|
4428
|
+
"editable_artifact_export_status",
|
|
4429
|
+
];
|
|
4430
|
+
|
|
4431
|
+
/**
|
|
4432
|
+
* First-party tools whose backing workload this deployment does not run. They
|
|
4433
|
+
* are absent from the ceiling (never offered) and an explicit request for one
|
|
4434
|
+
* is dropped rather than rejected: it is a deployment fact, not a caller error.
|
|
4435
|
+
*/
|
|
4436
|
+
export function deploymentUnavailableFirstPartyMcpTools(
|
|
4437
|
+
settings: Pick<Settings, "artifactMaterializerDeployed">,
|
|
4438
|
+
): ReadonlySet<FirstPartyMcpToolNameType> {
|
|
4439
|
+
return new Set(settings.artifactMaterializerDeployed ? [] : EDITABLE_ARTIFACT_EXPORT_TOOLS);
|
|
4440
|
+
}
|
|
4441
|
+
|
|
3986
4442
|
/** Resolve the deployment's session-tool defaults and hard execution ceiling. */
|
|
3987
4443
|
export function resolveFirstPartyMcpToolPolicy(
|
|
3988
|
-
settings:
|
|
4444
|
+
settings: FirstPartyMcpToolPolicySettings,
|
|
3989
4445
|
): FirstPartyMcpToolPolicy {
|
|
4446
|
+
const unavailable = deploymentUnavailableFirstPartyMcpTools(settings);
|
|
3990
4447
|
const allowed = currentAgentLearningToolSelection(
|
|
3991
4448
|
settings.allowedFirstPartyMcpTools ?? [...FIRST_PARTY_MCP_TOOL_NAMES],
|
|
3992
|
-
).filter((tool) => !isRetiredNativeAtlassianTool(tool));
|
|
4449
|
+
).filter((tool) => !isRetiredNativeAtlassianTool(tool) && !unavailable.has(tool));
|
|
3993
4450
|
const allowedSet = new Set(allowed);
|
|
3994
4451
|
const defaults = currentAgentLearningToolSelection(
|
|
3995
4452
|
settings.defaultFirstPartyMcpTools ?? [...DEFAULT_FIRST_PARTY_MCP_TOOLS],
|
|
@@ -4002,7 +4459,7 @@ export function resolveFirstPartyMcpToolPolicy(
|
|
|
4002
4459
|
|
|
4003
4460
|
/** Apply the deployment ceiling to an existing durable session selection. */
|
|
4004
4461
|
export function allowedFirstPartyMcpToolsForSession(
|
|
4005
|
-
settings:
|
|
4462
|
+
settings: FirstPartyMcpToolPolicySettings,
|
|
4006
4463
|
selected: readonly FirstPartyMcpToolNameType[] | null | undefined,
|
|
4007
4464
|
): FirstPartyMcpToolNameType[] {
|
|
4008
4465
|
const policy = resolveFirstPartyMcpToolPolicy(settings);
|
|
@@ -5424,6 +5881,71 @@ function matchesAdditiveCapabilityDefinitionVersion(
|
|
|
5424
5881
|
return false;
|
|
5425
5882
|
}
|
|
5426
5883
|
|
|
5884
|
+
/** The one pre-enablement hosted web-search declaration an operator may upgrade from. */
|
|
5885
|
+
function webSearchPreEnablementState(): CapabilityStateV1 {
|
|
5886
|
+
return { upstream: "unknown", runnable: false };
|
|
5887
|
+
}
|
|
5888
|
+
|
|
5889
|
+
function matchesWebSearchEnablementDefinitionVersion(
|
|
5890
|
+
model: ConfiguredModel,
|
|
5891
|
+
provider: ResolvedModelProvider,
|
|
5892
|
+
policy: TurnExecutionPolicyV1,
|
|
5893
|
+
): boolean {
|
|
5894
|
+
// An operator turning on hosted web search for an existing model changes
|
|
5895
|
+
// only capabilities.hostedTools.webSearch from the exact unknown/off
|
|
5896
|
+
// declaration to a runnable one. Reconstruct that single historical
|
|
5897
|
+
// declaration and require every other current field to reproduce the frozen
|
|
5898
|
+
// digest; never ignore the digest. Turning web search off, or changing any
|
|
5899
|
+
// other capability, still fails closed. Do not compose this with the
|
|
5900
|
+
// latency/input-modality subsets or the wire-profile, implicit-caching, or
|
|
5901
|
+
// Claude-accounting migration exceptions.
|
|
5902
|
+
if (!model.capabilities.hostedTools.webSearch.runnable) return false;
|
|
5903
|
+
const { definitionVersion: _definitionVersion, ...modelWithoutVersion } = model;
|
|
5904
|
+
const capabilities = {
|
|
5905
|
+
...model.capabilities,
|
|
5906
|
+
hostedTools: { ...model.capabilities.hostedTools, webSearch: webSearchPreEnablementState() },
|
|
5907
|
+
};
|
|
5908
|
+
return (
|
|
5909
|
+
policy.definitionVersion ===
|
|
5910
|
+
definitionVersionFor({ ...modelWithoutVersion, capabilities }, provider)
|
|
5911
|
+
);
|
|
5912
|
+
}
|
|
5913
|
+
|
|
5914
|
+
/**
|
|
5915
|
+
* The executable model an accepted turn runs: the current definition, except
|
|
5916
|
+
* that a turn frozen before hosted web search was enabled keeps its frozen
|
|
5917
|
+
* tool set (no web_search) on every recovery attempt. Only the next accepted
|
|
5918
|
+
* logical turn resolves the newly enabled tool. Call only with a policy that
|
|
5919
|
+
* already passed assertTurnExecutionPolicyMatchesConfigV1.
|
|
5920
|
+
*/
|
|
5921
|
+
export function configuredModelForAcceptedTurnExecutionPolicy(
|
|
5922
|
+
model: ConfiguredModel,
|
|
5923
|
+
provider: ResolvedModelProvider,
|
|
5924
|
+
policy: TurnExecutionPolicyV1,
|
|
5925
|
+
): ConfiguredModel {
|
|
5926
|
+
if (
|
|
5927
|
+
policy.definitionVersion === model.definitionVersion ||
|
|
5928
|
+
// Runtime test doubles may resolve a partial shape; a model without a
|
|
5929
|
+
// runnable web-search declaration has nothing to withhold.
|
|
5930
|
+
model.capabilities?.hostedTools?.webSearch?.runnable !== true ||
|
|
5931
|
+
!matchesWebSearchEnablementDefinitionVersion(model, provider, policy)
|
|
5932
|
+
) {
|
|
5933
|
+
return model;
|
|
5934
|
+
}
|
|
5935
|
+
return {
|
|
5936
|
+
...model,
|
|
5937
|
+
capabilities: {
|
|
5938
|
+
...model.capabilities,
|
|
5939
|
+
hostedTools: {
|
|
5940
|
+
...model.capabilities.hostedTools,
|
|
5941
|
+
webSearch: webSearchPreEnablementState(),
|
|
5942
|
+
},
|
|
5943
|
+
},
|
|
5944
|
+
hostedWebSearch: false,
|
|
5945
|
+
definitionVersion: policy.definitionVersion,
|
|
5946
|
+
};
|
|
5947
|
+
}
|
|
5948
|
+
|
|
5427
5949
|
/**
|
|
5428
5950
|
* The built-in provider's stable id: "openai" on the OpenAI platform, "azure"
|
|
5429
5951
|
* on Azure. Exported because the workspace model-policy gate must attribute
|
|
@@ -6243,7 +6765,8 @@ export function assertTurnExecutionPolicyMatchesConfigV1(
|
|
|
6243
6765
|
parsed.definitionVersion === legacyImplicitOpenAiDefinitionVersion ||
|
|
6244
6766
|
parsed.definitionVersion ===
|
|
6245
6767
|
legacyCodexAstraImplicitCachingDefinitionVersionFor(resolved.model, resolved.provider) ||
|
|
6246
|
-
matchesAdditiveCapabilityDefinitionVersion(resolved.model, resolved.provider, parsed)
|
|
6768
|
+
matchesAdditiveCapabilityDefinitionVersion(resolved.model, resolved.provider, parsed) ||
|
|
6769
|
+
matchesWebSearchEnablementDefinitionVersion(resolved.model, resolved.provider, parsed);
|
|
6247
6770
|
const identityMismatched =
|
|
6248
6771
|
parsed.providerId !== resolved.provider.id ||
|
|
6249
6772
|
parsed.upstreamModelId !== resolved.model.upstreamModelId ||
|
|
@@ -6258,7 +6781,11 @@ export function assertTurnExecutionPolicyMatchesConfigV1(
|
|
|
6258
6781
|
if (!definitionVersionMatches && !legacyClaudeAccountingMatches) {
|
|
6259
6782
|
throw new TurnExecutionPolicyDefinitionMismatchError();
|
|
6260
6783
|
}
|
|
6261
|
-
return {
|
|
6784
|
+
return {
|
|
6785
|
+
policy: parsed,
|
|
6786
|
+
provider: resolved.provider,
|
|
6787
|
+
model: configuredModelForAcceptedTurnExecutionPolicy(resolved.model, resolved.provider, parsed),
|
|
6788
|
+
};
|
|
6262
6789
|
}
|
|
6263
6790
|
|
|
6264
6791
|
/**
|
|
@@ -8370,6 +8897,14 @@ function validateSettings(settings: Settings, source: NodeJS.ProcessEnv = proces
|
|
|
8370
8897
|
);
|
|
8371
8898
|
}
|
|
8372
8899
|
parseExposedPorts(settings.dockerExposedPorts);
|
|
8900
|
+
// Malformed voice-input pricing deliberately does not fail boot: every
|
|
8901
|
+
// process shares this config, and a voice-only typo must not crash-loop
|
|
8902
|
+
// workers. The provider is withheld and the API logs voiceInputPricingIssues.
|
|
8903
|
+
parseRealtimeVoicePricingJson(settings.azureLivePricingJson, "OPENGENI_AZURE_LIVE_PRICING_JSON");
|
|
8904
|
+
parseRealtimeVoicePricingTableJson(
|
|
8905
|
+
settings.aiGatewayRealtimePricingJson,
|
|
8906
|
+
"OPENGENI_AI_GATEWAY_REALTIME_PRICING_JSON",
|
|
8907
|
+
);
|
|
8373
8908
|
sandboxEnvironmentVariableNames(settings);
|
|
8374
8909
|
sandboxLifecycleHookIds(settings);
|
|
8375
8910
|
// Fail fast on a malformed warm-rate table (P2.1).
|