Something went wrong. Try again.
A local-first event pipeline for independent agents, built on Jazz.
Something went wrong. Try again.
2.0 kB · 47 lines
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748import { pathToFileURL } from "node:url";import { splitServiceCredentialFile, type ConsumerCredentialProvider,} from "../src/runtime/credential-compartments.js";
export async function main(arguments_: string[] = process.argv.slice(2)): Promise<void> { const source = valueAfter(arguments_, "--source"); const outputDirectory = valueAfter(arguments_, "--output-dir"); if (!source || !outputDirectory) { throw new Error("Usage: split-service-credentials --source <private-env-file> --output-dir <private-directory> [--consumer-providers letta,letta-local,tinker,openai,openai-compatible] [--allow-remove <VARIABLE_NAME>]..."); } const providers = (valueAfter(arguments_, "--consumer-providers") ?? "letta") .split(",") .map((value) => value.trim()) .filter(Boolean) as ConsumerCredentialProvider[]; for (const provider of providers) { if (!(["letta", "letta-local", "tinker", "openai", "openai-compatible"] as string[]).includes(provider)) { throw new Error(`Unsupported consumer credential provider: ${provider}`); } } const receipt = await splitServiceCredentialFile(source, outputDirectory, { consumerProviders: providers, allowedRemovedVariableNames: valuesAfter(arguments_, "--allow-remove"), }); process.stdout.write(`${JSON.stringify(receipt, null, 2)}\n`);}
function valueAfter(arguments_: string[], flag: string): string | undefined { const index = arguments_.indexOf(flag); return index >= 0 ? arguments_[index + 1] : undefined;}
function valuesAfter(arguments_: string[], flag: string): string[] { const values: string[] = []; for (let index = 0; index < arguments_.length; index += 1) { if (arguments_[index] !== flag) continue; const value = arguments_[index + 1]; if (!value || value.startsWith("--")) throw new Error(`${flag} requires a value`); values.push(value); } return values;}
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) { await main();}