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:
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
import type { WaggleConnector, ConnectorResult } from './connector-sdk.js';
|
||||
import { getConnectorCredential } from './connectors/connector-credentials.js';
|
||||
import type { ToolDefinition } from './tools.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorDefinition, ConnectorHealth } from '@waggle/shared';
|
||||
@@ -109,7 +110,7 @@ export class ConnectorRegistry {
|
||||
if (this.connectors.get(connector.id) !== connector) return false;
|
||||
if (this.hydration.get(connector)?.status !== 'ready') return false;
|
||||
if (ALWAYS_CONNECTED_CONNECTOR_IDS.has(connector.id)) return true;
|
||||
const cred = this.vault.getConnectorCredential(connector.id);
|
||||
const cred = getConnectorCredential(this.vault, connector.id);
|
||||
return Boolean(
|
||||
cred
|
||||
&& !cred.isExpired
|
||||
@@ -128,7 +129,7 @@ export class ConnectorRegistry {
|
||||
/** Get ConnectorDefinition[] with live status from vault (for REST API responses) */
|
||||
getDefinitions(): ConnectorDefinition[] {
|
||||
return [...this.connectors.values()].map(c => {
|
||||
const cred = this.vault.getConnectorCredential(c.id);
|
||||
const cred = getConnectorCredential(this.vault, c.id);
|
||||
let status: ConnectorDefinition['status'] = 'disconnected';
|
||||
if (cred) {
|
||||
status = cred.isExpired ? 'expired' : (this.isConnected(c) ? 'connected' : 'disconnected');
|
||||
|
||||
Reference in New Issue
Block a user