feat: added providers management settings with ability to add or remove providers (#76)
* feat: implement adding opencode providers in openchamber settings * feat: implement provider authentication management with removal functionality
This commit is contained in:
committed by
GitHub
parent
ff874cc33d
commit
8f9facb561
@@ -3,6 +3,7 @@ import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import type { OpenCodeManager } from './opencode';
|
||||
import { createAgent, createCommand, deleteAgent, deleteCommand, getAgentSources, getCommandSources, updateAgent, updateCommand } from './opencodeConfig';
|
||||
import { removeProviderAuth } from './opencodeAuth';
|
||||
|
||||
export interface BridgeRequest {
|
||||
id: string;
|
||||
@@ -807,6 +808,36 @@ export async function handleBridgeMessage(message: BridgeRequest, ctx?: BridgeCo
|
||||
}
|
||||
}
|
||||
|
||||
case 'api:provider/auth:delete': {
|
||||
const { providerId } = (payload || {}) as { providerId?: string };
|
||||
if (!providerId) {
|
||||
return { id, type, success: false, error: 'Provider ID is required' };
|
||||
}
|
||||
try {
|
||||
const removed = removeProviderAuth(providerId);
|
||||
if (removed) {
|
||||
await ctx?.manager?.restart();
|
||||
}
|
||||
return {
|
||||
id,
|
||||
type,
|
||||
success: true,
|
||||
data: {
|
||||
success: true,
|
||||
removed,
|
||||
requiresReload: removed,
|
||||
message: removed
|
||||
? `Provider ${providerId} disconnected successfully. Reloading interface…`
|
||||
: `Provider ${providerId} was not configured.`,
|
||||
reloadDelayMs: removed ? CLIENT_RELOAD_DELAY_MS : undefined,
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
return { id, type, success: false, error: errorMessage };
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
return { id, type, success: false, error: `Unknown message type: ${type}` };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user