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:
@@ -372,7 +372,7 @@ declare module 'fastify' {
|
||||
traceStore: import('@waggle/core').ExecutionTraceStore;
|
||||
/** Active behavioral spec — the compiled `BEHAVIORAL_SPEC` baseline. */
|
||||
activeBehavioralSpec: ReturnType<typeof import('@waggle/agent').buildActiveBehavioralSpec>;
|
||||
vault: import('@waggle/core').VaultStore;
|
||||
vault: import('@waggle/core').SecretStore;
|
||||
embeddingProvider: import('@waggle/core').EmbeddingProviderInstance;
|
||||
skillHashStore: import('@waggle/core').SkillHashStore;
|
||||
scheduler: import('./cron.js').LocalScheduler;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { SecretStore } from '@waggle/core';
|
||||
import type { FastifyInstance } from 'fastify';
|
||||
import {
|
||||
discoverProviderModels,
|
||||
@@ -108,7 +108,7 @@ export function buildLiteLLMRuntimeConfig(
|
||||
/** Build the executable router catalog from the same live APIs used by the UI. */
|
||||
export async function prepareLiteLLMRuntimeConfig(
|
||||
dataDir: string,
|
||||
vault: VaultStore,
|
||||
vault: SecretStore,
|
||||
discoveryOptions: DiscoveryOptions = {},
|
||||
): Promise<LiteLLMRuntimeConfigResult> {
|
||||
const catalogs = new Map<string, DiscoveredProviderModel[]>();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -16,9 +16,9 @@ import {
|
||||
MSTeamsConnector, OutlookConnector, OneDriveConnector, OneNoteConnector,
|
||||
ComposioConnector,
|
||||
} from '@waggle/agent';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { SecretStore } from '@waggle/core';
|
||||
|
||||
export function registerConnectors(vault: VaultStore): ConnectorRegistry {
|
||||
export function registerConnectors(vault: SecretStore): ConnectorRegistry {
|
||||
const registry = new ConnectorRegistry(vault);
|
||||
registry.register(new GitHubConnector());
|
||||
registry.register(new SlackConnector());
|
||||
|
||||
@@ -12,7 +12,7 @@ import Fastify from 'fastify';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import * as os from 'node:os';
|
||||
import { MindDB, InstallAuditStore, VaultStore } from '@waggle/core';
|
||||
import { MindDB, InstallAuditStore, VaultStore, type SecretStore } from '@waggle/core';
|
||||
import {
|
||||
ConnectorRegistry,
|
||||
BaseConnector,
|
||||
@@ -46,7 +46,7 @@ class TestConnector extends BaseConnector {
|
||||
credentialValue: string | null = null;
|
||||
connectGate: Promise<void> | null = null;
|
||||
connectError: Error | null = null;
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
async connect(vault: SecretStore): Promise<void> {
|
||||
this.connectCalls += 1;
|
||||
if (this.connectGate) await this.connectGate;
|
||||
if (this.connectError) throw this.connectError;
|
||||
|
||||
Reference in New Issue
Block a user