mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
* feat(opencode): migrate OpenCode Manager to OpenCode 2 Port the backend lifecycle, generated plugins, event aggregation, schedules, worktrees, provider credentials, MCP, config handling, the frontend chat model, and the ocm CLI to OpenCode 2. Adopt @opencode/client 2.0.15 as the single typed V2 API contract, require OpenCode 2.0.0 or newer (pinned 2.0.15), and delete every V1-only code path. * refactor(opencode): reload config in place and drop v1 compatibility shims Route config/skill/AGENTS.md changes through the OpenCode location reload API instead of a full server restart, stop auto-resuming interrupted sessions, remove the restart coordinator and v1 MCP/version shims, and pin support to OpenCode >=2.0.15 <3.0.0. Adds integration-ready retries, service-mode launch, ocm-cli repo proxy, and new frontend form/MCP helpers. * refactor(opencode): consolidate v2 migration helpers and harden install, proxy, and session flows - extract shared semver and model-ref utilities, reuse across version checks - share the OpenCode release download script across Docker, entrypoint, dev setup - unify install/upgrade failure recovery and guard externally managed OPENCODE_BIN - scope the repo proxy location rewrite and surface ocm proxy errors - rework frontend session projection, permission lookup, and cache invalidation * fix(schedules): reject unavailable agents before creating a session * feat(opencode): add ocm install, schedule agent fallback, and session move guards
112 lines
3.4 KiB
TypeScript
112 lines
3.4 KiB
TypeScript
import { Input } from '@/components/ui/input'
|
|
import { Label } from '@/components/ui/label'
|
|
import { Checkbox } from '@/components/ui/checkbox'
|
|
import { MultiSelect } from '@/components/ui/multi-select'
|
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
|
|
import { ExternalFieldCard } from '@/components/ui/external-field-card'
|
|
import type { FormField, FormValue } from '@/api/oauth'
|
|
|
|
interface ProviderAuthFieldProps {
|
|
field: FormField
|
|
value: FormValue | undefined
|
|
disabled: boolean
|
|
onChange: (value: FormValue | undefined) => void
|
|
}
|
|
|
|
function fieldLabel(field: FormField): string {
|
|
return field.title ?? field.key
|
|
}
|
|
|
|
function FieldControl({ field, value, disabled, onChange }: ProviderAuthFieldProps) {
|
|
if (field.type === 'boolean') {
|
|
return (
|
|
<div className="flex items-center gap-2">
|
|
<Checkbox
|
|
id={field.key}
|
|
checked={value === true}
|
|
onCheckedChange={(checked) => onChange(checked === true)}
|
|
disabled={disabled}
|
|
/>
|
|
<Label htmlFor={field.key} className="cursor-pointer">
|
|
{fieldLabel(field)}
|
|
</Label>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (field.type === 'number' || field.type === 'integer') {
|
|
return (
|
|
<Input
|
|
id={field.key}
|
|
type="number"
|
|
value={typeof value === 'number' || typeof value === 'string' ? String(value) : ''}
|
|
onChange={(e) => onChange(e.target.value === '' ? undefined : Number(e.target.value))}
|
|
min={typeof field.minimum === 'number' ? field.minimum : undefined}
|
|
max={typeof field.maximum === 'number' ? field.maximum : undefined}
|
|
step={field.type === 'integer' ? 1 : 'any'}
|
|
className="bg-background border-border"
|
|
disabled={disabled}
|
|
/>
|
|
)
|
|
}
|
|
|
|
if (field.type === 'multiselect') {
|
|
return (
|
|
<MultiSelect
|
|
value={Array.isArray(value) ? value : []}
|
|
onChange={(next) => onChange(next)}
|
|
options={field.options}
|
|
disabled={disabled}
|
|
/>
|
|
)
|
|
}
|
|
|
|
if (field.type === 'string' && field.options && field.options.length > 0) {
|
|
return (
|
|
<Select
|
|
value={typeof value === 'string' ? value : ''}
|
|
onValueChange={(next) => onChange(next)}
|
|
disabled={disabled}
|
|
>
|
|
<SelectTrigger className="bg-background border-border">
|
|
<SelectValue placeholder="Select an option" />
|
|
</SelectTrigger>
|
|
<SelectContent>
|
|
{field.options.map((option) => (
|
|
<SelectItem key={option.value} value={option.value}>
|
|
{option.label}
|
|
</SelectItem>
|
|
))}
|
|
</SelectContent>
|
|
</Select>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<Input
|
|
id={field.key}
|
|
value={typeof value === 'string' ? value : ''}
|
|
onChange={(e) => onChange(e.target.value)}
|
|
placeholder={field.type === 'string' ? field.placeholder : undefined}
|
|
className="bg-background border-border"
|
|
disabled={disabled}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export function ProviderAuthField(props: ProviderAuthFieldProps) {
|
|
const { field } = props
|
|
|
|
if (field.type === 'external') {
|
|
return <ExternalFieldCard field={field} />
|
|
}
|
|
|
|
return (
|
|
<div className="space-y-2">
|
|
{field.type !== 'boolean' && <Label htmlFor={field.key}>{fieldLabel(field)}</Label>}
|
|
<FieldControl {...props} />
|
|
{field.description && <p className="text-xs text-muted-foreground">{field.description}</p>}
|
|
</div>
|
|
)
|
|
}
|