@sahu-01/openpaw 1.0.7 → 1.0.9
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.js +34 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -230906,6 +230906,17 @@ var MessageSchema = import_zod5.z.object({
|
|
|
230906
230906
|
content: import_zod5.z.string(),
|
|
230907
230907
|
metadata: import_zod5.z.record(import_zod5.z.unknown()).optional()
|
|
230908
230908
|
});
|
|
230909
|
+
var PROVIDER_ENV_VARS = {
|
|
230910
|
+
google: ["GOOGLE_API_KEY", "GEMINI_API_KEY"],
|
|
230911
|
+
openrouter: ["OPENROUTER_API_KEY"],
|
|
230912
|
+
openai: ["OPENAI_API_KEY"],
|
|
230913
|
+
anthropic: ["ANTHROPIC_API_KEY"],
|
|
230914
|
+
cohere: ["COHERE_API_KEY"],
|
|
230915
|
+
mistral: ["MISTRAL_API_KEY"],
|
|
230916
|
+
groq: ["GROQ_API_KEY"],
|
|
230917
|
+
together: ["TOGETHER_API_KEY"],
|
|
230918
|
+
perplexity: ["PERPLEXITY_API_KEY"]
|
|
230919
|
+
};
|
|
230909
230920
|
async function findOpenClawBinary(openclawDir) {
|
|
230910
230921
|
const pathBinary = process.platform === "win32" ? "openclaw.cmd" : "openclaw";
|
|
230911
230922
|
const pathDirs = (process.env["PATH"] ?? "").split(process.platform === "win32" ? ";" : ":");
|
|
@@ -230949,16 +230960,19 @@ async function processAuthProfiles(profilePath, vault) {
|
|
|
230949
230960
|
for (const profileName of Object.keys(data.profiles)) {
|
|
230950
230961
|
const profile = data.profiles[profileName];
|
|
230951
230962
|
if (profile && typeof profile.key === "string") {
|
|
230963
|
+
const provider = typeof profile.provider === "string" ? profile.provider : void 0;
|
|
230952
230964
|
if (profile.key.startsWith("openpaw:vault:")) {
|
|
230953
230965
|
const credId = profile.key.replace("openpaw:vault:", "");
|
|
230954
230966
|
const envVarName = credIdToEnvVar(credId);
|
|
230955
|
-
envVarMap.set(envVarName, credId);
|
|
230956
|
-
profile.key
|
|
230967
|
+
envVarMap.set(envVarName, { credId, provider });
|
|
230968
|
+
delete profile.key;
|
|
230957
230969
|
modified = true;
|
|
230958
230970
|
} else if (profile.key.startsWith("${OPENPAW_") && profile.key.endsWith("}")) {
|
|
230959
230971
|
const envVarName = profile.key.slice(2, -1);
|
|
230960
230972
|
const credId = envVarName.replace("OPENPAW_", "").toLowerCase();
|
|
230961
|
-
envVarMap.set(envVarName, credId);
|
|
230973
|
+
envVarMap.set(envVarName, { credId, provider });
|
|
230974
|
+
delete profile.key;
|
|
230975
|
+
modified = true;
|
|
230962
230976
|
}
|
|
230963
230977
|
}
|
|
230964
230978
|
}
|
|
@@ -230995,23 +231009,34 @@ async function startGateway(config = {}) {
|
|
|
230995
231009
|
const allEnvVars = /* @__PURE__ */ new Map();
|
|
230996
231010
|
for (const profilePath of profileFiles) {
|
|
230997
231011
|
const envVars = await processAuthProfiles(profilePath, vault);
|
|
230998
|
-
for (const [envVarName,
|
|
230999
|
-
allEnvVars.set(envVarName,
|
|
231012
|
+
for (const [envVarName, credInfo] of envVars) {
|
|
231013
|
+
allEnvVars.set(envVarName, credInfo);
|
|
231000
231014
|
}
|
|
231001
231015
|
}
|
|
231002
231016
|
const childEnv = { ...process.env };
|
|
231003
231017
|
let credentialsLoaded = 0;
|
|
231004
|
-
|
|
231005
|
-
|
|
231018
|
+
let providerEnvVarsSet = 0;
|
|
231019
|
+
for (const [envVarName, credInfo] of allEnvVars) {
|
|
231020
|
+
const result = vault.get(credInfo.credId);
|
|
231006
231021
|
if (result) {
|
|
231007
231022
|
childEnv[envVarName] = result.value;
|
|
231008
231023
|
credentialsLoaded++;
|
|
231009
231024
|
console.log(` ${envVarName} \u2192 [secured]`);
|
|
231025
|
+
if (credInfo.provider) {
|
|
231026
|
+
const providerEnvVars = PROVIDER_ENV_VARS[credInfo.provider.toLowerCase()];
|
|
231027
|
+
if (providerEnvVars) {
|
|
231028
|
+
for (const providerEnvVar of providerEnvVars) {
|
|
231029
|
+
childEnv[providerEnvVar] = result.value;
|
|
231030
|
+
providerEnvVarsSet++;
|
|
231031
|
+
console.log(` ${providerEnvVar} \u2192 [secured] (${credInfo.provider})`);
|
|
231032
|
+
}
|
|
231033
|
+
}
|
|
231034
|
+
}
|
|
231010
231035
|
} else {
|
|
231011
|
-
console.warn(` Warning: Credential ${credId} not found in vault`);
|
|
231036
|
+
console.warn(` Warning: Credential ${credInfo.credId} not found in vault`);
|
|
231012
231037
|
}
|
|
231013
231038
|
}
|
|
231014
|
-
console.log(`Loaded ${credentialsLoaded} credential(s)
|
|
231039
|
+
console.log(`Loaded ${credentialsLoaded} credential(s), set ${providerEnvVarsSet} provider env var(s)`);
|
|
231015
231040
|
let cleanedUp = false;
|
|
231016
231041
|
let openclawProcess = null;
|
|
231017
231042
|
const cleanup = async () => {
|