@opengeni/config 0.8.1 → 0.9.3
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 +14 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +72 -0
package/dist/index.d.ts
CHANGED
|
@@ -88,6 +88,12 @@ declare const SettingsSchema: z.ZodObject<{
|
|
|
88
88
|
observabilityMetricsEnabled: z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>;
|
|
89
89
|
observabilityOtlpEndpoint: z.ZodOptional<z.ZodString>;
|
|
90
90
|
observabilityOtlpHeaders: z.ZodDefault<z.ZodString>;
|
|
91
|
+
analyticsEnabled: z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>;
|
|
92
|
+
analyticsConsentRequired: z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>;
|
|
93
|
+
analyticsReoClientId: z.ZodOptional<z.ZodString>;
|
|
94
|
+
analyticsPosthogProjectKey: z.ZodOptional<z.ZodString>;
|
|
95
|
+
analyticsPosthogHost: z.ZodOptional<z.ZodString>;
|
|
96
|
+
analyticsGa4MeasurementId: z.ZodOptional<z.ZodString>;
|
|
91
97
|
publicBaseUrl: z.ZodOptional<z.ZodString>;
|
|
92
98
|
webBaseUrl: z.ZodOptional<z.ZodString>;
|
|
93
99
|
agentReleasesBaseUrl: z.ZodDefault<z.ZodString>;
|
|
@@ -130,6 +136,7 @@ declare const SettingsSchema: z.ZodObject<{
|
|
|
130
136
|
googleDriveClientId: z.ZodOptional<z.ZodString>;
|
|
131
137
|
googleDriveClientSecret: z.ZodOptional<z.ZodString>;
|
|
132
138
|
maxNestedAgentDepth: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
139
|
+
socialOauthClientsJson: z.ZodDefault<z.ZodString>;
|
|
133
140
|
goalMaxAutoContinuations: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
134
141
|
goalNoProgressLimit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
135
142
|
agentMaxModelCallsPerTurn: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
@@ -1241,6 +1248,13 @@ export declare function sandboxWarmRateMicrosPerSecond(settings: Settings, backe
|
|
|
1241
1248
|
*/
|
|
1242
1249
|
export declare function parseModelProvidersJson(raw: string): RegistryProvider[];
|
|
1243
1250
|
export declare function parseIntegrationsOauthClientsJson(raw: string | undefined): Record<string, IntegrationOAuthClientConfig>;
|
|
1251
|
+
export declare const SocialOAuthClientConfigSchema: z.ZodObject<{
|
|
1252
|
+
clientId: z.ZodString;
|
|
1253
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
1254
|
+
}, z.core.$strip>;
|
|
1255
|
+
export type SocialOAuthClientConfig = z.infer<typeof SocialOAuthClientConfigSchema>;
|
|
1256
|
+
declare const SOCIAL_OAUTH_PROVIDER_IDS: readonly ["x", "reddit"];
|
|
1257
|
+
export declare function parseSocialOauthClientsJson(raw: string | undefined): Partial<Record<(typeof SOCIAL_OAUTH_PROVIDER_IDS)[number], SocialOAuthClientConfig>>;
|
|
1244
1258
|
export declare function parseStaticUsageLimitsJson(raw: string): StaticUsageLimitsConfig;
|
|
1245
1259
|
export declare function parseStaticEntitlementsJson(raw: string): EntitlementsConfig;
|
|
1246
1260
|
/**
|
package/dist/index.js
CHANGED
|
@@ -175,6 +175,12 @@ var SettingsSchema = z.object({
|
|
|
175
175
|
observabilityMetricsEnabled: EnvBoolean.default(true),
|
|
176
176
|
observabilityOtlpEndpoint: z.string().url().optional(),
|
|
177
177
|
observabilityOtlpHeaders: z.string().default(""),
|
|
178
|
+
analyticsEnabled: EnvBoolean.default(false),
|
|
179
|
+
analyticsConsentRequired: EnvBoolean.default(true),
|
|
180
|
+
analyticsReoClientId: z.string().max(128).regex(/^[A-Za-z0-9_-]+$/u).optional(),
|
|
181
|
+
analyticsPosthogProjectKey: z.string().min(1).max(256).optional(),
|
|
182
|
+
analyticsPosthogHost: z.string().url().max(2048).optional(),
|
|
183
|
+
analyticsGa4MeasurementId: z.string().max(32).regex(/^G-[A-Z0-9]+$/u).optional(),
|
|
178
184
|
publicBaseUrl: z.string().url().optional(),
|
|
179
185
|
// Browser origin when the web app and API use separate origins in local
|
|
180
186
|
// development. Production normally leaves this unset and uses publicBaseUrl.
|
|
@@ -223,6 +229,9 @@ var SettingsSchema = z.object({
|
|
|
223
229
|
// Undefined is meaningful: the migration boundary persists the product
|
|
224
230
|
// default of 3 when no deployment override is supplied.
|
|
225
231
|
maxNestedAgentDepth: z.coerce.number().int().nonnegative().max(MAX_NESTED_AGENT_DEPTH).optional(),
|
|
232
|
+
// Operator OAuth apps for first-party social connectors, keyed by provider
|
|
233
|
+
// id ("x", "reddit"): {"x":{"clientId":"...","clientSecret":"..."}}.
|
|
234
|
+
socialOauthClientsJson: z.string().default("{}"),
|
|
226
235
|
// Session goal guard rails. Goals are designed for runs that legitimately
|
|
227
236
|
// span days, so length is bounded by pathology detection (no-progress
|
|
228
237
|
// streaks, budget exhaustion), never by count. goalMaxAutoContinuations is
|
|
@@ -1218,6 +1227,12 @@ function getSettings() {
|
|
|
1218
1227
|
observabilityMetricsEnabled: optional("OPENGENI_OBSERVABILITY_METRICS_ENABLED"),
|
|
1219
1228
|
observabilityOtlpEndpoint: optional("OPENGENI_OTEL_EXPORTER_OTLP_ENDPOINT") ?? optional("OTEL_EXPORTER_OTLP_ENDPOINT"),
|
|
1220
1229
|
observabilityOtlpHeaders: optional("OPENGENI_OTEL_EXPORTER_OTLP_HEADERS") ?? optional("OTEL_EXPORTER_OTLP_HEADERS"),
|
|
1230
|
+
analyticsEnabled: optional("OPENGENI_ANALYTICS_ENABLED"),
|
|
1231
|
+
analyticsConsentRequired: optional("OPENGENI_ANALYTICS_CONSENT_REQUIRED"),
|
|
1232
|
+
analyticsReoClientId: optional("OPENGENI_ANALYTICS_REO_CLIENT_ID"),
|
|
1233
|
+
analyticsPosthogProjectKey: optional("OPENGENI_ANALYTICS_POSTHOG_PROJECT_KEY"),
|
|
1234
|
+
analyticsPosthogHost: optional("OPENGENI_ANALYTICS_POSTHOG_HOST"),
|
|
1235
|
+
analyticsGa4MeasurementId: optional("OPENGENI_ANALYTICS_GA4_MEASUREMENT_ID"),
|
|
1221
1236
|
publicBaseUrl: optional("OPENGENI_PUBLIC_BASE_URL"),
|
|
1222
1237
|
webBaseUrl: optional("OPENGENI_WEB_BASE_URL"),
|
|
1223
1238
|
agentReleasesBaseUrl: optional("OPENGENI_AGENT_RELEASES_BASE_URL"),
|
|
@@ -1247,6 +1262,7 @@ function getSettings() {
|
|
|
1247
1262
|
googleDriveClientId: optional("OPENGENI_GOOGLE_DRIVE_CLIENT_ID"),
|
|
1248
1263
|
googleDriveClientSecret: optional("OPENGENI_GOOGLE_DRIVE_CLIENT_SECRET"),
|
|
1249
1264
|
maxNestedAgentDepth: optional("OPENGENI_MAX_NESTED_AGENT_DEPTH"),
|
|
1265
|
+
socialOauthClientsJson: optional("OPENGENI_SOCIAL_OAUTH_CLIENTS_JSON"),
|
|
1250
1266
|
goalMaxAutoContinuations: optional("OPENGENI_GOAL_MAX_AUTO_CONTINUATIONS"),
|
|
1251
1267
|
goalNoProgressLimit: optional("OPENGENI_GOAL_NO_PROGRESS_LIMIT"),
|
|
1252
1268
|
agentMaxModelCallsPerTurn: optional("OPENGENI_AGENT_MAX_MODEL_CALLS_PER_TURN"),
|
|
@@ -2651,6 +2667,46 @@ function parseIntegrationsOauthClientsJson(raw) {
|
|
|
2651
2667
|
}
|
|
2652
2668
|
return out;
|
|
2653
2669
|
}
|
|
2670
|
+
var SocialOAuthClientConfigSchema = z.object({
|
|
2671
|
+
clientId: z.string().min(1),
|
|
2672
|
+
clientSecret: z.string().min(1).optional()
|
|
2673
|
+
});
|
|
2674
|
+
var SOCIAL_OAUTH_PROVIDER_IDS = ["x", "reddit"];
|
|
2675
|
+
function parseSocialOauthClientsJson(raw) {
|
|
2676
|
+
if (!raw?.trim() || raw.trim() === "{}") {
|
|
2677
|
+
return {};
|
|
2678
|
+
}
|
|
2679
|
+
let parsed;
|
|
2680
|
+
try {
|
|
2681
|
+
parsed = JSON.parse(raw);
|
|
2682
|
+
} catch (error) {
|
|
2683
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2684
|
+
throw new Error(`OPENGENI_SOCIAL_OAUTH_CLIENTS_JSON must be valid JSON: ${message}`, {
|
|
2685
|
+
cause: error
|
|
2686
|
+
});
|
|
2687
|
+
}
|
|
2688
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
2689
|
+
throw new Error(
|
|
2690
|
+
"OPENGENI_SOCIAL_OAUTH_CLIENTS_JSON must be a JSON object keyed by social provider id"
|
|
2691
|
+
);
|
|
2692
|
+
}
|
|
2693
|
+
const out = {};
|
|
2694
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
2695
|
+
if (!SOCIAL_OAUTH_PROVIDER_IDS.includes(key)) {
|
|
2696
|
+
throw new Error(
|
|
2697
|
+
`OPENGENI_SOCIAL_OAUTH_CLIENTS_JSON provider ${key} is not supported (expected: ${SOCIAL_OAUTH_PROVIDER_IDS.join(", ")})`
|
|
2698
|
+
);
|
|
2699
|
+
}
|
|
2700
|
+
const result = SocialOAuthClientConfigSchema.safeParse(value);
|
|
2701
|
+
if (!result.success) {
|
|
2702
|
+
throw new Error(
|
|
2703
|
+
`OPENGENI_SOCIAL_OAUTH_CLIENTS_JSON client for ${key} is invalid: ${result.error.message}`
|
|
2704
|
+
);
|
|
2705
|
+
}
|
|
2706
|
+
out[key] = result.data;
|
|
2707
|
+
}
|
|
2708
|
+
return out;
|
|
2709
|
+
}
|
|
2654
2710
|
function parseStaticUsageLimitsJson(raw) {
|
|
2655
2711
|
if (!raw.trim() || raw.trim() === "{}") {
|
|
2656
2712
|
return {};
|
|
@@ -2875,6 +2931,7 @@ function validateSettings(settings) {
|
|
|
2875
2931
|
}
|
|
2876
2932
|
}
|
|
2877
2933
|
parseIntegrationsOauthClientsJson(settings.integrationsOauthClientsJson);
|
|
2934
|
+
parseSocialOauthClientsJson(settings.socialOauthClientsJson);
|
|
2878
2935
|
if (settings.productAccessMode === "configured" && !["local", "test"].includes(settings.environment) && !settings.delegationSecret && !settings.authRequired) {
|
|
2879
2936
|
throw new Error(
|
|
2880
2937
|
"OPENGENI_PRODUCT_ACCESS_MODE=configured requires OPENGENI_DELEGATION_SECRET or OPENGENI_AUTH_REQUIRED=true outside local/test"
|
|
@@ -3180,6 +3237,7 @@ export {
|
|
|
3180
3237
|
ModelProviderApi,
|
|
3181
3238
|
RegistryProviderKind,
|
|
3182
3239
|
SANDBOX_REQUIRED_ENV,
|
|
3240
|
+
SocialOAuthClientConfigSchema,
|
|
3183
3241
|
applyGitAuthPointerEnvironment,
|
|
3184
3242
|
assertTurnExecutionPolicyMatchesConfigV1,
|
|
3185
3243
|
builtinProviderId,
|
|
@@ -3212,6 +3270,7 @@ export {
|
|
|
3212
3270
|
parseModelPricingJson,
|
|
3213
3271
|
parseModelProvidersJson,
|
|
3214
3272
|
parseSandboxWarmRateJson,
|
|
3273
|
+
parseSocialOauthClientsJson,
|
|
3215
3274
|
parseStaticEntitlementsJson,
|
|
3216
3275
|
parseStaticUsageLimitsJson,
|
|
3217
3276
|
policyProviderIdForModel,
|