refactor: depend on SecretStore instead of the VaultStore class (P1.2)
Connectors, the connector SDK and registry, setup-connectors, provider-env, the LiteLLM runtime config and the sidecar's `vault` decoration only read and write secrets, so they now take the SecretStore interface. VaultStore is still constructed in the sidecar and the service startup, and its file format is unchanged. AGENTS.md now points at the interface.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { WaggleConfig, type ProviderEntry, type VaultStore } from '@waggle/core';
|
||||
import { WaggleConfig, type ProviderEntry, type SecretStore } from '@waggle/core';
|
||||
|
||||
/** Provider credentials consumed by LiteLLM and provider SDKs. */
|
||||
export const PROVIDER_ENV_NAMES: Record<string, readonly string[]> = {
|
||||
@@ -34,7 +34,7 @@ export function applyProviderKeyToEnv(
|
||||
|
||||
export function getProviderApiKeys(
|
||||
providerId: string,
|
||||
vault: VaultStore | null | undefined,
|
||||
vault: SecretStore | null | undefined,
|
||||
): string[] {
|
||||
const candidates: string[] = [];
|
||||
try {
|
||||
@@ -52,13 +52,13 @@ export function getProviderApiKeys(
|
||||
|
||||
export function getProviderApiKey(
|
||||
providerId: string,
|
||||
vault: VaultStore | null | undefined,
|
||||
vault: SecretStore | null | undefined,
|
||||
): string | undefined {
|
||||
return getProviderApiKeys(providerId, vault)[0];
|
||||
}
|
||||
|
||||
/** Hydrate provider SDK/LiteLLM env before a child process snapshots it. */
|
||||
export function hydrateProviderEnvFromVault(vault: VaultStore, overwrite = false): number {
|
||||
export function hydrateProviderEnvFromVault(vault: SecretStore, overwrite = false): number {
|
||||
let updated = 0;
|
||||
for (const providerId of Object.keys(PROVIDER_ENV_NAMES)) {
|
||||
const entry = vault.get(providerId);
|
||||
@@ -73,7 +73,7 @@ export function hydrateProviderEnvFromVault(vault: VaultStore, overwrite = false
|
||||
* the vault already holds. Returns the number of keys copied.
|
||||
*/
|
||||
export function copyProviderKeysToVault(
|
||||
vault: VaultStore,
|
||||
vault: SecretStore,
|
||||
providers: Readonly<Record<string, ProviderEntry>>,
|
||||
): number {
|
||||
let copied = 0;
|
||||
@@ -90,7 +90,7 @@ export function copyProviderKeysToVault(
|
||||
}
|
||||
|
||||
/** Move legacy config.json secrets before LiteLLM starts, then scrub plaintext. */
|
||||
export function migrateLegacyProviderKeysToVault(dataDir: string, vault: VaultStore): number {
|
||||
export function migrateLegacyProviderKeysToVault(dataDir: string, vault: SecretStore): number {
|
||||
const config = new WaggleConfig(dataDir);
|
||||
const providers = config.getProviders();
|
||||
const migrated = copyProviderKeysToVault(vault, providers);
|
||||
|
||||
Reference in New Issue
Block a user