feat(agent): support gemma-embedding-2-openai provider (#475)

* feat(agent): support gemma-embedding-2-openai provider

Add support for local LiteRT-LM Gemma Embedding 2 provider with 768-dimensional vector embeddings, environment-configured read-only embedding agents, 16-frame uniform sampling for video chunks, and automatic WebP-to-JPEG conversion.

* refactor(agent): remove unused legacy generateEmbeddingActivity

* chore(agent): align sharp version to 0.35.4

* refactor(agent): rename embedding server env to GEMMA_EMBEDDING_OPENAI_BASE_URL

* refactor(agent,transcode): use native Bun.Archive for video chunk frames

* fix(transcode,agent): populate buffer entries in Bun.Archive and validate frame sizes
This commit is contained in:
Yiling-J
2026-10-15 15:49:24 +08:00
committed by GitHub
parent c302c162a0
commit b7271777e0
28 changed files with 1270 additions and 238 deletions
@@ -92,4 +92,39 @@ describe('AgentFormDialog', () => {
expect(screen.getByText('Move Assets')).toBeDefined()
expect(screen.getByText('Delete Asset')).toBeDefined()
})
it('renders read-only state with system managed hint and only Close button', () => {
render(
<QueryClientProvider client={queryClient}>
<AgentFormDialog
isOpen={true}
readOnly={true}
onClose={vi.fn()}
teamId="team-123"
type="embedding"
title="Edit Embedding Agent"
initialValues={{
id: 'agent-1',
name: 'embedding-agent',
type: 'embedding',
enabled: true,
permission: 'reviewer',
thinkingLevel: 'off',
skills: [],
mcpServerIds: [],
deniedTools: [],
readOnly: true,
}}
/>
</QueryClientProvider>,
)
expect(
screen.getByText(
'This agent is managed by the server environment configuration and cannot be modified or deleted.',
),
).toBeDefined()
expect(screen.getAllByRole('button', { name: 'Close' }).length).toBe(2)
expect(screen.queryByRole('button', { name: 'Save Changes' })).toBeNull()
})
})
@@ -48,6 +48,7 @@ interface AgentFormDialogProps {
type?: AgentType
initialValues?: AgentInfo
title: string
readOnly?: boolean
}
const agentFormSchema = z.object({
@@ -137,6 +138,7 @@ export function AgentFormDialog({
type,
initialValues,
title,
readOnly = false,
}: AgentFormDialogProps) {
const queryClient = useQueryClient()
const { canAdmin } = usePermissions()
@@ -368,6 +370,11 @@ export function AgentFormDialog({
>
<ScrollArea className="flex-1 min-h-0">
<div className="p-6 pt-2 space-y-6">
{readOnly && (
<div className="p-3 bg-muted text-muted-foreground text-sm rounded-lg border border-border">
{m.agent_managed_by_system_hint()}
</div>
)}
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<form.Field
name="name"
@@ -382,6 +389,7 @@ export function AgentFormDialog({
onChange={(e) => field.handleChange(e.target.value)}
placeholder={m.agent_name_placeholder()}
aria-invalid={isInvalid}
disabled={readOnly}
/>
{isInvalid && <FieldError errors={mapErrors(field.state.meta.errors)} />}
</Field>
@@ -423,7 +431,7 @@ export function AgentFormDialog({
onValueChange={(val) =>
field.handleChange(val as 'owner' | 'editor' | 'reviewer')
}
disabled={!canAdmin}
disabled={readOnly || !canAdmin}
>
<SelectTrigger>
<SelectValue />
@@ -453,12 +461,15 @@ export function AgentFormDialog({
<button
key={preset.id}
type="button"
onClick={() => field.handleChange(preset.id)}
disabled={readOnly}
onClick={() => !readOnly && field.handleChange(preset.id)}
className={cn(
'relative w-14 h-14 rounded-full overflow-hidden border-2 transition-all hover:scale-105',
'relative w-14 h-14 rounded-full overflow-hidden border-2 transition-all',
!readOnly && 'hover:scale-105',
isSelected
? 'border-primary ring-2 ring-primary ring-offset-2'
: 'border-border hover:border-muted-foreground',
readOnly && 'cursor-default opacity-80',
)}
>
<img
@@ -473,7 +484,8 @@ export function AgentFormDialog({
!AVAILABLE_AVATARS.some((p) => p.id === field.state.value) && (
<button
type="button"
className="relative w-14 h-14 rounded-full overflow-hidden border-2 border-primary ring-2 ring-primary ring-offset-2 scale-105"
disabled={true}
className="relative w-14 h-14 rounded-full overflow-hidden border-2 border-primary ring-2 ring-primary ring-offset-2 scale-105 cursor-default"
>
<img
src={field.state.value}
@@ -1024,29 +1036,37 @@ export function AgentFormDialog({
</ScrollArea>
<DialogFooter className="p-6 pt-4 border-t border-border flex-shrink-0">
<Button variant="outline" onClick={onClose} type="button">
{m.cancel()}
</Button>
<form.Subscribe
selector={(state) => [state.canSubmit, state.isSubmitting]}
children={([canSubmit, isSubmitting]) => (
<Button
type="submit"
className="bg-primary hover:bg-primary/90 text-primary-foreground min-w-[120px]"
disabled={
!canSubmit ||
isSubmitting ||
createMutation.isPending ||
updateMutation.isPending
}
>
{(isSubmitting || createMutation.isPending || updateMutation.isPending) && (
<Loader2 className="w-4 h-4 animate-spin mr-2" />
)}
{initialValues ? m.save_changes() : m.create_agent()}
{readOnly ? (
<Button variant="outline" onClick={onClose} type="button">
{m.close()}
</Button>
) : (
<>
<Button variant="outline" onClick={onClose} type="button">
{m.cancel()}
</Button>
)}
/>
<form.Subscribe
selector={(state) => [state.canSubmit, state.isSubmitting]}
children={([canSubmit, isSubmitting]) => (
<Button
type="submit"
className="bg-primary hover:bg-primary/90 text-primary-foreground min-w-[120px]"
disabled={
!canSubmit ||
isSubmitting ||
createMutation.isPending ||
updateMutation.isPending
}
>
{(isSubmitting || createMutation.isPending || updateMutation.isPending) && (
<Loader2 className="w-4 h-4 animate-spin mr-2" />
)}
{initialValues ? m.save_changes() : m.create_agent()}
</Button>
)}
/>
</>
)}
</DialogFooter>
</form>
</DialogContent>
@@ -189,6 +189,7 @@ export function AgentsSettings({ teamId }: AgentsSettingsProps) {
{(isCreateDialogOpen || editingAgent) && (
<AgentFormDialog
isOpen={true}
readOnly={editingAgent?.readOnly}
title={
editingAgent
? m.edit_item({ name: editingAgent.name })
@@ -340,29 +341,38 @@ export function AgentsSettings({ teamId }: AgentsSettingsProps) {
</div>
</div>
</div>
<DropdownMenu modal={false}>
<DropdownMenuTrigger asChild onClick={(e) => e.stopPropagation()}>
<Button
variant="ghost"
size="icon"
className="h-8 w-8 text-muted-foreground hover:text-foreground"
>
<MoreVertical className="w-4 h-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-32">
<DropdownMenuItem
onClick={(e) => {
e.stopPropagation()
setAgentToDelete(agent)
setIsDeleteDialogOpen(true)
}}
className="text-red-500 focus:text-red-500 gap-2 cursor-pointer"
>
<Trash2 className="w-4 h-4" /> {m.delete()}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
{agent.readOnly ? (
<Badge
variant="outline"
className="text-xs text-muted-foreground border-border"
>
{m.agent_readonly()}
</Badge>
) : (
<DropdownMenu modal={false}>
<DropdownMenuTrigger asChild onClick={(e) => e.stopPropagation()}>
<Button
variant="ghost"
size="icon"
className="h-8 w-8 text-muted-foreground hover:text-foreground"
>
<MoreVertical className="w-4 h-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-32">
<DropdownMenuItem
onClick={(e) => {
e.stopPropagation()
setAgentToDelete(agent)
setIsDeleteDialogOpen(true)
}}
className="text-red-500 focus:text-red-500 gap-2 cursor-pointer"
>
<Trash2 className="w-4 h-4" /> {m.delete()}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
)}
</div>
<div className="flex items-center justify-between gap-2 pt-2 border-t border-border/50">
@@ -408,6 +418,7 @@ export function AgentsSettings({ teamId }: AgentsSettingsProps) {
<div onClick={(e) => e.stopPropagation()}>
<Switch
checked={agent.enabled}
disabled={agent.readOnly}
onCheckedChange={(enabled) => {
updateAgentMutation.mutate({
teamId,