refactor(agent): move the connector credential helpers out of VaultStore (P1.2)
getConnectorCredential, setConnectorCredential and setConnectorCredentialBundle are now plain functions over a SecretStore in packages/agent/src/connectors/connector-credentials.ts. The secret names, metadata layout and the rule that tokens never go into plaintext metadata are unchanged, so existing vault files keep working. A bundle still lands as one update: SecretStore gains writeBatch, which VaultStore applies with a single vault-file replacement. Connector tests seed a Map-backed SecretStore instead of mocking VaultStore methods; the helper tests from core and server moved to the agent package.
This commit is contained in:
@@ -12,7 +12,7 @@ import { executeCoordinator } from '../../../worker/src/execution/coordinator.js
|
||||
import { AgentMessageBus } from '../../src/agent-message-bus.js';
|
||||
import { createAgentCommsTools } from '../../src/agent-comms-tools.js';
|
||||
import { WorkspaceSessionManager } from '../../../server/src/local/workspace-sessions.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import { createMemorySecretStore, type MockSecretStore } from '../helpers/memory-secret-store.js';
|
||||
// The session manager is typed against the published @waggle/agent surface.
|
||||
import type { Orchestrator } from '@waggle/agent';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
@@ -46,17 +46,10 @@ class MockConnector extends BaseConnector {
|
||||
}
|
||||
}
|
||||
|
||||
function createMockVault(connected: string[]): VaultStore {
|
||||
return {
|
||||
getConnectorCredential: vi.fn((id: string) => {
|
||||
if (connected.includes(id)) return { value: 'tok', type: 'bearer', isExpired: false };
|
||||
return null;
|
||||
}),
|
||||
setConnectorCredential: vi.fn(),
|
||||
set: vi.fn(), get: vi.fn(), delete: vi.fn(),
|
||||
list: vi.fn(() => []), has: vi.fn(() => false),
|
||||
migrateFromConfig: vi.fn(() => 0),
|
||||
} as unknown as VaultStore;
|
||||
function createMockVault(connected: string[]): MockSecretStore {
|
||||
return createMemorySecretStore({
|
||||
connectors: Object.fromEntries(connected.map(id => [id, { type: 'bearer' as const, value: 'tok' }])),
|
||||
});
|
||||
}
|
||||
|
||||
function createMockDeps(): ExecutionDeps {
|
||||
|
||||
Reference in New Issue
Block a user