mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-26 12:35:35 +02:00
fix(core): read data tool API key from credentials.json5
Use credentialManager.getToolConfig("data") as the primary source for
the Financial Datasets API key, with FINANCIAL_DATASETS_API_KEY env var
as fallback. Also add data tool entry to the credentials template.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -44,7 +44,8 @@ function buildCoreTemplate(): string {
|
||||
},
|
||||
tools: {
|
||||
// brave: { apiKey: "brv-..." },
|
||||
// perplexity: { apiKey: "pplx-...", baseUrl: "https://api.perplexity.ai", model: "perplexity/sonar-pro" }
|
||||
// perplexity: { apiKey: "pplx-...", baseUrl: "https://api.perplexity.ai", model: "perplexity/sonar-pro" },
|
||||
// data: { apiKey: "your-financial-datasets-api-key" }
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -12,14 +12,19 @@ const BASE_URL = "https://api.financialdatasets.ai";
|
||||
const TIMEOUT_MS = 30_000;
|
||||
|
||||
function getApiKey(): string {
|
||||
const key = credentialManager.getEnv("FINANCIAL_DATASETS_API_KEY");
|
||||
if (!key) {
|
||||
throw new Error(
|
||||
"FINANCIAL_DATASETS_API_KEY not configured. " +
|
||||
"Set it in ~/.super-multica/skills.env.json5 under env, or as an environment variable.",
|
||||
);
|
||||
}
|
||||
return key;
|
||||
// 1. credentials.json5 → tools.data.apiKey (preferred)
|
||||
const toolConfig = credentialManager.getToolConfig("data");
|
||||
if (toolConfig?.apiKey) return toolConfig.apiKey;
|
||||
|
||||
// 2. Fallback: env var (skills.env.json5 or process.env)
|
||||
const envKey = credentialManager.getEnv("FINANCIAL_DATASETS_API_KEY");
|
||||
if (envKey) return envKey;
|
||||
|
||||
throw new Error(
|
||||
"Financial Datasets API key not configured. " +
|
||||
'Set it in ~/.super-multica/credentials.json5 under tools.data.apiKey, ' +
|
||||
"or set FINANCIAL_DATASETS_API_KEY in ~/.super-multica/skills.env.json5.",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user