refactor: move all server config to startup env vars; drop plugin settings

This commit is contained in:
tao.chen
2026-07-23 13:21:31 +08:00
parent ca2281af3b
commit f9b93906c6
7 changed files with 72 additions and 171 deletions
+4 -34
View File
@@ -3,6 +3,10 @@
*
* These mirror the Python server's `CellContext` / `OpenCodeRequest` / `OpenCodeResponse`
* shapes in `opencode_bridge/routes.py`. Keep them in sync.
*
* v3-final: the JupyterLab plugin settings have been removed entirely.
* All connection config lives in startup environment variables (see
* `opencode_bridge/config.py`); the inline model picker is fully dynamic.
*/
export interface ErrorOutput {
@@ -43,40 +47,6 @@ export interface OpenCodeFailure {
export type OpenCodeResponse = OpenCodeSuccess | OpenCodeFailure;
/** Frontend view of the 4 schema/plugin.json fields. */
export interface OpenCodeSettings {
opencodeServerUrl: string;
opencodeServerUser: string;
opencodeServerPassword: string;
requestTimeoutSeconds: number;
opencodeProvider: string;
opencodeModel: string;
}
export const DEFAULT_OPENCODE_SETTINGS: OpenCodeSettings = {
opencodeServerUrl: 'http://127.0.0.1:4096',
opencodeServerUser: 'opencode',
opencodeServerPassword: '',
requestTimeoutSeconds: 120,
opencodeProvider: '',
opencodeModel: '',
};
export function readOpenCodeSettings(composite: unknown): OpenCodeSettings {
const c = (composite ?? {}) as Partial<OpenCodeSettings>;
return {
opencodeServerUrl: c.opencodeServerUrl || DEFAULT_OPENCODE_SETTINGS.opencodeServerUrl,
opencodeServerUser: c.opencodeServerUser || DEFAULT_OPENCODE_SETTINGS.opencodeServerUser,
opencodeServerPassword: c.opencodeServerPassword || '',
requestTimeoutSeconds:
typeof c.requestTimeoutSeconds === 'number'
? c.requestTimeoutSeconds
: DEFAULT_OPENCODE_SETTINGS.requestTimeoutSeconds,
opencodeProvider: c.opencodeProvider || '',
opencodeModel: c.opencodeModel || '',
};
}
/** Response from GET /opencode-bridge/providers. */
export interface OpenCodeProvider {
id: string;