@sagentlab/navarch-runtime 0.1.177 → 0.1.178
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.
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Reserved provider environment names (docs/navarch/custom-provider-endpoints.md § 3.3.1).
|
|
3
|
+
//
|
|
4
|
+
// Mirrors lib/navarch/provider-secret-names.ts in the control plane, which this
|
|
5
|
+
// standalone package cannot import. The conversion must stay identical to the
|
|
6
|
+
// one in `toEnvMap` (session.cts); a root test
|
|
7
|
+
// (lib/navarch/__tests__/provider-secret-names.test.ts) runs both copies and
|
|
8
|
+
// `toEnvMap` on the same inputs.
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ENDPOINT_PROTECTED_ENV_NAMES = void 0;
|
|
11
|
+
exports.providerSecretEnvName = providerSecretEnvName;
|
|
12
|
+
exports.isProtectedProviderSecret = isProtectedProviderSecret;
|
|
13
|
+
/** Environment names the custom endpoint sets. No user secret may produce one. */
|
|
14
|
+
exports.ENDPOINT_PROTECTED_ENV_NAMES = Object.freeze([
|
|
15
|
+
"ANTHROPIC_BASE_URL",
|
|
16
|
+
"OPENAI_BASE_URL",
|
|
17
|
+
"ANTHROPIC_MODEL",
|
|
18
|
+
"ANTHROPIC_AUTH_TOKEN",
|
|
19
|
+
]);
|
|
20
|
+
/** The environment name `toEnvMap` gives a secret named `name`. */
|
|
21
|
+
function providerSecretEnvName(name) {
|
|
22
|
+
return name.toUpperCase().replace(/[^A-Z0-9_]/g, "_");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* True when a user secret named `name` must be refused because its environment
|
|
26
|
+
* name is a protected provider name. On managed machines pass the managed
|
|
27
|
+
* provider secret names; their converted forms are protected too.
|
|
28
|
+
*/
|
|
29
|
+
function isProtectedProviderSecret(name, managedProviderNames = []) {
|
|
30
|
+
const protectedNames = new Set([
|
|
31
|
+
...exports.ENDPOINT_PROTECTED_ENV_NAMES,
|
|
32
|
+
...Array.from(managedProviderNames, providerSecretEnvName),
|
|
33
|
+
]);
|
|
34
|
+
return protectedNames.has(providerSecretEnvName(name));
|
|
35
|
+
}
|
package/package.json
CHANGED