@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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credit pricing for deployment-funded live (speech-to-speech) voice.
|
|
3
|
+
*
|
|
4
|
+
* Live voice is metered by server-observed connection time, billed per started
|
|
5
|
+
* minute. Prices are deployment configuration, never code defaults: when credit
|
|
6
|
+
* billing is active, a deployment-funded voice model without a configured price
|
|
7
|
+
* is not offered and cannot be started.
|
|
8
|
+
*/
|
|
9
|
+
export type RealtimeVoicePricing = {
|
|
10
|
+
/** Upstream cost of one minute of live voice, in USD micros. */
|
|
11
|
+
microsPerMinute: number;
|
|
12
|
+
/** Opengeni margin in basis points added on top of the upstream cost. */
|
|
13
|
+
marginBps?: number | undefined;
|
|
14
|
+
};
|
|
15
|
+
/** Model id of the deployment-hosted Azure GPT Live voice. */
|
|
16
|
+
export declare const AZURE_LIVE_REALTIME_MODEL_ID: "opengeni-azure/gpt-live-1";
|
|
17
|
+
/** One live-voice price, e.g. `{"microsPerMinute":50000,"marginBps":500}`. */
|
|
18
|
+
export declare function parseRealtimeVoicePricingJson(raw: string | undefined, env?: string): RealtimeVoicePricing | null;
|
|
19
|
+
/**
|
|
20
|
+
* Prices keyed by upstream AI Gateway realtime model id, e.g.
|
|
21
|
+
* `{"openai/gpt-realtime-2.1":{"microsPerMinute":120000,"marginBps":500}}`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseRealtimeVoicePricingTableJson(raw: string | undefined, env?: string): Record<string, RealtimeVoicePricing>;
|
|
24
|
+
/** Credit price of one started minute, after margin, rounded up to whole micros. */
|
|
25
|
+
export declare function realtimeVoiceMinuteCreditMicros(pricing: RealtimeVoicePricing): {
|
|
26
|
+
providerCostMicros: number;
|
|
27
|
+
creditCostMicros: number;
|
|
28
|
+
};
|
|
29
|
+
/** Billed minutes for a server-observed interval: every started minute, at least one. */
|
|
30
|
+
export declare function realtimeVoiceStartedMinutes(startedAt: Date, observedUntil: Date): number;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Provider-agnostic web search: the deployment-funded `web_search` and
|
|
4
|
+
* `web_fetch` agent tools.
|
|
5
|
+
*
|
|
6
|
+
* Hosted search (the provider-executed `web_search` tool of OpenAI, Azure,
|
|
7
|
+
* Codex and SuperGrok) follows the model catalog. Provider search is a
|
|
8
|
+
* separate, deployment-configured HTTP provider that Opengeni calls from the
|
|
9
|
+
* worker. It is inert until `OPENGENI_WEB_SEARCH_PROVIDER` names a provider
|
|
10
|
+
* with its credentials, and it is offered only where the turn has no hosted
|
|
11
|
+
* search unless the operator selects `replace`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const WEB_SEARCH_PROVIDER_IDS: readonly ["tinyfish", "exa", "tavily", "firecrawl", "brave", "jina", "searxng"];
|
|
14
|
+
export type WebSearchProviderId = (typeof WEB_SEARCH_PROVIDER_IDS)[number];
|
|
15
|
+
/** Model-visible names of the provider tools. */
|
|
16
|
+
export declare const WEB_SEARCH_TOOL_NAME = "web_search";
|
|
17
|
+
export declare const WEB_FETCH_TOOL_NAME = "web_fetch";
|
|
18
|
+
export type WebSearchProviderToolName = typeof WEB_SEARCH_TOOL_NAME | typeof WEB_FETCH_TOOL_NAME;
|
|
19
|
+
/**
|
|
20
|
+
* `fallback` (default): offer provider tools only to turns without hosted
|
|
21
|
+
* search. `replace`: offer them to every turn and withhold the SDK-hosted
|
|
22
|
+
* `web_search` tool. SuperGrok keeps its transport-level native search in
|
|
23
|
+
* both modes because Opengeni does not attach it as an agent tool.
|
|
24
|
+
*/
|
|
25
|
+
export declare const WebSearchProviderMode: z.ZodEnum<{
|
|
26
|
+
fallback: "fallback";
|
|
27
|
+
replace: "replace";
|
|
28
|
+
}>;
|
|
29
|
+
export type WebSearchProviderMode = z.infer<typeof WebSearchProviderMode>;
|
|
30
|
+
type ProviderTraits = {
|
|
31
|
+
search: boolean;
|
|
32
|
+
fetch: boolean;
|
|
33
|
+
/** Needs an API key for this operation. */
|
|
34
|
+
searchKey: boolean;
|
|
35
|
+
fetchKey: boolean;
|
|
36
|
+
/** Needs an explicit base URL (self-hosted). */
|
|
37
|
+
baseUrl: boolean;
|
|
38
|
+
};
|
|
39
|
+
/** What each adapter can do. Jina fetch works keyless at a low rate limit. */
|
|
40
|
+
export declare const WEB_SEARCH_PROVIDER_TRAITS: Readonly<Record<WebSearchProviderId, ProviderTraits>>;
|
|
41
|
+
/**
|
|
42
|
+
* Upstream list price of one call in integer USD micros, plus the Opengeni
|
|
43
|
+
* margin in basis points (500 = +5%, as for model pricing). Credit billing
|
|
44
|
+
* charges `ceil(providerCost * (10000 + marginBps) / 10000)` per call.
|
|
45
|
+
*/
|
|
46
|
+
export type WebSearchPricing = {
|
|
47
|
+
searchMicros: number;
|
|
48
|
+
fetchMicros: number;
|
|
49
|
+
marginBps?: number | undefined;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Built-in pay-as-you-go list prices (checked 2026-10). A provider response
|
|
53
|
+
* that reports its own dollar cost (Exa `costDollars`, Tavily `usage.credits`)
|
|
54
|
+
* bills that cost instead; an explicit `OPENGENI_WEB_SEARCH_PRICING_JSON`
|
|
55
|
+
* overrides both. Plan-dependent providers (Firecrawl) should set the JSON.
|
|
56
|
+
*/
|
|
57
|
+
export declare const DEFAULT_WEB_SEARCH_PRICING: Readonly<Record<WebSearchProviderId, WebSearchPricing>>;
|
|
58
|
+
/** Tavily's pay-as-you-go price of one credit, used for reported usage. */
|
|
59
|
+
export declare const TAVILY_CREDIT_MICROS = 8000;
|
|
60
|
+
export type WebSearchProviderEndpoint = {
|
|
61
|
+
provider: WebSearchProviderId;
|
|
62
|
+
apiKey: string | null;
|
|
63
|
+
baseUrl: string | null;
|
|
64
|
+
};
|
|
65
|
+
export type WebSearchProviderConfig = {
|
|
66
|
+
mode: WebSearchProviderMode;
|
|
67
|
+
search: WebSearchProviderEndpoint;
|
|
68
|
+
/** Null when no configured provider can fetch pages. */
|
|
69
|
+
fetch: WebSearchProviderEndpoint | null;
|
|
70
|
+
/** Explicit operator price, else null (built-in or provider-reported). */
|
|
71
|
+
pricingOverride: WebSearchPricing | null;
|
|
72
|
+
timeoutMs: number;
|
|
73
|
+
};
|
|
74
|
+
export type WebSearchSettings = {
|
|
75
|
+
webSearchEnabled: boolean;
|
|
76
|
+
webSearchProvider?: string | undefined;
|
|
77
|
+
webSearchApiKey?: string | undefined;
|
|
78
|
+
webSearchBaseUrl?: string | undefined;
|
|
79
|
+
webFetchProvider?: string | undefined;
|
|
80
|
+
webFetchApiKey?: string | undefined;
|
|
81
|
+
webFetchBaseUrl?: string | undefined;
|
|
82
|
+
webSearchProviderMode?: string | undefined;
|
|
83
|
+
webSearchPricingJson?: string | undefined;
|
|
84
|
+
webSearchRequestTimeoutMs?: number | undefined;
|
|
85
|
+
};
|
|
86
|
+
export type WebSearchProviderResolution = {
|
|
87
|
+
status: "off";
|
|
88
|
+
} | {
|
|
89
|
+
status: "invalid";
|
|
90
|
+
reason: string;
|
|
91
|
+
} | {
|
|
92
|
+
status: "configured";
|
|
93
|
+
config: WebSearchProviderConfig;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Resolve the deployment's provider search. `off` is the default and also
|
|
97
|
+
* applies when `OPENGENI_WEB_SEARCH_ENABLED=false` (the server-wide web search
|
|
98
|
+
* switch). `invalid` means an operator named a provider but the configuration
|
|
99
|
+
* cannot work; the tools stay unoffered and the worker logs the reason.
|
|
100
|
+
*/
|
|
101
|
+
export declare function resolveWebSearchProvider(settings: WebSearchSettings): WebSearchProviderResolution;
|
|
102
|
+
/** The configured provider, or null when off or invalid. */
|
|
103
|
+
export declare function webSearchProviderConfig(settings: WebSearchSettings): WebSearchProviderConfig | null;
|
|
104
|
+
/**
|
|
105
|
+
* The single web-search plan for one turn, shared by the worker (which tools
|
|
106
|
+
* it attaches) and the API's effective-tools projection (what it reports).
|
|
107
|
+
*
|
|
108
|
+
* `hostedWebSearch` is whether the resolved model attaches the SDK-hosted
|
|
109
|
+
* `web_search` tool. `transportHostedSearch` is true for providers whose native
|
|
110
|
+
* search is added by the transport rather than as an agent tool (SuperGrok).
|
|
111
|
+
*/
|
|
112
|
+
export declare function webSearchToolPlan(settings: WebSearchSettings, turn: {
|
|
113
|
+
hostedWebSearch: boolean;
|
|
114
|
+
transportHostedSearch?: boolean;
|
|
115
|
+
}): {
|
|
116
|
+
hostedWebSearch: boolean;
|
|
117
|
+
providerTools: WebSearchProviderToolName[];
|
|
118
|
+
};
|
|
119
|
+
/** Upstream price for one call before any provider-reported cost. */
|
|
120
|
+
export declare function webSearchCallPricing(config: WebSearchProviderConfig, operation: "search" | "fetch"): {
|
|
121
|
+
providerMicros: number;
|
|
122
|
+
marginBps: number;
|
|
123
|
+
explicit: boolean;
|
|
124
|
+
};
|
|
125
|
+
/** Credit cost of a provider cost after margin, rounded up to whole micros. */
|
|
126
|
+
export declare function webSearchCreditMicros(providerMicros: number, marginBps: number): number;
|
|
127
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeni/config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "OpenGeni runtime configuration: settings resolution, deployment knobs, and config validation shared across the server packages.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"prepublishOnly": "bash ../../scripts/prepublish-guard"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@opengeni/codex": "1.
|
|
37
|
-
"@opengeni/contracts": "1.
|
|
38
|
-
"@opengeni/xai-subscription": "1.
|
|
36
|
+
"@opengeni/codex": "1.4.0",
|
|
37
|
+
"@opengeni/contracts": "1.4.0",
|
|
38
|
+
"@opengeni/xai-subscription": "1.4.0",
|
|
39
39
|
"zod": "^4.2.1"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|