feat(provider): add provider and model sync feature with vendored generator (#378)

* feat(provider): vendor and adapt pi model generator

- Vendor generate-models.ts, model-data.ts, and models-dev-reasoning-options.ts from @earendil-works/pi tag v0.82.1
- Adapt imports to use @earendil-works/pi-ai and expose generateModels programmatic function
- Add compare.test.ts to verify vendored generator against original built-in catalog
- Add packages/core/src/provider/generator to eslint ignores

* feat(provider): add provider and model sync api and ui

* feat(webui): add checkbox for existing providers and clean dialog description

* feat(webui): add expand all and collapse all to sync providers dialog

* refactor(provider): remove compare.test.ts and cli overhead from generate-models

* fix(provider): add 30s timeout and strict error handling to sync catalog fetching

* fix(e2e): eliminate drag-and-drop race condition on webkit

Allow requestAnimationFrame collision updates to settle in dragCard helper before releasing pointer, and scope fileCard locator via data-testid to avoid matching sidebar tree items.
This commit is contained in:
Yiling-J
2026-09-03 21:01:14 +08:00
committed by GitHub
parent c3ef769f51
commit a236cd3a97
58 changed files with 5070 additions and 15 deletions
+41
View File
@@ -5,6 +5,7 @@ import { providerService } from '@shumai/core/src/provider/provider'
import {
createModelRequestSchema,
createProviderRequestSchema,
syncApplyRequestSchema,
updateModelRequestSchema,
updateProviderRequestSchema,
AuditAction,
@@ -30,6 +31,46 @@ const route = new Hono<{ Variables: { user: User } }>()
return c.json(providers)
})
.post('/teams/:teamId/providers/sync-check', async (c) => {
const teamId = c.req.param('teamId')
const user = c.get('user')
await authzService.hasPermission({
user,
permission: Permission.Admin,
type: ResourceType.Team,
id: teamId,
})
const result = await providerService.checkUpdates(teamId)
return c.json(result)
})
.post(
'/teams/:teamId/providers/sync-apply',
zValidator('json', syncApplyRequestSchema),
async (c) => {
const teamId = c.req.param('teamId')
const user = c.get('user')
const body = c.req.valid('json')
await authzService.hasPermission({
user,
permission: Permission.Admin,
type: ResourceType.Team,
id: teamId,
})
const result = await providerService.applySync(teamId, body)
await auditLogService.logAction({
action: AuditAction.provider_update,
teamId,
userId: user?.id,
})
return c.json(result)
},
)
.get('/providers/:id/models', async (c) => {
const id = c.req.param('id')
const user = c.get('user')