@wopr-network/platform-core 1.52.0 → 1.54.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/auth/better-auth.js
CHANGED
|
@@ -144,6 +144,11 @@ function authOptions(cfg) {
|
|
|
144
144
|
baseURL,
|
|
145
145
|
basePath,
|
|
146
146
|
socialProviders: resolveSocialProviders(cfg),
|
|
147
|
+
user: {
|
|
148
|
+
additionalFields: {
|
|
149
|
+
role: { type: "string", defaultValue: "user", input: false },
|
|
150
|
+
},
|
|
151
|
+
},
|
|
147
152
|
account: {
|
|
148
153
|
accountLinking: {
|
|
149
154
|
enabled: true,
|
package/dist/gateway/proxy.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ export interface ProxyDeps {
|
|
|
25
25
|
graceBufferCents?: number;
|
|
26
26
|
providers: ProviderConfig;
|
|
27
27
|
defaultModel?: string;
|
|
28
|
+
/** Dynamic model resolver — called per-request, overrides defaultModel. Return null to use defaultModel fallback. */
|
|
29
|
+
resolveDefaultModel?: () => string | null;
|
|
28
30
|
defaultMargin: number;
|
|
29
31
|
fetchFn: FetchFn;
|
|
30
32
|
arbitrageRouter?: import("../monetization/arbitrage/router.js").ArbitrageRouter;
|
package/dist/gateway/proxy.js
CHANGED
|
@@ -53,6 +53,7 @@ export function buildProxyDeps(config) {
|
|
|
53
53
|
graceBufferCents: config.graceBufferCents,
|
|
54
54
|
providers: config.providers,
|
|
55
55
|
defaultModel: config.defaultModel,
|
|
56
|
+
resolveDefaultModel: config.resolveDefaultModel,
|
|
56
57
|
defaultMargin: config.defaultMargin ?? DEFAULT_MARGIN,
|
|
57
58
|
fetchFn: config.fetchFn ?? fetch,
|
|
58
59
|
arbitrageRouter: config.arbitrageRouter,
|
|
@@ -113,12 +114,13 @@ export function chatCompletions(deps) {
|
|
|
113
114
|
let isStreaming = false;
|
|
114
115
|
let requestModel;
|
|
115
116
|
let parsedBody;
|
|
117
|
+
// Resolve the enforced model once — dynamic DB resolver takes priority over static env var.
|
|
118
|
+
const enforcedModel = deps.resolveDefaultModel?.() ?? deps.defaultModel ?? null;
|
|
116
119
|
try {
|
|
117
120
|
parsedBody = JSON.parse(rawBody);
|
|
118
121
|
isStreaming = parsedBody?.stream === true;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
parsedBody.model = deps.defaultModel;
|
|
122
|
+
if (enforcedModel && parsedBody) {
|
|
123
|
+
parsedBody.model = enforcedModel;
|
|
122
124
|
}
|
|
123
125
|
requestModel = parsedBody?.model;
|
|
124
126
|
}
|
|
@@ -126,7 +128,7 @@ export function chatCompletions(deps) {
|
|
|
126
128
|
// Not valid JSON, assume non-streaming
|
|
127
129
|
}
|
|
128
130
|
// Re-serialize if model was overridden, otherwise forward raw body.
|
|
129
|
-
const body =
|
|
131
|
+
const body = enforcedModel && parsedBody ? JSON.stringify(parsedBody) : rawBody;
|
|
130
132
|
deps.metrics?.recordGatewayRequest("chat-completions");
|
|
131
133
|
// WOP-746: Arbitrage routing for non-streaming chat completions.
|
|
132
134
|
// Mirrors the TTS arbitrage pattern. When arbitrageRouter is present and
|
package/dist/gateway/types.d.ts
CHANGED
|
@@ -102,10 +102,11 @@ export interface ProviderConfig {
|
|
|
102
102
|
}
|
|
103
103
|
/** Full gateway configuration. */
|
|
104
104
|
export interface GatewayConfig {
|
|
105
|
-
/**
|
|
106
|
-
* When set, the gateway rewrites body.model before forwarding to the upstream provider.
|
|
107
|
-
* This enforces "we serve one model" pricing — clients don't get to choose. */
|
|
105
|
+
/** Static model override — rewrites body.model before forwarding to upstream. */
|
|
108
106
|
defaultModel?: string;
|
|
107
|
+
/** Dynamic model resolver — called per-request, takes priority over defaultModel.
|
|
108
|
+
* Return null to fall back to defaultModel / client-specified. */
|
|
109
|
+
resolveDefaultModel?: () => string | null;
|
|
109
110
|
/** MeterEmitter instance for usage tracking */
|
|
110
111
|
meter: MeterEmitter;
|
|
111
112
|
/** BudgetChecker instance for pre-call budget validation */
|
package/package.json
CHANGED
package/src/auth/better-auth.ts
CHANGED
|
@@ -212,6 +212,11 @@ function authOptions(cfg: BetterAuthConfig): BetterAuthOptions {
|
|
|
212
212
|
baseURL,
|
|
213
213
|
basePath,
|
|
214
214
|
socialProviders: resolveSocialProviders(cfg),
|
|
215
|
+
user: {
|
|
216
|
+
additionalFields: {
|
|
217
|
+
role: { type: "string", defaultValue: "user", input: false },
|
|
218
|
+
},
|
|
219
|
+
},
|
|
215
220
|
account: {
|
|
216
221
|
accountLinking: {
|
|
217
222
|
enabled: true,
|
package/src/gateway/proxy.ts
CHANGED
|
@@ -68,6 +68,8 @@ export interface ProxyDeps {
|
|
|
68
68
|
graceBufferCents?: number;
|
|
69
69
|
providers: ProviderConfig;
|
|
70
70
|
defaultModel?: string;
|
|
71
|
+
/** Dynamic model resolver — called per-request, overrides defaultModel. Return null to use defaultModel fallback. */
|
|
72
|
+
resolveDefaultModel?: () => string | null;
|
|
71
73
|
defaultMargin: number;
|
|
72
74
|
fetchFn: FetchFn;
|
|
73
75
|
arbitrageRouter?: import("../monetization/arbitrage/router.js").ArbitrageRouter;
|
|
@@ -93,6 +95,7 @@ export function buildProxyDeps(config: GatewayConfig): ProxyDeps {
|
|
|
93
95
|
graceBufferCents: config.graceBufferCents,
|
|
94
96
|
providers: config.providers,
|
|
95
97
|
defaultModel: config.defaultModel,
|
|
98
|
+
resolveDefaultModel: config.resolveDefaultModel,
|
|
96
99
|
defaultMargin: config.defaultMargin ?? DEFAULT_MARGIN,
|
|
97
100
|
fetchFn: config.fetchFn ?? fetch,
|
|
98
101
|
arbitrageRouter: config.arbitrageRouter,
|
|
@@ -180,19 +183,20 @@ export function chatCompletions(deps: ProxyDeps) {
|
|
|
180
183
|
temperature?: number;
|
|
181
184
|
}
|
|
182
185
|
| undefined;
|
|
186
|
+
// Resolve the enforced model once — dynamic DB resolver takes priority over static env var.
|
|
187
|
+
const enforcedModel = deps.resolveDefaultModel?.() ?? deps.defaultModel ?? null;
|
|
183
188
|
try {
|
|
184
189
|
parsedBody = JSON.parse(rawBody) as typeof parsedBody;
|
|
185
190
|
isStreaming = parsedBody?.stream === true;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
parsedBody.model = deps.defaultModel;
|
|
191
|
+
if (enforcedModel && parsedBody) {
|
|
192
|
+
parsedBody.model = enforcedModel;
|
|
189
193
|
}
|
|
190
194
|
requestModel = parsedBody?.model;
|
|
191
195
|
} catch {
|
|
192
196
|
// Not valid JSON, assume non-streaming
|
|
193
197
|
}
|
|
194
198
|
// Re-serialize if model was overridden, otherwise forward raw body.
|
|
195
|
-
const body =
|
|
199
|
+
const body = enforcedModel && parsedBody ? JSON.stringify(parsedBody) : rawBody;
|
|
196
200
|
|
|
197
201
|
deps.metrics?.recordGatewayRequest("chat-completions");
|
|
198
202
|
|
package/src/gateway/types.ts
CHANGED
|
@@ -98,10 +98,11 @@ export interface ProviderConfig {
|
|
|
98
98
|
|
|
99
99
|
/** Full gateway configuration. */
|
|
100
100
|
export interface GatewayConfig {
|
|
101
|
-
/**
|
|
102
|
-
* When set, the gateway rewrites body.model before forwarding to the upstream provider.
|
|
103
|
-
* This enforces "we serve one model" pricing — clients don't get to choose. */
|
|
101
|
+
/** Static model override — rewrites body.model before forwarding to upstream. */
|
|
104
102
|
defaultModel?: string;
|
|
103
|
+
/** Dynamic model resolver — called per-request, takes priority over defaultModel.
|
|
104
|
+
* Return null to fall back to defaultModel / client-specified. */
|
|
105
|
+
resolveDefaultModel?: () => string | null;
|
|
105
106
|
/** MeterEmitter instance for usage tracking */
|
|
106
107
|
meter: MeterEmitter;
|
|
107
108
|
/** BudgetChecker instance for pre-call budget validation */
|