fix: specify extension env vars only by name (#2249)

Co-authored-by: Lily Delalande <ldelalande@block.xyz>
This commit is contained in:
Alex Hancock
2025-04-17 16:57:11 -04:00
committed by GitHub
parent 9b605dbdd7
commit 571ba86157
2 changed files with 53 additions and 4 deletions
@@ -1,6 +1,12 @@
import type { ExtensionConfig } from '../../../api/types.gen';
import { toastService, ToastServiceOptions } from '../../../toasts';
import { addToAgent, removeFromAgent } from './agent-api';
import { upsertConfig } from '../../../api';
// TODO: unify config.yaml and the agent /extensions/add API's notion of env vars
export type AgentExtensionConfig = ExtensionConfig & {
env_keys?: string[];
};
interface ActivateExtensionProps {
addToConfig: (name: string, extensionConfig: ExtensionConfig, enabled: boolean) => Promise<void>;
@@ -283,3 +289,11 @@ export async function deleteExtension({ name, removeFromConfig }: DeleteExtensio
throw agentRemoveError;
}
}
export async function saveEnvVarsToKeyring(extension: ExtensionConfig) {
if (extension.type === 'stdio' || extension.type === 'sse') {
for (const [key, value] of Object.entries(extension.envs || {})) {
await upsertConfig({ body: { key, value, is_secret: true } });
}
}
}