@sahu-01/openpaw 1.0.7 → 1.0.8
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 +31 -8
- 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,17 @@ 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);
|
|
230967
|
+
envVarMap.set(envVarName, { credId, provider });
|
|
230956
230968
|
profile.key = "${" + envVarName + "}";
|
|
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 });
|
|
230962
230974
|
}
|
|
230963
230975
|
}
|
|
230964
230976
|
}
|
|
@@ -230995,23 +231007,34 @@ async function startGateway(config = {}) {
|
|
|
230995
231007
|
const allEnvVars = /* @__PURE__ */ new Map();
|
|
230996
231008
|
for (const profilePath of profileFiles) {
|
|
230997
231009
|
const envVars = await processAuthProfiles(profilePath, vault);
|
|
230998
|
-
for (const [envVarName,
|
|
230999
|
-
allEnvVars.set(envVarName,
|
|
231010
|
+
for (const [envVarName, credInfo] of envVars) {
|
|
231011
|
+
allEnvVars.set(envVarName, credInfo);
|
|
231000
231012
|
}
|
|
231001
231013
|
}
|
|
231002
231014
|
const childEnv = { ...process.env };
|
|
231003
231015
|
let credentialsLoaded = 0;
|
|
231004
|
-
|
|
231005
|
-
|
|
231016
|
+
let providerEnvVarsSet = 0;
|
|
231017
|
+
for (const [envVarName, credInfo] of allEnvVars) {
|
|
231018
|
+
const result = vault.get(credInfo.credId);
|
|
231006
231019
|
if (result) {
|
|
231007
231020
|
childEnv[envVarName] = result.value;
|
|
231008
231021
|
credentialsLoaded++;
|
|
231009
231022
|
console.log(` ${envVarName} \u2192 [secured]`);
|
|
231023
|
+
if (credInfo.provider) {
|
|
231024
|
+
const providerEnvVars = PROVIDER_ENV_VARS[credInfo.provider.toLowerCase()];
|
|
231025
|
+
if (providerEnvVars) {
|
|
231026
|
+
for (const providerEnvVar of providerEnvVars) {
|
|
231027
|
+
childEnv[providerEnvVar] = result.value;
|
|
231028
|
+
providerEnvVarsSet++;
|
|
231029
|
+
console.log(` ${providerEnvVar} \u2192 [secured] (${credInfo.provider})`);
|
|
231030
|
+
}
|
|
231031
|
+
}
|
|
231032
|
+
}
|
|
231010
231033
|
} else {
|
|
231011
|
-
console.warn(` Warning: Credential ${credId} not found in vault`);
|
|
231034
|
+
console.warn(` Warning: Credential ${credInfo.credId} not found in vault`);
|
|
231012
231035
|
}
|
|
231013
231036
|
}
|
|
231014
|
-
console.log(`Loaded ${credentialsLoaded} credential(s)
|
|
231037
|
+
console.log(`Loaded ${credentialsLoaded} credential(s), set ${providerEnvVarsSet} provider env var(s)`);
|
|
231015
231038
|
let cleanedUp = false;
|
|
231016
231039
|
let openclawProcess = null;
|
|
231017
231040
|
const cleanup = async () => {
|