mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
feat: add dynamic OAuth prompt system with conditional fields
- Add PromptFieldSchema supporting text and select input types - Support conditional prompt visibility based on previous inputs - Add inputs parameter to OAuth authorize request - Update OAuth dialogs to render dynamic prompts - Add OPENCODE_PUBLIC_URL config for OAuth callback URLs - Remove redundant OAuthMethod enum in favor of backend schema
This commit is contained in:
1 parent
9d94c333b4
commit
2b5e130916
12 files changed
+371
-78
No files matched your search
@@ -13,6 +13,7 @@ export const DEFAULTS = {
|
||||
OPENCODE: {
|
||||
PORT: 5551,
|
||||
HOST: '127.0.0.1',
|
||||
PUBLIC_URL: '', // Optional: public URL for OAuth callbacks (e.g., https://mydomain.com)
|
||||
},
|
||||
|
||||
DATABASE: {
|
||||
|
||||
@@ -53,6 +53,7 @@ export const ENV = {
|
||||
OPENCODE: {
|
||||
PORT: getEnvNumber('OPENCODE_SERVER_PORT', DEFAULTS.OPENCODE.PORT),
|
||||
HOST: getEnvString('OPENCODE_HOST', DEFAULTS.OPENCODE.HOST),
|
||||
PUBLIC_URL: getEnvString('OPENCODE_PUBLIC_URL', ''), // Public URL for OAuth callbacks
|
||||
},
|
||||
|
||||
DATABASE: {
|
||||
|
||||
@@ -22,15 +22,39 @@ export const CredentialListResponseSchema = z.object({
|
||||
providers: z.array(z.string()),
|
||||
});
|
||||
|
||||
export const PromptFieldSchema = z.discriminatedUnion("type", [
|
||||
z.object({
|
||||
type: z.literal("text"),
|
||||
key: z.string(),
|
||||
message: z.string(),
|
||||
placeholder: z.string().optional(),
|
||||
}),
|
||||
z.object({
|
||||
type: z.literal("select"),
|
||||
key: z.string(),
|
||||
message: z.string(),
|
||||
options: z.array(z.object({
|
||||
label: z.string(),
|
||||
value: z.string(),
|
||||
})),
|
||||
when: z.object({
|
||||
key: z.string(),
|
||||
value: z.string(),
|
||||
}).optional(),
|
||||
}),
|
||||
]);
|
||||
|
||||
export const ProviderAuthMethodSchema = z.object({
|
||||
type: z.enum(["oauth", "api"]),
|
||||
label: z.string(),
|
||||
prompts: z.array(PromptFieldSchema).optional(),
|
||||
});
|
||||
|
||||
export const ProviderAuthMethodsSchema = z.record(z.string(), z.array(ProviderAuthMethodSchema));
|
||||
|
||||
export const OAuthAuthorizeRequestSchema = z.object({
|
||||
method: z.number(),
|
||||
inputs: z.record(z.string(), z.string()).optional(),
|
||||
});
|
||||
|
||||
export const OAuthAuthorizeResponseSchema = z.object({
|
||||
@@ -46,4 +70,4 @@ export const OAuthCallbackRequestSchema = z.object({
|
||||
|
||||
export const ProviderAuthMethodsResponseSchema = z.object({
|
||||
providers: z.record(z.string(), z.array(ProviderAuthMethodSchema)),
|
||||
});
|
||||
}).or(ProviderAuthMethodsSchema);
|
||||
Reference in new issue
Block a user