mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-21 05:32:53 +00:00
feat: add Fireworks provider and simplify plugin setup loading
This commit is contained in:
@@ -21,7 +21,6 @@ const allowedFiles = new Set([
|
||||
"src/agents/tools/web-fetch.test-harness.ts",
|
||||
"src/config/legacy-web-fetch.ts",
|
||||
"src/config/zod-schema.agent-runtime.ts",
|
||||
"src/plugins/bundled-provider-auth-env-vars.generated.ts",
|
||||
"src/secrets/target-registry-data.ts",
|
||||
]);
|
||||
const suspiciousPatterns = [
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
import path from "node:path";
|
||||
import { collectBundledPluginSources } from "./lib/bundled-plugin-source-utils.mjs";
|
||||
import { reportGeneratedOutputCli, writeGeneratedOutput } from "./lib/generated-output-utils.mjs";
|
||||
|
||||
const GENERATED_BY = "scripts/generate-bundled-provider-auth-env-vars.mjs";
|
||||
const DEFAULT_OUTPUT_PATH = "src/plugins/bundled-provider-auth-env-vars.generated.ts";
|
||||
|
||||
function normalizeProviderAuthEnvVars(providerAuthEnvVars) {
|
||||
if (
|
||||
!providerAuthEnvVars ||
|
||||
typeof providerAuthEnvVars !== "object" ||
|
||||
Array.isArray(providerAuthEnvVars)
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Object.entries(providerAuthEnvVars)
|
||||
.map(([providerId, envVars]) => {
|
||||
const normalizedProviderId = providerId.trim();
|
||||
const normalizedEnvVars = Array.isArray(envVars)
|
||||
? envVars.map((value) => String(value).trim()).filter(Boolean)
|
||||
: [];
|
||||
if (!normalizedProviderId || normalizedEnvVars.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return [normalizedProviderId, normalizedEnvVars];
|
||||
})
|
||||
.filter(Boolean)
|
||||
.toSorted(([left], [right]) => left.localeCompare(right));
|
||||
}
|
||||
|
||||
export function collectBundledProviderAuthEnvVars(params = {}) {
|
||||
const repoRoot = path.resolve(params.repoRoot ?? process.cwd());
|
||||
const entries = new Map();
|
||||
for (const source of collectBundledPluginSources({ repoRoot })) {
|
||||
for (const [providerId, envVars] of normalizeProviderAuthEnvVars(
|
||||
source.manifest.providerAuthEnvVars,
|
||||
)) {
|
||||
entries.set(providerId, envVars);
|
||||
}
|
||||
}
|
||||
|
||||
return Object.fromEntries(
|
||||
[...entries.entries()].toSorted(([left], [right]) => left.localeCompare(right)),
|
||||
);
|
||||
}
|
||||
|
||||
export function renderBundledProviderAuthEnvVarModule(entries) {
|
||||
const renderedEntries = Object.entries(entries)
|
||||
.map(([providerId, envVars]) => {
|
||||
const renderedKey = /^[$A-Z_a-z][\w$]*$/u.test(providerId)
|
||||
? providerId
|
||||
: JSON.stringify(providerId);
|
||||
const renderedEnvVars = envVars.map((value) => JSON.stringify(value)).join(", ");
|
||||
return ` ${renderedKey}: [${renderedEnvVars}],`;
|
||||
})
|
||||
.join("\n");
|
||||
return `// Auto-generated by ${GENERATED_BY}. Do not edit directly.
|
||||
|
||||
export const BUNDLED_PROVIDER_AUTH_ENV_VAR_CANDIDATES = {
|
||||
${renderedEntries}
|
||||
} as const satisfies Record<string, readonly string[]>;
|
||||
`;
|
||||
}
|
||||
|
||||
export function writeBundledProviderAuthEnvVarModule(params = {}) {
|
||||
const repoRoot = path.resolve(params.repoRoot ?? process.cwd());
|
||||
const next = renderBundledProviderAuthEnvVarModule(
|
||||
collectBundledProviderAuthEnvVars({ repoRoot }),
|
||||
);
|
||||
return writeGeneratedOutput({
|
||||
repoRoot,
|
||||
outputPath: params.outputPath ?? DEFAULT_OUTPUT_PATH,
|
||||
next,
|
||||
check: params.check,
|
||||
});
|
||||
}
|
||||
|
||||
reportGeneratedOutputCli({
|
||||
importMetaUrl: import.meta.url,
|
||||
label: "bundled-provider-auth-env-vars",
|
||||
run: ({ check }) => writeBundledProviderAuthEnvVarModule({ check }),
|
||||
});
|
||||
Reference in New Issue
Block a user