mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-02 22:14:50 +00:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e806435e49 | ||
|
|
17ba2631c5 | ||
|
|
2505612dd8 | ||
|
|
bfeabb8244 | ||
|
|
e3fe5792b9 |
@@ -8,10 +8,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- **sessions**: See total tokens and estimated cost in the session logs footer, with a breakdown of input, output, and cached tokens.
|
||||||
|
- **projects**: Middle-click or Command/Ctrl-click a project to open it in a new tab. Use **Open in new tab** in a file or folder's context menu to keep your current view open.
|
||||||
|
- **video**: Use **Generate Transcripts** in a video's context menu to save a transcript with the local embedding server. Choose a language or let the server detect it automatically.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
- **provider**: Open a provider card to edit its settings, or use its refresh button to choose new models to add. Use Add Provider to set up a new provider.
|
||||||
|
|
||||||
## [0.7.2] - 2026-11-27
|
## [0.7.2] - 2026-11-27
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -67,12 +67,16 @@ apps/web/e2e/
|
|||||||
| Owner changes a team member role in the members dialog and permissions update | `tests/team/change-member-role.spec.ts` |
|
| Owner changes a team member role in the members dialog and permissions update | `tests/team/change-member-role.spec.ts` |
|
||||||
| Owner manages resource quotas in settings and resets usage from the dashboard | `tests/team/quotas-settings.spec.ts` |
|
| Owner manages resource quotas in settings and resets usage from the dashboard | `tests/team/quotas-settings.spec.ts` |
|
||||||
| Owner creates an API token that is shown once, listed by hint, and authenticates API calls | `tests/team/api-tokens.spec.ts` |
|
| Owner creates an API token that is shown once, listed by hint, and authenticates API calls | `tests/team/api-tokens.spec.ts` |
|
||||||
| Session logs stay within the dialog and scroll through long messages and expanded records on desktop and narrow screens | `tests/team/agent-session-logs.spec.ts` |
|
| Session logs scroll through long messages and expanded records with the usage footer pinned and the token breakdown available on desktop and narrow screens | `tests/team/agent-session-logs.spec.ts` |
|
||||||
|
| Provider cards open the editor by click and keyboard, keep menu actions independent, and show a scrollable model preview on desktop and mobile | `tests/team/provider-model-refresh.spec.ts` |
|
||||||
|
|
||||||
### project
|
### project
|
||||||
| Test | File |
|
| Test | File |
|
||||||
|---|---|
|
|---|---|
|
||||||
| Owner creates a project with a cover image | `tests/project/create-project.spec.ts` |
|
| Owner creates a project with a cover image | `tests/project/create-project.spec.ts` |
|
||||||
|
| Owner opens project cards in new tabs with middle-click and modifier-click | `tests/project/open-in-new-tab.spec.ts` |
|
||||||
|
| Owner opens a folder card and a file row in new tabs from the context menu | `tests/project/open-in-new-tab.spec.ts` |
|
||||||
|
| Owner opens transcript generation from a video context menu, selects a language, and sees completion | `tests/project/generate-transcripts.spec.ts` |
|
||||||
| Owner uploads a file or an unsupported file via the "Upload File" context menu action | `tests/project/upload-file.spec.ts` |
|
| Owner uploads a file or an unsupported file via the "Upload File" context menu action | `tests/project/upload-file.spec.ts` |
|
||||||
| Owner deletes a file, finds it in recently deleted, and restores it | `tests/project/delete-restore.spec.ts` |
|
| Owner deletes a file, finds it in recently deleted, and restores it | `tests/project/delete-restore.spec.ts` |
|
||||||
| Owner deletes a folder and still sees its contents preview and countdown in recently deleted | `tests/project/delete-restore.spec.ts` |
|
| Owner deletes a folder and still sees its contents preview and countdown in recently deleted | `tests/project/delete-restore.spec.ts` |
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import { expect, test } from '../../fixtures'
|
||||||
|
import { fileCard } from '../../helpers/files'
|
||||||
|
|
||||||
|
test.use({ fileOptions: { mediaType: 'video' } })
|
||||||
|
|
||||||
|
test('selects a transcription language from the video context menu and tracks the job', async ({
|
||||||
|
file,
|
||||||
|
prisma,
|
||||||
|
}) => {
|
||||||
|
const { page, projectId, fileId, fileName } = file
|
||||||
|
let submitted = false
|
||||||
|
await page.route('**/api/signup-info', async (route) => {
|
||||||
|
const response = await route.fetch()
|
||||||
|
await route.fulfill({ json: { ...(await response.json()), transcriptionEnabled: true } })
|
||||||
|
})
|
||||||
|
await page.route('**/api/transcription/languages', (route) =>
|
||||||
|
route.fulfill({
|
||||||
|
json: {
|
||||||
|
model: 'whisper-tiny',
|
||||||
|
languages: [
|
||||||
|
{ code: 'en', name: 'English' },
|
||||||
|
{ code: 'zh', name: 'Chinese' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
await page.route(`**/api/files/${fileId}/transcription-status`, (route) =>
|
||||||
|
route.fulfill({
|
||||||
|
body: JSON.stringify(submitted ? { taskId: 'transcript-task', status: 'completed' } : null),
|
||||||
|
contentType: 'application/json',
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
await page.route(`**/api/files/${fileId}/transcripts`, async (route) => {
|
||||||
|
expect(route.request().postDataJSON()).toEqual({ language: 'zh' })
|
||||||
|
submitted = true
|
||||||
|
await route.fulfill({ status: 202, json: { kind: 'queued', taskId: 'transcript-task' } })
|
||||||
|
})
|
||||||
|
|
||||||
|
await expect
|
||||||
|
.poll(() =>
|
||||||
|
prisma.asset.findUnique({
|
||||||
|
where: { id: fileId },
|
||||||
|
select: { status: true, media: true },
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.toMatchObject({ status: 'processed', media: { proxyType: 'video' } })
|
||||||
|
const [signupInfo] = await Promise.all([
|
||||||
|
page.waitForResponse('**/api/signup-info'),
|
||||||
|
page.goto(`/projects/${projectId}`),
|
||||||
|
])
|
||||||
|
expect(await signupInfo.json()).toMatchObject({ transcriptionEnabled: true })
|
||||||
|
await fileCard(page, fileName).click({ button: 'right' })
|
||||||
|
await page.getByRole('menuitem', { name: 'Generate Transcripts' }).click()
|
||||||
|
const dialog = page.getByRole('dialog', { name: 'Generate Transcripts' })
|
||||||
|
const language = dialog.getByRole('combobox', { name: 'Language' })
|
||||||
|
await expect(language).toHaveValue('Auto')
|
||||||
|
await language.fill('Chi')
|
||||||
|
await dialog.getByRole('option', { name: 'Chinese' }).click()
|
||||||
|
await expect(language).toHaveValue('Chinese')
|
||||||
|
await dialog.getByRole('button', { name: 'Generate', exact: true }).click()
|
||||||
|
await expect(dialog.getByRole('status')).toHaveText('Transcript generated.')
|
||||||
|
})
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import { expect, test } from '../../fixtures'
|
||||||
|
import { seedFolder } from '../../helpers/assets'
|
||||||
|
import { fileCard } from '../../helpers/files'
|
||||||
|
|
||||||
|
test('project cards open in a new tab with middle-click and modifier-click', async ({
|
||||||
|
project,
|
||||||
|
}) => {
|
||||||
|
const { page, context, teamId, projectId, projectName } = project
|
||||||
|
await page.reload()
|
||||||
|
const projectLink = page.getByRole('link', { name: projectName, exact: true })
|
||||||
|
|
||||||
|
const [middleClickTab] = await Promise.all([
|
||||||
|
context.waitForEvent('page'),
|
||||||
|
projectLink.click({ button: 'middle' }),
|
||||||
|
])
|
||||||
|
await expect(middleClickTab).toHaveURL(`/projects/${projectId}`)
|
||||||
|
await expect(page).toHaveURL(`/teams/${teamId}`)
|
||||||
|
await middleClickTab.close()
|
||||||
|
|
||||||
|
const [modifierClickTab] = await Promise.all([
|
||||||
|
context.waitForEvent('page'),
|
||||||
|
projectLink.click({ modifiers: ['ControlOrMeta'] }),
|
||||||
|
])
|
||||||
|
await expect(modifierClickTab).toHaveURL(`/projects/${projectId}`)
|
||||||
|
await expect(page).toHaveURL(`/teams/${teamId}`)
|
||||||
|
await modifierClickTab.close()
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: 'More options' }).click()
|
||||||
|
await expect(page.getByRole('menuitem', { name: 'Project Settings' })).toBeVisible()
|
||||||
|
await expect(page).toHaveURL(`/teams/${teamId}`)
|
||||||
|
await page.keyboard.press('Escape')
|
||||||
|
|
||||||
|
await projectLink.click()
|
||||||
|
await expect(page).toHaveURL(`/projects/${projectId}`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('the context menu opens a folder card and a file row in new tabs', async ({
|
||||||
|
file,
|
||||||
|
prisma,
|
||||||
|
}) => {
|
||||||
|
const { page, context, projectId, rootFolderId, fileId, fileName } = file
|
||||||
|
const projectPath = `/projects/${projectId}`
|
||||||
|
const folder = await seedFolder(prisma, projectId, rootFolderId, 'Test folder')
|
||||||
|
await page.goto(projectPath)
|
||||||
|
|
||||||
|
const openInNewTab = page.getByRole('menuitem', { name: 'Open in new tab' })
|
||||||
|
await fileCard(page, folder.name).click({ button: 'right' })
|
||||||
|
await expect(openInNewTab).toBeVisible()
|
||||||
|
expect(context.pages()).toHaveLength(1)
|
||||||
|
const [folderTab] = await Promise.all([context.waitForEvent('page'), openInNewTab.click()])
|
||||||
|
await expect(folderTab).toHaveURL(`${projectPath}/folders/${folder.id}`)
|
||||||
|
await expect(page).toHaveURL(projectPath)
|
||||||
|
await folderTab.close()
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: 'List View' }).click()
|
||||||
|
const fileRow = fileCard(page, fileName)
|
||||||
|
const fileLabel = fileRow.getByText(fileName, { exact: true })
|
||||||
|
const selected = fileRow.getByRole('checkbox')
|
||||||
|
await fileLabel.click()
|
||||||
|
await expect(selected).toBeChecked()
|
||||||
|
await expect(page).toHaveURL(projectPath)
|
||||||
|
|
||||||
|
await fileLabel.click({ button: 'right' })
|
||||||
|
const [fileTab] = await Promise.all([context.waitForEvent('page'), openInNewTab.press('Enter')])
|
||||||
|
await expect(fileTab).toHaveURL(`${projectPath}/files/${fileId}`)
|
||||||
|
await expect(page).toHaveURL(projectPath)
|
||||||
|
await expect(selected).toBeChecked()
|
||||||
|
})
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { expect, test } from '../../fixtures'
|
import { expect, test } from '../../fixtures'
|
||||||
|
|
||||||
test('session logs stay within the dialog and scroll through long messages and expanded records', async ({
|
test('session logs scroll with usage pinned below long messages and expanded records', async ({
|
||||||
owner,
|
owner,
|
||||||
prisma,
|
prisma,
|
||||||
}) => {
|
}) => {
|
||||||
@@ -25,6 +25,13 @@ test('session logs stay within the dialog and scroll through long messages and e
|
|||||||
type: 'chat',
|
type: 'chat',
|
||||||
name: 'Scrollable Session Logs',
|
name: 'Scrollable Session Logs',
|
||||||
cwd: '/test',
|
cwd: '/test',
|
||||||
|
accountedUsage: {
|
||||||
|
inputTokens: 12800,
|
||||||
|
outputTokens: 1580,
|
||||||
|
cacheReadTokens: 10000,
|
||||||
|
totalTokens: 24380,
|
||||||
|
cost: 0.014,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await prisma.agentSessionCommit.create({
|
await prisma.agentSessionCommit.create({
|
||||||
@@ -64,6 +71,10 @@ test('session logs stay within the dialog and scroll through long messages and e
|
|||||||
await expect(dialog.getByText(/^(Entry ID|条目 ID):/)).toHaveCount(0)
|
await expect(dialog.getByText(/^(Entry ID|条目 ID):/)).toHaveCount(0)
|
||||||
const viewport = dialog.locator('[data-slot="scroll-area-viewport"]')
|
const viewport = dialog.locator('[data-slot="scroll-area-viewport"]')
|
||||||
const heading = dialog.getByRole('heading')
|
const heading = dialog.getByRole('heading')
|
||||||
|
const footer = dialog.locator('footer')
|
||||||
|
const breakdown = footer.getByRole('button', { name: /^(Breakdown|明细|상세 내역)$/ })
|
||||||
|
await expect(footer).toContainText('24,380')
|
||||||
|
await expect(footer).toContainText('$0.014')
|
||||||
|
|
||||||
for (const size of [
|
for (const size of [
|
||||||
{ width: 1280, height: 800 },
|
{ width: 1280, height: 800 },
|
||||||
@@ -97,6 +108,7 @@ test('session logs stay within the dialog and scroll through long messages and e
|
|||||||
)
|
)
|
||||||
.toBe(true)
|
.toBe(true)
|
||||||
const headerTop = (await heading.boundingBox())!.y
|
const headerTop = (await heading.boundingBox())!.y
|
||||||
|
const footerTop = (await footer.boundingBox())!.y
|
||||||
await viewport.evaluate((element) => {
|
await viewport.evaluate((element) => {
|
||||||
element.scrollTop = 0
|
element.scrollTop = 0
|
||||||
})
|
})
|
||||||
@@ -110,6 +122,26 @@ test('session logs stay within the dialog and scroll through long messages and e
|
|||||||
})
|
})
|
||||||
await expect(record.locator('summary')).toBeInViewport()
|
await expect(record.locator('summary')).toBeInViewport()
|
||||||
expect((await heading.boundingBox())!.y).toBeCloseTo(headerTop, 0)
|
expect((await heading.boundingBox())!.y).toBeCloseTo(headerTop, 0)
|
||||||
|
expect((await footer.boundingBox())!.y).toBeCloseTo(footerTop, 0)
|
||||||
|
await expect(footer).toBeInViewport()
|
||||||
|
|
||||||
|
await breakdown.click()
|
||||||
|
const popover = page.getByRole('dialog', {
|
||||||
|
name: /Token breakdown|Token 用量明细|토큰 사용량 상세 내역/,
|
||||||
|
})
|
||||||
|
await expect(popover).toBeVisible()
|
||||||
|
for (const count of ['12,800', '1,580', '10,000']) {
|
||||||
|
await expect(popover.getByText(count, { exact: true })).toBeVisible()
|
||||||
|
}
|
||||||
|
await expect
|
||||||
|
.poll(async () => {
|
||||||
|
const bounds = await popover.boundingBox()
|
||||||
|
return bounds ? bounds.y + bounds.height : Infinity
|
||||||
|
})
|
||||||
|
.toBeLessThan(footerTop + 1)
|
||||||
|
await page.keyboard.press('Escape')
|
||||||
|
await expect(popover).toBeHidden()
|
||||||
|
await expect(breakdown).toBeFocused()
|
||||||
|
|
||||||
await record.locator('summary').click()
|
await record.locator('summary').click()
|
||||||
await viewport.evaluate((element) => {
|
await viewport.evaluate((element) => {
|
||||||
|
|||||||
@@ -0,0 +1,134 @@
|
|||||||
|
import type { RefreshedProviderModel } from '@shumai/dtos'
|
||||||
|
import { expect, test } from '../../fixtures'
|
||||||
|
|
||||||
|
test('provider cards open the edit dialog and keep their refresh and menu actions independent', async ({
|
||||||
|
owner,
|
||||||
|
prisma,
|
||||||
|
}) => {
|
||||||
|
const { page, teamId } = owner
|
||||||
|
const provider = await prisma.provider.create({
|
||||||
|
data: {
|
||||||
|
teamId,
|
||||||
|
name: 'OpenAI production',
|
||||||
|
config: {
|
||||||
|
api: 'openai-responses',
|
||||||
|
baseUrl: 'https://api.openai.com/v1',
|
||||||
|
apiKey: 'saved-test-key',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const missing = await prisma.provider.create({
|
||||||
|
data: {
|
||||||
|
teamId,
|
||||||
|
name: 'Anthropic staging',
|
||||||
|
config: {
|
||||||
|
api: 'anthropic-messages',
|
||||||
|
baseUrl: 'https://api.anthropic.com',
|
||||||
|
apiKey: 'UNSET_E2E_ANTHROPIC_KEY',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const models = Array.from({ length: 48 }, (_, index): RefreshedProviderModel => ({
|
||||||
|
modelId: `test-model-${index + 1}`,
|
||||||
|
name: `Test Model ${index + 1}`,
|
||||||
|
config: {
|
||||||
|
reasoning: false,
|
||||||
|
input: ['text'],
|
||||||
|
contextWindow: 128000,
|
||||||
|
maxTokens: 4096,
|
||||||
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
|
||||||
|
const releasePreview = Promise.withResolvers<void>()
|
||||||
|
await page.route(
|
||||||
|
`**/api/teams/${teamId}/providers/${provider.id}/models/refresh`,
|
||||||
|
async (route) => {
|
||||||
|
await releasePreview.promise
|
||||||
|
await route.fulfill({
|
||||||
|
json: { status: 'ready', providerUpdatedAt: provider.updatedAt.toISOString(), models },
|
||||||
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
|
await page.goto(`/teams/${teamId}/settings#providers`)
|
||||||
|
|
||||||
|
const cards = page.locator('main [data-slot="card"]')
|
||||||
|
const openai = cards.filter({ hasText: provider.name })
|
||||||
|
const anthropic = cards.filter({ hasText: missing.name })
|
||||||
|
const refresh = openai.getByRole('button', { name: /Refresh models for OpenAI production/ })
|
||||||
|
const edit = openai.getByRole('button', { name: `Edit ${provider.name}` })
|
||||||
|
const editDialog = page.getByRole('dialog', { name: `Edit ${provider.name}` })
|
||||||
|
const options = openai.getByRole('button', { name: `Options for ${provider.name}` })
|
||||||
|
await expect(cards.first()).toContainText(provider.name)
|
||||||
|
await expect(openai.getByText('Configured', { exact: true })).toBeVisible()
|
||||||
|
await expect(anthropic.getByText('Configured', { exact: true })).toHaveCount(0)
|
||||||
|
await expect(anthropic.getByRole('button', { name: /Refresh models/ })).toBeEnabled()
|
||||||
|
await expect(refresh).toHaveText('')
|
||||||
|
|
||||||
|
await openai.click({ position: { x: 8, y: 30 } })
|
||||||
|
await expect(editDialog).toBeVisible()
|
||||||
|
await page.keyboard.press('Escape')
|
||||||
|
await expect(editDialog).toBeHidden()
|
||||||
|
await expect(edit).toBeFocused()
|
||||||
|
|
||||||
|
await edit.press('Enter')
|
||||||
|
await expect(editDialog).toBeVisible()
|
||||||
|
await page.keyboard.press('Escape')
|
||||||
|
await expect(editDialog).toBeHidden()
|
||||||
|
|
||||||
|
await options.click()
|
||||||
|
await expect(editDialog).toBeHidden()
|
||||||
|
await page.getByRole('menuitem', { name: 'Edit', exact: true }).click()
|
||||||
|
await expect(editDialog).toBeVisible()
|
||||||
|
await page.keyboard.press('Escape')
|
||||||
|
await expect(editDialog).toBeHidden()
|
||||||
|
await expect(options).toBeFocused()
|
||||||
|
|
||||||
|
await options.click()
|
||||||
|
await page.getByRole('menuitem', { name: 'Delete', exact: true }).click()
|
||||||
|
const confirmDelete = page.getByRole('alertdialog')
|
||||||
|
await expect(confirmDelete).toContainText(provider.name)
|
||||||
|
await expect(editDialog).toBeHidden()
|
||||||
|
await confirmDelete.getByRole('button', { name: 'Cancel' }).click()
|
||||||
|
|
||||||
|
await refresh.click()
|
||||||
|
await expect(refresh).toHaveAttribute('aria-busy', 'true')
|
||||||
|
await expect(editDialog).toBeHidden()
|
||||||
|
await expect(anthropic.getByRole('button', { name: /Refresh models/ })).toHaveAttribute(
|
||||||
|
'aria-busy',
|
||||||
|
'false',
|
||||||
|
)
|
||||||
|
releasePreview.resolve()
|
||||||
|
|
||||||
|
const dialog = page.getByRole('dialog', { name: 'New models for OpenAI production' })
|
||||||
|
await expect(dialog).toBeVisible()
|
||||||
|
await expect(dialog.getByRole('checkbox', { name: 'Test Model 1 test-model-1' })).toBeVisible()
|
||||||
|
|
||||||
|
for (const viewport of [
|
||||||
|
{ width: 1280, height: 800 },
|
||||||
|
{ width: 390, height: 640 },
|
||||||
|
]) {
|
||||||
|
await page.setViewportSize(viewport)
|
||||||
|
await expect
|
||||||
|
.poll(() =>
|
||||||
|
dialog.locator('[data-slot="scroll-area-viewport"]').evaluate((element) => {
|
||||||
|
const scrollAreaBounds = element.getBoundingClientRect()
|
||||||
|
const dialogBounds = element.closest('[role="dialog"]')?.getBoundingClientRect()
|
||||||
|
return (
|
||||||
|
dialogBounds !== undefined &&
|
||||||
|
dialogBounds.left >= 0 &&
|
||||||
|
dialogBounds.right <= window.innerWidth &&
|
||||||
|
dialogBounds.top >= 0 &&
|
||||||
|
dialogBounds.bottom <= window.innerHeight &&
|
||||||
|
scrollAreaBounds.bottom < dialogBounds.bottom &&
|
||||||
|
element.scrollHeight > element.clientHeight
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.toBe(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
await dialog.getByRole('button', { name: 'Cancel' }).click()
|
||||||
|
await expect(dialog).toBeHidden()
|
||||||
|
await expect(refresh).toBeFocused()
|
||||||
|
})
|
||||||
@@ -147,9 +147,9 @@
|
|||||||
"name": "@shumai/agent",
|
"name": "@shumai/agent",
|
||||||
"version": "0.7.2",
|
"version": "0.7.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@earendil-works/chord": "1.5.0",
|
"@earendil-works/chord": "1.7.0",
|
||||||
"@earendil-works/pi-ai": "1.5.0",
|
"@earendil-works/pi-ai": "1.7.0",
|
||||||
"@earendil-works/pi-durable": "1.5.0",
|
"@earendil-works/pi-durable": "1.7.0",
|
||||||
"@google/genai": "2.28.0",
|
"@google/genai": "2.28.0",
|
||||||
"@shumai/core": "workspace:*",
|
"@shumai/core": "workspace:*",
|
||||||
"@shumai/db": "workspace:*",
|
"@shumai/db": "workspace:*",
|
||||||
@@ -172,7 +172,7 @@
|
|||||||
"version": "0.7.2",
|
"version": "0.7.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@better-auth/mcp": "1.7.12",
|
"@better-auth/mcp": "1.7.12",
|
||||||
"@earendil-works/pi-durable": "1.5.0",
|
"@earendil-works/pi-durable": "1.7.0",
|
||||||
"@hono/zod-validator": "0.7.6",
|
"@hono/zod-validator": "0.7.6",
|
||||||
"@modelcontextprotocol/server": "2.0.0",
|
"@modelcontextprotocol/server": "2.0.0",
|
||||||
"@shumai/core": "workspace:*",
|
"@shumai/core": "workspace:*",
|
||||||
@@ -214,9 +214,9 @@
|
|||||||
"@aws-sdk/s3-request-presigner": "3.1121.0",
|
"@aws-sdk/s3-request-presigner": "3.1121.0",
|
||||||
"@better-auth/mcp": "1.7.12",
|
"@better-auth/mcp": "1.7.12",
|
||||||
"@better-auth/oauth-provider": "1.7.12",
|
"@better-auth/oauth-provider": "1.7.12",
|
||||||
"@earendil-works/chord": "1.5.0",
|
"@earendil-works/chord": "1.7.0",
|
||||||
"@earendil-works/pi-ai": "1.5.0",
|
"@earendil-works/pi-ai": "1.7.0",
|
||||||
"@earendil-works/pi-durable": "1.5.0",
|
"@earendil-works/pi-durable": "1.7.0",
|
||||||
"@google/genai": "2.28.0",
|
"@google/genai": "2.28.0",
|
||||||
"@modelcontextprotocol/client": "2.0.0",
|
"@modelcontextprotocol/client": "2.0.0",
|
||||||
"@shumai/db": "workspace:*",
|
"@shumai/db": "workspace:*",
|
||||||
@@ -271,8 +271,8 @@
|
|||||||
"name": "@shumai/dtos",
|
"name": "@shumai/dtos",
|
||||||
"version": "0.7.2",
|
"version": "0.7.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@earendil-works/pi-ai": "1.5.0",
|
"@earendil-works/pi-ai": "1.7.0",
|
||||||
"@earendil-works/pi-durable": "1.5.0",
|
"@earendil-works/pi-durable": "1.7.0",
|
||||||
"zod": "4.5.4",
|
"zod": "4.5.4",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -280,8 +280,8 @@
|
|||||||
"name": "@shumai/e2e",
|
"name": "@shumai/e2e",
|
||||||
"version": "0.7.2",
|
"version": "0.7.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@earendil-works/pi-ai": "1.5.0",
|
"@earendil-works/pi-ai": "1.7.0",
|
||||||
"@earendil-works/pi-durable": "1.5.0",
|
"@earendil-works/pi-durable": "1.7.0",
|
||||||
"@google/genai": "2.28.0",
|
"@google/genai": "2.28.0",
|
||||||
"@shumai/agent": "workspace:*",
|
"@shumai/agent": "workspace:*",
|
||||||
"@shumai/core": "workspace:*",
|
"@shumai/core": "workspace:*",
|
||||||
@@ -323,8 +323,8 @@
|
|||||||
"@dnd-kit/abstract": "0.5.0",
|
"@dnd-kit/abstract": "0.5.0",
|
||||||
"@dnd-kit/dom": "0.5.0",
|
"@dnd-kit/dom": "0.5.0",
|
||||||
"@dnd-kit/react": "0.5.0",
|
"@dnd-kit/react": "0.5.0",
|
||||||
"@earendil-works/pi-ai": "1.5.0",
|
"@earendil-works/pi-ai": "1.7.0",
|
||||||
"@earendil-works/pi-durable": "1.5.0",
|
"@earendil-works/pi-durable": "1.7.0",
|
||||||
"@ferrucc-io/emoji-picker": "0.1.2",
|
"@ferrucc-io/emoji-picker": "0.1.2",
|
||||||
"@hookform/resolvers": "5.9.1",
|
"@hookform/resolvers": "5.9.1",
|
||||||
"@lexical/code": "0.49.0",
|
"@lexical/code": "0.49.0",
|
||||||
@@ -496,21 +496,21 @@
|
|||||||
|
|
||||||
"@aws-sdk/core": ["@aws-sdk/core@3.977.9", "", { "dependencies": { "@aws-sdk/types": "^3.974.5", "@aws-sdk/xml-builder": "^3.972.40", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.33.3", "@smithy/signature-v4": "^5.6.12", "@smithy/types": "^4.17.2", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-reqPFEQrZxDZpeGj4PFMepBeR5LGYHRqq/L0motTzgFkCRBA4rFdaVXDSLYyGHhxVz7sT2PDnPN9CluGSfgyJA=="],
|
"@aws-sdk/core": ["@aws-sdk/core@3.977.9", "", { "dependencies": { "@aws-sdk/types": "^3.974.5", "@aws-sdk/xml-builder": "^3.972.40", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.33.3", "@smithy/signature-v4": "^5.6.12", "@smithy/types": "^4.17.2", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-reqPFEQrZxDZpeGj4PFMepBeR5LGYHRqq/L0motTzgFkCRBA4rFdaVXDSLYyGHhxVz7sT2PDnPN9CluGSfgyJA=="],
|
||||||
|
|
||||||
"@aws-sdk/credential-provider-env": ["@aws-sdk/credential-provider-env@3.972.70", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-H404B7dJl2mCrBqahDEYsanB0xhdDp6tXnXcTUnXmmpy2Q3J0Ho0bUajZ2jr/RdwzCyS59Gi8xXIFwPLGBl6Uw=="],
|
"@aws-sdk/credential-provider-env": ["@aws-sdk/credential-provider-env@3.972.80", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-uO5TiSvb6j1w9RTe5z28OaOmsrOxVQUPaC5+wZl50RfOXcrYD/KgnS8I9lfyGXc7sGbkCopK6VnhNIAoLqfewQ=="],
|
||||||
|
|
||||||
"@aws-sdk/credential-provider-http": ["@aws-sdk/credential-provider-http@3.972.72", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/fetch-http-handler": "^5.7.2", "@smithy/node-http-handler": "^4.11.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-X98zYOrVOeuosCX+6ktf29FC2N2GHPLia7qv6mzPzTc+RPAuHWCDS++Z6JK7eGYqb/v6uaW7bAXaOvDBfol+0w=="],
|
"@aws-sdk/credential-provider-http": ["@aws-sdk/credential-provider-http@3.972.82", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/fetch-http-handler": "^5.8.0", "@smithy/node-http-handler": "^4.14.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-vQzlDHlC24Yz42p+rT4NBoP/5VdetkBoujbOLq9h6QYWC8THuZSPYnXIR9OP3XcOrdMgPBBipOrdssfxnIiWUg=="],
|
||||||
|
|
||||||
"@aws-sdk/credential-provider-ini": ["@aws-sdk/credential-provider-ini@3.973.15", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/credential-provider-env": "^3.972.70", "@aws-sdk/credential-provider-http": "^3.972.72", "@aws-sdk/credential-provider-login": "^3.972.77", "@aws-sdk/credential-provider-process": "^3.972.70", "@aws-sdk/credential-provider-sso": "^3.973.14", "@aws-sdk/credential-provider-web-identity": "^3.972.76", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/credential-provider-imds": "^4.4.16", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-Rykg6s5ceBuynMOGWgoowO4N+27JfnqXAnVaSunZl0hOO1XodSrxGNz6sCEbnmS0lAfQZDKyb3fbr46gSuv6Sg=="],
|
"@aws-sdk/credential-provider-ini": ["@aws-sdk/credential-provider-ini@3.973.25", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/credential-provider-env": "^3.972.80", "@aws-sdk/credential-provider-http": "^3.972.82", "@aws-sdk/credential-provider-login": "^3.972.87", "@aws-sdk/credential-provider-process": "^3.972.80", "@aws-sdk/credential-provider-sso": "^3.973.24", "@aws-sdk/credential-provider-web-identity": "^3.972.86", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/credential-provider-imds": "^4.5.2", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-b5xl71uCRdWsu7P1VeGpiGuCf6zfYETsSNOv8AmYVTrsgbvTJRXdmmOPVfxkvGGVNsiKkGctClQW3jAn0SZLug=="],
|
||||||
|
|
||||||
"@aws-sdk/credential-provider-login": ["@aws-sdk/credential-provider-login@3.972.77", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-Jb59xfEISoN5mmbnA+HYqdtrSX3CgCtJoof+V5D8/TgUI56W63GEEd5Y58WijU3Ou6+WEgaLD1feVzaRXV5IDQ=="],
|
"@aws-sdk/credential-provider-login": ["@aws-sdk/credential-provider-login@3.972.87", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-C4ZFmcwM+Zj14Z8huVUk54Gv4uzT1ZdzG9cY3Gdh8FePakq7Bss1OFsgZjAhWFOkFOGpBvFBeu0OWjWf8HNKRQ=="],
|
||||||
|
|
||||||
"@aws-sdk/credential-provider-node": ["@aws-sdk/credential-provider-node@3.972.81", "", { "dependencies": { "@aws-sdk/credential-provider-env": "^3.972.70", "@aws-sdk/credential-provider-http": "^3.972.72", "@aws-sdk/credential-provider-ini": "^3.973.15", "@aws-sdk/credential-provider-process": "^3.972.70", "@aws-sdk/credential-provider-sso": "^3.973.14", "@aws-sdk/credential-provider-web-identity": "^3.972.76", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/credential-provider-imds": "^4.4.16", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-Rml+WitoFvXmv6JZ18U/xGdGDGGvB/mOin0ya0lTnTrdC0Z1lrVxTYh7iNklZBcvcRMrs4DoEf6xy1KWyrLQQw=="],
|
"@aws-sdk/credential-provider-node": ["@aws-sdk/credential-provider-node@3.972.82", "", { "dependencies": { "@aws-sdk/credential-provider-env": "^3.972.70", "@aws-sdk/credential-provider-http": "^3.972.72", "@aws-sdk/credential-provider-ini": "^3.973.15", "@aws-sdk/credential-provider-process": "^3.972.70", "@aws-sdk/credential-provider-sso": "^3.973.14", "@aws-sdk/credential-provider-web-identity": "^3.972.76", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/credential-provider-imds": "^4.4.16", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-znDkEOGXB8W3kG1LJUKP3foBZY/9qLM0eil/DxWXSp37XsdsRLQHE/d/OaCGGVgKpA6znR38h/+INk8do1FjiA=="],
|
||||||
|
|
||||||
"@aws-sdk/credential-provider-process": ["@aws-sdk/credential-provider-process@3.972.70", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-2ry03fGRJr4sV3jI+ocjj5JqALnFD6ymM5KiNCDZMvq8bX2GSbE0vji4aM43TVCl2nXqqLRZaUxdq/KeWRAY4Q=="],
|
"@aws-sdk/credential-provider-process": ["@aws-sdk/credential-provider-process@3.972.80", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-xqfixO5aclje7tbQJDias+iNND5wp/3QZixCdZcVQpgWPTZ0V5DfTW9A804A5Z7ezu7sH3WRO+vzUjtiJBA8yg=="],
|
||||||
|
|
||||||
"@aws-sdk/credential-provider-sso": ["@aws-sdk/credential-provider-sso@3.973.14", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/token-providers": "3.1116.0", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-jkhg/8ocAAoc0RFyLMhCw+/zZh7gystQgd4F4hznNa8P4Cc501PQmxd+jGLiMHodPJ+7Zv/3znM62gZojyasmA=="],
|
"@aws-sdk/credential-provider-sso": ["@aws-sdk/credential-provider-sso@3.973.24", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/token-providers": "3.1161.0", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-nlg3BKG03Cgzvv/dMnhxvDJPhAhQSpaN0RUdwgU7ziwkasoev7iI8el8Xy4Rd5sqzgaDUbV269fOXck5SargqA=="],
|
||||||
|
|
||||||
"@aws-sdk/credential-provider-web-identity": ["@aws-sdk/credential-provider-web-identity@3.972.76", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-d3AGyVu759PGr35mEB2s22xxlNEA5rpdxtSPJthfPFJvoQ8dt357iVPECqWfUxXp1toJAvKmbtcIYVGigaGsCA=="],
|
"@aws-sdk/credential-provider-web-identity": ["@aws-sdk/credential-provider-web-identity@3.972.86", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-zKTyLJBEyfQBVlYqT6Jt+mYV4r8kGbWM7dn6v4Y4MRARizhYafjDXP/iMu76UMRhToSPNmIKX1XAb24gtpBFIA=="],
|
||||||
|
|
||||||
"@aws-sdk/eventstream-handler-node": ["@aws-sdk/eventstream-handler-node@3.972.34", "", { "dependencies": { "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-cTeVzpu1xEAkryTZBYhGwnQ6gOGyp8ZYZvmn0Sg/nI/ABmy/CRHHxPDJDUi9PxwxUtGGaatvfRUB3FCgT/rSWw=="],
|
"@aws-sdk/eventstream-handler-node": ["@aws-sdk/eventstream-handler-node@3.972.34", "", { "dependencies": { "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-cTeVzpu1xEAkryTZBYhGwnQ6gOGyp8ZYZvmn0Sg/nI/ABmy/CRHHxPDJDUi9PxwxUtGGaatvfRUB3FCgT/rSWw=="],
|
||||||
|
|
||||||
@@ -618,17 +618,17 @@
|
|||||||
|
|
||||||
"@dnd-kit/state": ["@dnd-kit/state@0.5.0", "", { "dependencies": { "@preact/signals-core": "^1.10.0", "tslib": "^2.6.2" } }, "sha512-y7XbabQqjF58Lk8YmDQuR8l6QjN+Kh4qlGEjUvHuIeasLk1QP+9L5diXS98VMxQIivyMmUtX2//f+3N7qPJX4w=="],
|
"@dnd-kit/state": ["@dnd-kit/state@0.5.0", "", { "dependencies": { "@preact/signals-core": "^1.10.0", "tslib": "^2.6.2" } }, "sha512-y7XbabQqjF58Lk8YmDQuR8l6QjN+Kh4qlGEjUvHuIeasLk1QP+9L5diXS98VMxQIivyMmUtX2//f+3N7qPJX4w=="],
|
||||||
|
|
||||||
"@earendil-works/chord": ["@earendil-works/chord@1.5.0", "", { "dependencies": { "@earendil-works/pi-schema": "1.5.0", "@earendil-works/pi-telemetry": "1.5.0" }, "peerDependencies": { "esbuild": "0.28.2", "ws": "8.21.0" }, "optionalPeers": ["esbuild", "ws"] }, "sha512-jf555zbCM21E03DVBDPD/Tuae0lz64YjaHx/athUxNZ/H7phVVb0dWfZsaYnxaXPQ1odW8iHEoVLOlE/prvUPg=="],
|
"@earendil-works/chord": ["@earendil-works/chord@1.7.0", "", { "dependencies": { "@earendil-works/pi-schema": "1.7.0", "@earendil-works/pi-telemetry": "1.7.0" }, "peerDependencies": { "esbuild": "^0.28.2", "react": "^19.3.0", "ws": "^8.21.0" }, "optionalPeers": ["esbuild", "react", "ws"] }, "sha512-/zBlRrJkNbw0dJ4OrUzk08PC48mzOIFZQKTUE1qxQUWoPlf/xms95lEigzC30MllS+k5qqih7Clg0cTzYgPs1w=="],
|
||||||
|
|
||||||
"@earendil-works/pi-ai": ["@earendil-works/pi-ai@1.5.0", "", { "dependencies": { "@anthropic-ai/sdk": "0.129.0", "@aws-sdk/client-bedrock-runtime": "3.1127.0", "@earendil-works/pi-schema": "1.5.0", "@earendil-works/pi-telemetry": "1.5.0", "@google/genai": "2.21.0", "@smithy/node-http-handler": "4.12.1", "http-proxy-agent": "9.1.0", "https-proxy-agent": "9.1.0", "openai": "7.19.0", "partial-json": "0.1.7" }, "bin": { "pi-ai": "dist/cli.js" } }, "sha512-VeWxNqTHSqRCf8AcY/6kvNwh+neRL6MPxZPePVztIQy6qqK9MR/YoCSN/ZgDnIyCD3pqEXgRyQbzk4KV4uvjbg=="],
|
"@earendil-works/pi-ai": ["@earendil-works/pi-ai@1.7.0", "", { "dependencies": { "@anthropic-ai/sdk": "0.129.0", "@aws-sdk/client-bedrock-runtime": "3.1127.0", "@aws-sdk/credential-provider-node": "3.972.82", "@earendil-works/pi-schema": "1.7.0", "@earendil-works/pi-telemetry": "1.7.0", "@google/genai": "3.6.1", "@smithy/node-http-handler": "4.12.1", "http-proxy-agent": "9.1.0", "https-proxy-agent": "9.1.0", "openai": "7.59.0", "partial-json": "0.1.7" }, "bin": { "pi-ai": "dist/cli.js" } }, "sha512-iKryMlUYniwWbU7YU0uS7W0+cGd9c6oJ6PzRLOn8j4+1njG4c+BQq1cNawctx/npDqGeOx8ME7Gkgl6K6arPuw=="],
|
||||||
|
|
||||||
"@earendil-works/pi-codemode": ["@earendil-works/pi-codemode@1.5.0", "", { "dependencies": { "quickjs-wasi": "3.6.2" } }, "sha512-PLBJZ17AEWGzOlAAcFuOkw3PxkOti0JlFuZQyeF2GRTqbpuYo4k9t8YqUV2uOQVzrUnKdxahwaFUqc1eNS1WAg=="],
|
"@earendil-works/pi-codemode": ["@earendil-works/pi-codemode@1.7.0", "", { "dependencies": { "quickjs-wasi": "3.6.2" } }, "sha512-fhCoh8TLxhdRTOWSEplwp39Uv+JTsu9pCqtgu9gorO8zcaw92vsbVI/G89yFs92csTo2+yB7EsJq/+725Vj+eA=="],
|
||||||
|
|
||||||
"@earendil-works/pi-durable": ["@earendil-works/pi-durable@1.5.0", "", { "dependencies": { "@earendil-works/chord": "1.5.0", "@earendil-works/pi-ai": "1.5.0", "@earendil-works/pi-codemode": "1.5.0", "@earendil-works/pi-schema": "1.5.0", "@earendil-works/pi-telemetry": "1.5.0", "@silvia-odwyer/photon": "0.3.3", "diff": "8.0.4" } }, "sha512-xeBP2vIo5NvsCMQ4Y/V+Z164xQEi9JWiBWHdjn4Z15EnFqV3c0FxJAX26FqyyyintrYyk+Enre94GNcvRlBA5g=="],
|
"@earendil-works/pi-durable": ["@earendil-works/pi-durable@1.7.0", "", { "dependencies": { "@earendil-works/chord": "1.7.0", "@earendil-works/pi-ai": "1.7.0", "@earendil-works/pi-codemode": "1.7.0", "@earendil-works/pi-schema": "1.7.0", "@earendil-works/pi-telemetry": "1.7.0", "@silvia-odwyer/photon": "0.3.3", "diff": "8.0.4" } }, "sha512-qL9PlFfXrirBNt7QR2bjZfviN6ZVcsGTHEqaj6U4Lxqqx9Vtth7LyIuGNlG2chDKMr3/ABamH8qZ9ggMgTGDOQ=="],
|
||||||
|
|
||||||
"@earendil-works/pi-schema": ["@earendil-works/pi-schema@1.5.0", "", {}, "sha512-RW0MbT2tR65OY6xMsgB/yVBb7m/RTNwA+9hurSN1vVXfHZRVmVnXbruBPrx/PzbrQnW5yLVlMRWxErGDQtF1Hg=="],
|
"@earendil-works/pi-schema": ["@earendil-works/pi-schema@1.7.0", "", {}, "sha512-skji4McLg9jum3NFWzFa/4QRGEZhMGnSi3QL8b9VljJkc/QopH2/BFuGKI+VcEwYzKGwsd0I8RzvXGnZGfGltQ=="],
|
||||||
|
|
||||||
"@earendil-works/pi-telemetry": ["@earendil-works/pi-telemetry@1.5.0", "", {}, "sha512-VW3tcVdnNfl/Vk8wHPTzZdKkxcsCOM12ppiO4DXnd9wMxUCmOfLt/wvUnWeKWbTVlVSRg0uqKtnnhE2UCsG2Bw=="],
|
"@earendil-works/pi-telemetry": ["@earendil-works/pi-telemetry@1.7.0", "", {}, "sha512-QZkngqktohuFZ2TZuJSXDuUntld4sCMW1tkUPaD4moMEX/z1lwcjycXnd9ChO9HNxm/Jfo+UTiC+N2hkAF9b0w=="],
|
||||||
|
|
||||||
"@electric-sql/pglite": ["@electric-sql/pglite@0.4.3", "", {}, "sha512-ichuWTgtd4mOM1G4SpyGJa5trT03lWbMypDV0fUXUCXg5hiHqVAz/bZyV68NqmkLB7WcYmj1RMJVSp8HV/v/ZQ=="],
|
"@electric-sql/pglite": ["@electric-sql/pglite@0.4.3", "", {}, "sha512-ichuWTgtd4mOM1G4SpyGJa5trT03lWbMypDV0fUXUCXg5hiHqVAz/bZyV68NqmkLB7WcYmj1RMJVSp8HV/v/ZQ=="],
|
||||||
|
|
||||||
@@ -2498,7 +2498,7 @@
|
|||||||
|
|
||||||
"once": ["once@1.4.0", "", { "dependencies": { "wrappy": "1" } }, "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w=="],
|
"once": ["once@1.4.0", "", { "dependencies": { "wrappy": "1" } }, "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w=="],
|
||||||
|
|
||||||
"openai": ["openai@7.19.0", "", { "peerDependencies": { "@aws-sdk/credential-provider-node": ">=3.972.0 <4", "@smithy/hash-node": ">=4.3.0 <5", "@smithy/signature-v4": ">=5.4.0 <6", "undici": ">=5 <9", "ws": "^8.21.0", "zod": "^3.25 || ^4.0" }, "optionalPeers": ["@aws-sdk/credential-provider-node", "@smithy/hash-node", "@smithy/signature-v4", "undici", "ws", "zod"] }, "sha512-MX2s3u2L5racTO0CC/SWpCOasJQBCJrqLKXK+l82cAhdeF8mPMBEe/gxMm0ZFa2xpKpOFLRjxv5afYEZbBXmbQ=="],
|
"openai": ["openai@7.59.0", "", { "peerDependencies": { "@aws-sdk/credential-provider-node": ">=3.972.0 <4", "@smithy/hash-node": ">=4.3.0 <5", "@smithy/signature-v4": ">=5.4.0 <6", "google-auth-library": ">=9.15.1 <12", "undici": ">=5 <9", "ws": "^8.21.0", "zod": "^3.25 || ^4.0" }, "optionalPeers": ["@aws-sdk/credential-provider-node", "@smithy/hash-node", "@smithy/signature-v4", "google-auth-library", "undici", "ws", "zod"] }, "sha512-wPYKJkLPFEdNJ2tThSg4jE1Ptsv4X3u8g8LIvu0Qz/UIhsKeCzl73rl48PtQsDVrJL/ku0liXOsbyd2TsRsPJw=="],
|
||||||
|
|
||||||
"optionator": ["optionator@0.9.4", "", { "dependencies": { "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", "levn": "^0.4.1", "prelude-ls": "^1.2.1", "type-check": "^0.4.0", "word-wrap": "^1.2.5" } }, "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g=="],
|
"optionator": ["optionator@0.9.4", "", { "dependencies": { "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", "levn": "^0.4.1", "prelude-ls": "^1.2.1", "type-check": "^0.4.0", "word-wrap": "^1.2.5" } }, "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g=="],
|
||||||
|
|
||||||
@@ -3046,11 +3046,85 @@
|
|||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@smithy/node-http-handler": ["@smithy/node-http-handler@4.11.3", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-2jY1tSpERfPfWqyBV2pH+iGFaghVsIJszJNsT7hxtQYhVJpWDyc0LqOWI+nXOxOAHaEfZ4PXXtp1wW1TGpHhkA=="],
|
"@aws-sdk/client-bedrock-runtime/@smithy/node-http-handler": ["@smithy/node-http-handler@4.11.3", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-2jY1tSpERfPfWqyBV2pH+iGFaghVsIJszJNsT7hxtQYhVJpWDyc0LqOWI+nXOxOAHaEfZ4PXXtp1wW1TGpHhkA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/client-s3/@aws-sdk/credential-provider-node": ["@aws-sdk/credential-provider-node@3.972.81", "", { "dependencies": { "@aws-sdk/credential-provider-env": "^3.972.70", "@aws-sdk/credential-provider-http": "^3.972.72", "@aws-sdk/credential-provider-ini": "^3.973.15", "@aws-sdk/credential-provider-process": "^3.972.70", "@aws-sdk/credential-provider-sso": "^3.973.14", "@aws-sdk/credential-provider-web-identity": "^3.972.76", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/credential-provider-imds": "^4.4.16", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-Rml+WitoFvXmv6JZ18U/xGdGDGGvB/mOin0ya0lTnTrdC0Z1lrVxTYh7iNklZBcvcRMrs4DoEf6xy1KWyrLQQw=="],
|
||||||
|
|
||||||
"@aws-sdk/client-s3/@smithy/node-http-handler": ["@smithy/node-http-handler@4.11.3", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-2jY1tSpERfPfWqyBV2pH+iGFaghVsIJszJNsT7hxtQYhVJpWDyc0LqOWI+nXOxOAHaEfZ4PXXtp1wW1TGpHhkA=="],
|
"@aws-sdk/client-s3/@smithy/node-http-handler": ["@smithy/node-http-handler@4.11.3", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-2jY1tSpERfPfWqyBV2pH+iGFaghVsIJszJNsT7hxtQYhVJpWDyc0LqOWI+nXOxOAHaEfZ4PXXtp1wW1TGpHhkA=="],
|
||||||
|
|
||||||
"@aws-sdk/credential-provider-http/@smithy/node-http-handler": ["@smithy/node-http-handler@4.11.3", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-2jY1tSpERfPfWqyBV2pH+iGFaghVsIJszJNsT7hxtQYhVJpWDyc0LqOWI+nXOxOAHaEfZ4PXXtp1wW1TGpHhkA=="],
|
"@aws-sdk/credential-provider-env/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="],
|
||||||
|
|
||||||
"@aws-sdk/credential-provider-sso/@aws-sdk/token-providers": ["@aws-sdk/token-providers@3.1116.0", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-ygIivKqh8aHzNkucOCXHyIBgBpLPfrSI0mCqXF+vLBsPTUKqj0VSqAY0GFPe7lQl4HntjOcQ+KSyS7oUV2C54Q=="],
|
"@aws-sdk/credential-provider-env/@aws-sdk/types": ["@aws-sdk/types@3.975.0", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-env/@smithy/core": ["@smithy/core@3.38.1", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-U/mB2XiwTLaf+NSgLSWwJfptsMT/H8aBi0aTAA/E5e2/TagFeGCqAyhKGG0w0A9IWTkm4qYEmLoD/HB6aYfnRA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-env/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-http/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-http/@aws-sdk/types": ["@aws-sdk/types@3.975.0", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-http/@smithy/core": ["@smithy/core@3.38.1", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-U/mB2XiwTLaf+NSgLSWwJfptsMT/H8aBi0aTAA/E5e2/TagFeGCqAyhKGG0w0A9IWTkm4qYEmLoD/HB6aYfnRA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-http/@smithy/fetch-http-handler": ["@smithy/fetch-http-handler@5.8.0", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.18.0", "tslib": "^2.6.2" } }, "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-http/@smithy/node-http-handler": ["@smithy/node-http-handler@4.14.1", "", { "dependencies": { "@smithy/core": "^3.38.1", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/T6E1jzCL0fErS9uq8JqES/5yYQQ4ppVmmYHwXw2nlov8KFzLb+3QqHR5iAun1BsuAB50IPxZliV8YMgghLwhA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-http/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-ini/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients": ["@aws-sdk/nested-clients@3.997.54", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/signature-v4-multi-region": "^3.996.51", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/fetch-http-handler": "^5.8.0", "@smithy/node-http-handler": "^4.14.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/OczlavsS7U5sOodRO10Ug4R/AKFVZiXTstKipWe68EfjPkmdDFNXNl9FCJyXWkg1DG6RBm3qAuVB8FNW9O8KQ=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-ini/@aws-sdk/types": ["@aws-sdk/types@3.975.0", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-ini/@smithy/core": ["@smithy/core@3.38.1", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-U/mB2XiwTLaf+NSgLSWwJfptsMT/H8aBi0aTAA/E5e2/TagFeGCqAyhKGG0w0A9IWTkm4qYEmLoD/HB6aYfnRA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-ini/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-login/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-login/@aws-sdk/nested-clients": ["@aws-sdk/nested-clients@3.997.54", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/signature-v4-multi-region": "^3.996.51", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/fetch-http-handler": "^5.8.0", "@smithy/node-http-handler": "^4.14.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/OczlavsS7U5sOodRO10Ug4R/AKFVZiXTstKipWe68EfjPkmdDFNXNl9FCJyXWkg1DG6RBm3qAuVB8FNW9O8KQ=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-login/@aws-sdk/types": ["@aws-sdk/types@3.975.0", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-login/@smithy/core": ["@smithy/core@3.38.1", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-U/mB2XiwTLaf+NSgLSWwJfptsMT/H8aBi0aTAA/E5e2/TagFeGCqAyhKGG0w0A9IWTkm4qYEmLoD/HB6aYfnRA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-login/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-node/@aws-sdk/types": ["@aws-sdk/types@3.975.0", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-node/@smithy/core": ["@smithy/core@3.38.1", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-U/mB2XiwTLaf+NSgLSWwJfptsMT/H8aBi0aTAA/E5e2/TagFeGCqAyhKGG0w0A9IWTkm4qYEmLoD/HB6aYfnRA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-node/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-process/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-process/@aws-sdk/types": ["@aws-sdk/types@3.975.0", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-process/@smithy/core": ["@smithy/core@3.38.1", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-U/mB2XiwTLaf+NSgLSWwJfptsMT/H8aBi0aTAA/E5e2/TagFeGCqAyhKGG0w0A9IWTkm4qYEmLoD/HB6aYfnRA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-process/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-sso/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients": ["@aws-sdk/nested-clients@3.997.54", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/signature-v4-multi-region": "^3.996.51", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/fetch-http-handler": "^5.8.0", "@smithy/node-http-handler": "^4.14.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/OczlavsS7U5sOodRO10Ug4R/AKFVZiXTstKipWe68EfjPkmdDFNXNl9FCJyXWkg1DG6RBm3qAuVB8FNW9O8KQ=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-sso/@aws-sdk/token-providers": ["@aws-sdk/token-providers@3.1161.0", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-ypbXSofNcSHwf/KA40bFCXJb0MLaAKrfT7sot4dFaA+2lsuXNah4zLRJIAU7Qmvs9PFJ6rnY0bZFEC+mE7attA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-sso/@aws-sdk/types": ["@aws-sdk/types@3.975.0", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-sso/@smithy/core": ["@smithy/core@3.38.1", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-U/mB2XiwTLaf+NSgLSWwJfptsMT/H8aBi0aTAA/E5e2/TagFeGCqAyhKGG0w0A9IWTkm4qYEmLoD/HB6aYfnRA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-sso/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-web-identity/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients": ["@aws-sdk/nested-clients@3.997.54", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/signature-v4-multi-region": "^3.996.51", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/fetch-http-handler": "^5.8.0", "@smithy/node-http-handler": "^4.14.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/OczlavsS7U5sOodRO10Ug4R/AKFVZiXTstKipWe68EfjPkmdDFNXNl9FCJyXWkg1DG6RBm3qAuVB8FNW9O8KQ=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-web-identity/@aws-sdk/types": ["@aws-sdk/types@3.975.0", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-web-identity/@smithy/core": ["@smithy/core@3.38.1", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-U/mB2XiwTLaf+NSgLSWwJfptsMT/H8aBi0aTAA/E5e2/TagFeGCqAyhKGG0w0A9IWTkm4qYEmLoD/HB6aYfnRA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-web-identity/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="],
|
||||||
|
|
||||||
"@aws-sdk/nested-clients/@smithy/node-http-handler": ["@smithy/node-http-handler@4.11.3", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-2jY1tSpERfPfWqyBV2pH+iGFaghVsIJszJNsT7hxtQYhVJpWDyc0LqOWI+nXOxOAHaEfZ4PXXtp1wW1TGpHhkA=="],
|
"@aws-sdk/nested-clients/@smithy/node-http-handler": ["@smithy/node-http-handler@4.11.3", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-2jY1tSpERfPfWqyBV2pH+iGFaghVsIJszJNsT7hxtQYhVJpWDyc0LqOWI+nXOxOAHaEfZ4PXXtp1wW1TGpHhkA=="],
|
||||||
|
|
||||||
@@ -3060,9 +3134,7 @@
|
|||||||
|
|
||||||
"@dbos-inc/dbos-sdk/ws": ["ws@8.21.3", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw=="],
|
"@dbos-inc/dbos-sdk/ws": ["ws@8.21.3", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw=="],
|
||||||
|
|
||||||
"@earendil-works/chord/ws": ["ws@8.21.3", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw=="],
|
"@earendil-works/pi-ai/@google/genai": ["@google/genai@3.6.1", "", { "dependencies": { "google-auth-library": "^10.3.0", "p-retry": "^4.6.2", "protobufjs": "^7.6.5", "ws": "^8.21.0" }, "peerDependencies": { "@modelcontextprotocol/sdk": "^1.25.2" }, "optionalPeers": ["@modelcontextprotocol/sdk"] }, "sha512-DQIkZkl+VoZc+RUSaJ41vRuywjQDpP0t/oUf5/ddQhNW6JsPjVULW2EgHmuJ1mrr6ACtrmUdPlqtNXF1yfKySg=="],
|
||||||
|
|
||||||
"@earendil-works/pi-ai/@google/genai": ["@google/genai@2.21.0", "", { "dependencies": { "google-auth-library": "^10.3.0", "p-retry": "^4.6.2", "protobufjs": "^7.5.4", "ws": "^8.18.0" }, "peerDependencies": { "@modelcontextprotocol/sdk": "^1.25.2" }, "optionalPeers": ["@modelcontextprotocol/sdk"], "hasInstallScript": true }, "sha512-+PDtco2/Z0ONdzCGekCoCT+O1VJS9xJQNN4XzQpXG/t3El/SWWMkCWlFRO1KmivOHPa4Q0VjUYu1HBKCZ/v33Q=="],
|
|
||||||
|
|
||||||
"@eslint-community/eslint-utils/eslint-visitor-keys": ["eslint-visitor-keys@3.4.3", "", {}, "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag=="],
|
"@eslint-community/eslint-utils/eslint-visitor-keys": ["eslint-visitor-keys@3.4.3", "", {}, "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag=="],
|
||||||
|
|
||||||
@@ -3320,25 +3392,77 @@
|
|||||||
|
|
||||||
"wrap-ansi-cjs/ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="],
|
"wrap-ansi-cjs/ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-env": ["@aws-sdk/credential-provider-env@3.972.80", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-uO5TiSvb6j1w9RTe5z28OaOmsrOxVQUPaC5+wZl50RfOXcrYD/KgnS8I9lfyGXc7sGbkCopK6VnhNIAoLqfewQ=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-http": ["@aws-sdk/credential-provider-http@3.972.82", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/fetch-http-handler": "^5.8.0", "@smithy/node-http-handler": "^4.14.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-vQzlDHlC24Yz42p+rT4NBoP/5VdetkBoujbOLq9h6QYWC8THuZSPYnXIR9OP3XcOrdMgPBBipOrdssfxnIiWUg=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini": ["@aws-sdk/credential-provider-ini@3.973.25", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/credential-provider-env": "^3.972.80", "@aws-sdk/credential-provider-http": "^3.972.82", "@aws-sdk/credential-provider-login": "^3.972.87", "@aws-sdk/credential-provider-process": "^3.972.80", "@aws-sdk/credential-provider-sso": "^3.973.24", "@aws-sdk/credential-provider-web-identity": "^3.972.86", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/credential-provider-imds": "^4.5.2", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-b5xl71uCRdWsu7P1VeGpiGuCf6zfYETsSNOv8AmYVTrsgbvTJRXdmmOPVfxkvGGVNsiKkGctClQW3jAn0SZLug=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-process": ["@aws-sdk/credential-provider-process@3.972.80", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-xqfixO5aclje7tbQJDias+iNND5wp/3QZixCdZcVQpgWPTZ0V5DfTW9A804A5Z7ezu7sH3WRO+vzUjtiJBA8yg=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso": ["@aws-sdk/credential-provider-sso@3.973.24", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/token-providers": "3.1161.0", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-nlg3BKG03Cgzvv/dMnhxvDJPhAhQSpaN0RUdwgU7ziwkasoev7iI8el8Xy4Rd5sqzgaDUbV269fOXck5SargqA=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity": ["@aws-sdk/credential-provider-web-identity@3.972.86", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-zKTyLJBEyfQBVlYqT6Jt+mYV4r8kGbWM7dn6v4Y4MRARizhYafjDXP/iMu76UMRhToSPNmIKX1XAb24gtpBFIA=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/types": ["@aws-sdk/types@3.975.0", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw=="],
|
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/types": ["@aws-sdk/types@3.975.0", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@smithy/core": ["@smithy/core@3.38.1", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-U/mB2XiwTLaf+NSgLSWwJfptsMT/H8aBi0aTAA/E5e2/TagFeGCqAyhKGG0w0A9IWTkm4qYEmLoD/HB6aYfnRA=="],
|
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@smithy/core": ["@smithy/core@3.38.1", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-U/mB2XiwTLaf+NSgLSWwJfptsMT/H8aBi0aTAA/E5e2/TagFeGCqAyhKGG0w0A9IWTkm4qYEmLoD/HB6aYfnRA=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="],
|
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="],
|
||||||
|
|
||||||
"@earendil-works/pi-ai/@google/genai/ws": ["ws@8.21.3", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw=="],
|
"@aws-sdk/client-s3/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-env": ["@aws-sdk/credential-provider-env@3.972.70", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-H404B7dJl2mCrBqahDEYsanB0xhdDp6tXnXcTUnXmmpy2Q3J0Ho0bUajZ2jr/RdwzCyS59Gi8xXIFwPLGBl6Uw=="],
|
||||||
|
|
||||||
|
"@aws-sdk/client-s3/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-http": ["@aws-sdk/credential-provider-http@3.972.72", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/fetch-http-handler": "^5.7.2", "@smithy/node-http-handler": "^4.11.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-X98zYOrVOeuosCX+6ktf29FC2N2GHPLia7qv6mzPzTc+RPAuHWCDS++Z6JK7eGYqb/v6uaW7bAXaOvDBfol+0w=="],
|
||||||
|
|
||||||
|
"@aws-sdk/client-s3/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini": ["@aws-sdk/credential-provider-ini@3.973.15", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/credential-provider-env": "^3.972.70", "@aws-sdk/credential-provider-http": "^3.972.72", "@aws-sdk/credential-provider-login": "^3.972.77", "@aws-sdk/credential-provider-process": "^3.972.70", "@aws-sdk/credential-provider-sso": "^3.973.14", "@aws-sdk/credential-provider-web-identity": "^3.972.76", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/credential-provider-imds": "^4.4.16", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-Rykg6s5ceBuynMOGWgoowO4N+27JfnqXAnVaSunZl0hOO1XodSrxGNz6sCEbnmS0lAfQZDKyb3fbr46gSuv6Sg=="],
|
||||||
|
|
||||||
|
"@aws-sdk/client-s3/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-process": ["@aws-sdk/credential-provider-process@3.972.70", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-2ry03fGRJr4sV3jI+ocjj5JqALnFD6ymM5KiNCDZMvq8bX2GSbE0vji4aM43TVCl2nXqqLRZaUxdq/KeWRAY4Q=="],
|
||||||
|
|
||||||
|
"@aws-sdk/client-s3/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso": ["@aws-sdk/credential-provider-sso@3.973.14", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/token-providers": "3.1116.0", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-jkhg/8ocAAoc0RFyLMhCw+/zZh7gystQgd4F4hznNa8P4Cc501PQmxd+jGLiMHodPJ+7Zv/3znM62gZojyasmA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/client-s3/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity": ["@aws-sdk/credential-provider-web-identity@3.972.76", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-d3AGyVu759PGr35mEB2s22xxlNEA5rpdxtSPJthfPFJvoQ8dt357iVPECqWfUxXp1toJAvKmbtcIYVGigaGsCA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-env/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-env/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-http/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-http/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-http/@smithy/fetch-http-handler/@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-ini/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-ini/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region": ["@aws-sdk/signature-v4-multi-region@3.996.51", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-+aHvUugVBuMPXxgkPfWnTMyGdE/yWS8GHi5+qQ37HowS0YqzrbuaDLznj+Dtmtu5jgCdqz36gXmujOToUhNNWw=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@smithy/fetch-http-handler": ["@smithy/fetch-http-handler@5.8.0", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.18.0", "tslib": "^2.6.2" } }, "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@smithy/node-http-handler": ["@smithy/node-http-handler@4.14.1", "", { "dependencies": { "@smithy/core": "^3.38.1", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/T6E1jzCL0fErS9uq8JqES/5yYQQ4ppVmmYHwXw2nlov8KFzLb+3QqHR5iAun1BsuAB50IPxZliV8YMgghLwhA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-login/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-login/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-login/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region": ["@aws-sdk/signature-v4-multi-region@3.996.51", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-+aHvUugVBuMPXxgkPfWnTMyGdE/yWS8GHi5+qQ37HowS0YqzrbuaDLznj+Dtmtu5jgCdqz36gXmujOToUhNNWw=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-login/@aws-sdk/nested-clients/@smithy/fetch-http-handler": ["@smithy/fetch-http-handler@5.8.0", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.18.0", "tslib": "^2.6.2" } }, "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-login/@aws-sdk/nested-clients/@smithy/node-http-handler": ["@smithy/node-http-handler@4.14.1", "", { "dependencies": { "@smithy/core": "^3.38.1", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/T6E1jzCL0fErS9uq8JqES/5yYQQ4ppVmmYHwXw2nlov8KFzLb+3QqHR5iAun1BsuAB50IPxZliV8YMgghLwhA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-process/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-process/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-sso/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-sso/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region": ["@aws-sdk/signature-v4-multi-region@3.996.51", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-+aHvUugVBuMPXxgkPfWnTMyGdE/yWS8GHi5+qQ37HowS0YqzrbuaDLznj+Dtmtu5jgCdqz36gXmujOToUhNNWw=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@smithy/fetch-http-handler": ["@smithy/fetch-http-handler@5.8.0", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.18.0", "tslib": "^2.6.2" } }, "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@smithy/node-http-handler": ["@smithy/node-http-handler@4.14.1", "", { "dependencies": { "@smithy/core": "^3.38.1", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/T6E1jzCL0fErS9uq8JqES/5yYQQ4ppVmmYHwXw2nlov8KFzLb+3QqHR5iAun1BsuAB50IPxZliV8YMgghLwhA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-web-identity/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-web-identity/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region": ["@aws-sdk/signature-v4-multi-region@3.996.51", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-+aHvUugVBuMPXxgkPfWnTMyGdE/yWS8GHi5+qQ37HowS0YqzrbuaDLznj+Dtmtu5jgCdqz36gXmujOToUhNNWw=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@smithy/fetch-http-handler": ["@smithy/fetch-http-handler@5.8.0", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.18.0", "tslib": "^2.6.2" } }, "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA=="],
|
||||||
|
|
||||||
|
"@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@smithy/node-http-handler": ["@smithy/node-http-handler@4.14.1", "", { "dependencies": { "@smithy/core": "^3.38.1", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/T6E1jzCL0fErS9uq8JqES/5yYQQ4ppVmmYHwXw2nlov8KFzLb+3QqHR5iAun1BsuAB50IPxZliV8YMgghLwhA=="],
|
||||||
|
|
||||||
"@isaacs/cliui/string-width/emoji-regex": ["emoji-regex@9.2.2", "", {}, "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="],
|
"@isaacs/cliui/string-width/emoji-regex": ["emoji-regex@9.2.2", "", {}, "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="],
|
||||||
|
|
||||||
@@ -3456,31 +3580,27 @@
|
|||||||
|
|
||||||
"readdir-glob/minimatch/brace-expansion": ["brace-expansion@2.1.4", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg=="],
|
"readdir-glob/minimatch/brace-expansion": ["brace-expansion@2.1.4", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-env/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="],
|
"@aws-sdk/client-s3/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/credential-provider-login": ["@aws-sdk/credential-provider-login@3.972.77", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-Jb59xfEISoN5mmbnA+HYqdtrSX3CgCtJoof+V5D8/TgUI56W63GEEd5Y58WijU3Ou6+WEgaLD1feVzaRXV5IDQ=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-http/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="],
|
"@aws-sdk/client-s3/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/token-providers": ["@aws-sdk/token-providers@3.1116.0", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/nested-clients": "^3.997.44", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-ygIivKqh8aHzNkucOCXHyIBgBpLPfrSI0mCqXF+vLBsPTUKqj0VSqAY0GFPe7lQl4HntjOcQ+KSyS7oUV2C54Q=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-http/@smithy/fetch-http-handler": ["@smithy/fetch-http-handler@5.8.0", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.18.0", "tslib": "^2.6.2" } }, "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA=="],
|
"@aws-sdk/credential-provider-http/@smithy/fetch-http-handler/@smithy/core/@smithy/types": ["@smithy/types@4.17.2", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-FOKpVZob9MPTn2znRzGrnsMHv7BOsKVw3XiP/cOyYLDVZ9qKp4nifIiSCuUU/fIj5Vu0UOAxCFr+qRAtG0NUkA=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-http/@smithy/node-http-handler": ["@smithy/node-http-handler@4.14.1", "", { "dependencies": { "@smithy/core": "^3.38.1", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/T6E1jzCL0fErS9uq8JqES/5yYQQ4ppVmmYHwXw2nlov8KFzLb+3QqHR5iAun1BsuAB50IPxZliV8YMgghLwhA=="],
|
"@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="],
|
"@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/credential-provider-login": ["@aws-sdk/credential-provider-login@3.972.87", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-C4ZFmcwM+Zj14Z8huVUk54Gv4uzT1ZdzG9cY3Gdh8FePakq7Bss1OFsgZjAhWFOkFOGpBvFBeu0OWjWf8HNKRQ=="],
|
"@aws-sdk/credential-provider-login/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients": ["@aws-sdk/nested-clients@3.997.54", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/signature-v4-multi-region": "^3.996.51", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/fetch-http-handler": "^5.8.0", "@smithy/node-http-handler": "^4.14.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/OczlavsS7U5sOodRO10Ug4R/AKFVZiXTstKipWe68EfjPkmdDFNXNl9FCJyXWkg1DG6RBm3qAuVB8FNW9O8KQ=="],
|
"@aws-sdk/credential-provider-login/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-process/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="],
|
"@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="],
|
"@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients": ["@aws-sdk/nested-clients@3.997.54", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/signature-v4-multi-region": "^3.996.51", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/fetch-http-handler": "^5.8.0", "@smithy/node-http-handler": "^4.14.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/OczlavsS7U5sOodRO10Ug4R/AKFVZiXTstKipWe68EfjPkmdDFNXNl9FCJyXWkg1DG6RBm3qAuVB8FNW9O8KQ=="],
|
"@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/token-providers": ["@aws-sdk/token-providers@3.1161.0", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/nested-clients": "^3.997.54", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-ypbXSofNcSHwf/KA40bFCXJb0MLaAKrfT7sot4dFaA+2lsuXNah4zLRJIAU7Qmvs9PFJ6rnY0bZFEC+mE7attA=="],
|
"@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/core": ["@aws-sdk/core@3.979.1", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@aws-sdk/xml-builder": "^3.972.42", "@aws/lambda-invoke-store": "^0.3.0", "@smithy/core": "^3.38.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-ayOlV1VhLNMiq8PW9ZkVobG4gkldnUoHjG69yy2b8j+VYFlhz/uAL7ZdYQAoQ+eShtGUdNDnnG5rxDg6yUJrOg=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients": ["@aws-sdk/nested-clients@3.997.54", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/signature-v4-multi-region": "^3.996.51", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/fetch-http-handler": "^5.8.0", "@smithy/node-http-handler": "^4.14.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/OczlavsS7U5sOodRO10Ug4R/AKFVZiXTstKipWe68EfjPkmdDFNXNl9FCJyXWkg1DG6RBm3qAuVB8FNW9O8KQ=="],
|
|
||||||
|
|
||||||
"@prisma/studio-core/@radix-ui/react-toggle/@radix-ui/react-primitive/@radix-ui/react-slot": ["@radix-ui/react-slot@1.2.3", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.2" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A=="],
|
"@prisma/studio-core/@radix-ui/react-toggle/@radix-ui/react-primitive/@radix-ui/react-slot": ["@radix-ui/react-slot@1.2.3", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.2" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A=="],
|
||||||
|
|
||||||
@@ -3508,70 +3628,14 @@
|
|||||||
|
|
||||||
"readdir-glob/minimatch/brace-expansion/balanced-match": ["balanced-match@1.0.2", "", {}, "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="],
|
"readdir-glob/minimatch/brace-expansion/balanced-match": ["balanced-match@1.0.2", "", {}, "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-env/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="],
|
"@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core/@smithy/types": ["@smithy/types@4.17.2", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-FOKpVZob9MPTn2znRzGrnsMHv7BOsKVw3XiP/cOyYLDVZ9qKp4nifIiSCuUU/fIj5Vu0UOAxCFr+qRAtG0NUkA=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-env/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
"@aws-sdk/credential-provider-login/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core/@smithy/types": ["@smithy/types@4.17.2", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-FOKpVZob9MPTn2znRzGrnsMHv7BOsKVw3XiP/cOyYLDVZ9qKp4nifIiSCuUU/fIj5Vu0UOAxCFr+qRAtG0NUkA=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-http/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="],
|
"@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core/@smithy/types": ["@smithy/types@4.17.2", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-FOKpVZob9MPTn2znRzGrnsMHv7BOsKVw3XiP/cOyYLDVZ9qKp4nifIiSCuUU/fIj5Vu0UOAxCFr+qRAtG0NUkA=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-http/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
"@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core/@smithy/types": ["@smithy/types@4.17.2", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-FOKpVZob9MPTn2znRzGrnsMHv7BOsKVw3XiP/cOyYLDVZ9qKp4nifIiSCuUU/fIj5Vu0UOAxCFr+qRAtG0NUkA=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-http/@smithy/fetch-http-handler/@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region": ["@aws-sdk/signature-v4-multi-region@3.996.51", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-+aHvUugVBuMPXxgkPfWnTMyGdE/yWS8GHi5+qQ37HowS0YqzrbuaDLznj+Dtmtu5jgCdqz36gXmujOToUhNNWw=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@smithy/fetch-http-handler": ["@smithy/fetch-http-handler@5.8.0", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.18.0", "tslib": "^2.6.2" } }, "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@smithy/node-http-handler": ["@smithy/node-http-handler@4.14.1", "", { "dependencies": { "@smithy/core": "^3.38.1", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/T6E1jzCL0fErS9uq8JqES/5yYQQ4ppVmmYHwXw2nlov8KFzLb+3QqHR5iAun1BsuAB50IPxZliV8YMgghLwhA=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-process/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-process/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region": ["@aws-sdk/signature-v4-multi-region@3.996.51", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-+aHvUugVBuMPXxgkPfWnTMyGdE/yWS8GHi5+qQ37HowS0YqzrbuaDLznj+Dtmtu5jgCdqz36gXmujOToUhNNWw=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@smithy/fetch-http-handler": ["@smithy/fetch-http-handler@5.8.0", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.18.0", "tslib": "^2.6.2" } }, "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@smithy/node-http-handler": ["@smithy/node-http-handler@4.14.1", "", { "dependencies": { "@smithy/core": "^3.38.1", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/T6E1jzCL0fErS9uq8JqES/5yYQQ4ppVmmYHwXw2nlov8KFzLb+3QqHR5iAun1BsuAB50IPxZliV8YMgghLwhA=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/core/@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.42", "", { "dependencies": { "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/core/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region": ["@aws-sdk/signature-v4-multi-region@3.996.51", "", { "dependencies": { "@aws-sdk/types": "^3.975.0", "@smithy/signature-v4": "^5.7.5", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-+aHvUugVBuMPXxgkPfWnTMyGdE/yWS8GHi5+qQ37HowS0YqzrbuaDLznj+Dtmtu5jgCdqz36gXmujOToUhNNWw=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@smithy/fetch-http-handler": ["@smithy/fetch-http-handler@5.8.0", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.18.0", "tslib": "^2.6.2" } }, "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@smithy/node-http-handler": ["@smithy/node-http-handler@4.14.1", "", { "dependencies": { "@smithy/core": "^3.38.1", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-/T6E1jzCL0fErS9uq8JqES/5yYQQ4ppVmmYHwXw2nlov8KFzLb+3QqHR5iAun1BsuAB50IPxZliV8YMgghLwhA=="],
|
|
||||||
|
|
||||||
"@prisma/studio-core/@radix-ui/react-toggle/@radix-ui/react-primitive/@radix-ui/react-slot/@radix-ui/react-compose-refs": ["@radix-ui/react-compose-refs@1.1.2", "", { "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-z4eqJvfiNnFMHIIvXP3CY57y2WJs5g2v3X0zm9mEJkrkNv4rDxu+sg9Jh8EkXyeqBkB7SOcboo9dMVqhyrACIg=="],
|
"@prisma/studio-core/@radix-ui/react-toggle/@radix-ui/react-primitive/@radix-ui/react-slot/@radix-ui/react-compose-refs": ["@radix-ui/react-compose-refs@1.1.2", "", { "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-z4eqJvfiNnFMHIIvXP3CY57y2WJs5g2v3X0zm9mEJkrkNv4rDxu+sg9Jh8EkXyeqBkB7SOcboo9dMVqhyrACIg=="],
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-http/@smithy/fetch-http-handler/@smithy/core/@smithy/types": ["@smithy/types@4.17.2", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-FOKpVZob9MPTn2znRzGrnsMHv7BOsKVw3XiP/cOyYLDVZ9qKp4nifIiSCuUU/fIj5Vu0UOAxCFr+qRAtG0NUkA=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@aws-sdk/signature-v4-multi-region/@smithy/signature-v4": ["@smithy/signature-v4@5.7.5", "", { "dependencies": { "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-ini/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core/@smithy/types": ["@smithy/types@4.17.2", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-FOKpVZob9MPTn2znRzGrnsMHv7BOsKVw3XiP/cOyYLDVZ9qKp4nifIiSCuUU/fIj5Vu0UOAxCFr+qRAtG0NUkA=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-sso/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core/@smithy/types": ["@smithy/types@4.17.2", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-FOKpVZob9MPTn2znRzGrnsMHv7BOsKVw3XiP/cOyYLDVZ9qKp4nifIiSCuUU/fIj5Vu0UOAxCFr+qRAtG0NUkA=="],
|
|
||||||
|
|
||||||
"@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-web-identity/@aws-sdk/nested-clients/@smithy/fetch-http-handler/@smithy/core/@smithy/types": ["@smithy/types@4.17.2", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-FOKpVZob9MPTn2znRzGrnsMHv7BOsKVw3XiP/cOyYLDVZ9qKp4nifIiSCuUU/fIj5Vu0UOAxCFr+qRAtG0NUkA=="],
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ When creating agents for chat or metadata autofill, you must select an underlyin
|
|||||||
|
|
||||||
## Built-In Providers
|
## Built-In Providers
|
||||||
|
|
||||||
Shumai ships with pre-configured configurations for major LLM providers. Because Shumai uses [Pi](https://github.com/earendil-works/pi) as its core agent framework, the supported provider and model configurations are automatically synchronized with Pi's capabilities.
|
Shumai seeds new teams with provider and model configurations bundled with [Pi](https://github.com/earendil-works/pi). In **Settings → Providers**, choose **Refresh models** on a provider card, select compatible models, then choose **Add selected**. Refresh looks up the public catalog and preserves your saved settings and models. Use **Add Provider** to set up another provider.
|
||||||
|
|
||||||
Team Owner can freely edit, delete, or add new providers. All configured provider and model settings are injected directly into the Pi framework at runtime.
|
Team Owner can freely edit, delete, or add new providers. All configured provider and model settings are injected directly into the Pi framework at runtime.
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ description: 将 Shumai 连接至 OpenAI、Anthropic、Gemini 或自定义 LLM
|
|||||||
|
|
||||||
## 内置模型服务商
|
## 内置模型服务商
|
||||||
|
|
||||||
Shumai 预置了主流 LLM 服务商的配置。由于 Shumai 采用 [Pi](https://github.com/earendil-works/pi) 作为底层核心智能体框架,系统支持的服务商与模型配置会自动与 Pi 的功能生态保持同步。
|
Shumai 使用 [Pi](https://github.com/earendil-works/pi) 随附的服务商与模型配置初始化新团队。在**设置 → 服务商**中,点击服务商卡片上的**刷新模型**,选择兼容的模型,然后点击**添加所选**。刷新会查询公开模型目录,并保留现有设置和模型。若要设置其他服务商,请点击**添加服务商**。
|
||||||
|
|
||||||
团队所有者可自由编辑、删除或添加新服务商。所有已配置的服务商与模型参数均会在运行时直接注入 Pi 框架。
|
团队所有者可自由编辑、删除或添加新服务商。所有已配置的服务商与模型参数均会在运行时直接注入 Pi 框架。
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
"main": "./src/index.ts",
|
"main": "./src/index.ts",
|
||||||
"types": "./src/index.ts",
|
"types": "./src/index.ts",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@earendil-works/chord": "1.5.0",
|
"@earendil-works/chord": "1.7.0",
|
||||||
"@earendil-works/pi-ai": "1.5.0",
|
"@earendil-works/pi-ai": "1.7.0",
|
||||||
"@earendil-works/pi-durable": "1.5.0",
|
"@earendil-works/pi-durable": "1.7.0",
|
||||||
"@google/genai": "2.28.0",
|
"@google/genai": "2.28.0",
|
||||||
"@shumai/core": "workspace:*",
|
"@shumai/core": "workspace:*",
|
||||||
"@shumai/db": "workspace:*",
|
"@shumai/db": "workspace:*",
|
||||||
|
|||||||
@@ -0,0 +1,180 @@
|
|||||||
|
import { execFile } from 'node:child_process'
|
||||||
|
import { mkdtemp, rm } from 'node:fs/promises'
|
||||||
|
import { tmpdir } from 'node:os'
|
||||||
|
import { join } from 'node:path'
|
||||||
|
import { promisify } from 'node:util'
|
||||||
|
import { logger } from '@shumai/core/src/logger'
|
||||||
|
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||||
|
import {
|
||||||
|
isLocalTranscriptionEnabled,
|
||||||
|
LocalTranscriptionError,
|
||||||
|
transcribeLocalAudio,
|
||||||
|
} from '@shumai/core/src/transcript/local-transcription'
|
||||||
|
import { transcriptService } from '@shumai/core/src/transcript/transcript'
|
||||||
|
import { selectPrimaryAudioStream } from '@shumai/core/src/transcode/transcode'
|
||||||
|
import { prisma } from '@shumai/db'
|
||||||
|
import { transcriptionErrors } from '@shumai/dtos'
|
||||||
|
import {
|
||||||
|
ApplicationFailure,
|
||||||
|
defineStep,
|
||||||
|
ensureLocalMediaFile,
|
||||||
|
getLocalTaskAbortSignal,
|
||||||
|
} from '@shumai/workflow-core'
|
||||||
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
const execFileAsync = promisify(execFile)
|
||||||
|
|
||||||
|
const audioProbeSchema = z.object({
|
||||||
|
streams: z.array(
|
||||||
|
z.object({
|
||||||
|
index: z.number().int().nonnegative(),
|
||||||
|
// eslint-disable-next-line @typescript-eslint/naming-convention -- ffprobe field
|
||||||
|
codec_type: z.string(),
|
||||||
|
// eslint-disable-next-line @typescript-eslint/naming-convention -- ffprobe field
|
||||||
|
bit_rate: z.string().optional(),
|
||||||
|
disposition: z.record(z.string(), z.number()).optional(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
})
|
||||||
|
|
||||||
|
async function removeTempDirectory(directory: string): Promise<void> {
|
||||||
|
try {
|
||||||
|
await rm(directory, { recursive: true, force: true })
|
||||||
|
} catch (error) {
|
||||||
|
logger.warn({ err: error, directory }, 'Failed to remove local transcription files')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const extractTranscriptAudioActivity = defineStep(
|
||||||
|
async function extractTranscriptAudioActivity({
|
||||||
|
assetId,
|
||||||
|
taskId,
|
||||||
|
audioKey,
|
||||||
|
}: {
|
||||||
|
assetId: string
|
||||||
|
taskId: string
|
||||||
|
audioKey: string
|
||||||
|
}): Promise<void> {
|
||||||
|
if (!isLocalTranscriptionEnabled()) {
|
||||||
|
throw ApplicationFailure.create({
|
||||||
|
message: 'Local transcription is disabled',
|
||||||
|
nonRetryable: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const asset = await prisma.asset.findFirst({
|
||||||
|
where: {
|
||||||
|
id: assetId,
|
||||||
|
type: 'file',
|
||||||
|
status: 'processed',
|
||||||
|
isDeleted: false,
|
||||||
|
mediaType: { startsWith: 'video/' },
|
||||||
|
storageKey: { status: 'active', isArchived: false },
|
||||||
|
},
|
||||||
|
select: { storageKey: { select: { key: true } } },
|
||||||
|
})
|
||||||
|
if (!asset?.storageKey) {
|
||||||
|
throw ApplicationFailure.create({
|
||||||
|
message: 'Video is no longer available',
|
||||||
|
nonRetryable: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const signal = getLocalTaskAbortSignal(taskId)
|
||||||
|
const directory = await mkdtemp(join(tmpdir(), 'shumai-transcript-'))
|
||||||
|
try {
|
||||||
|
const video = await ensureLocalMediaFile(asset.storageKey.key, join(directory, 'video'))
|
||||||
|
const { stdout } = await execFileAsync(
|
||||||
|
'ffprobe',
|
||||||
|
['-v', 'error', '-select_streams', 'a', '-show_streams', '-of', 'json', video],
|
||||||
|
{ signal },
|
||||||
|
)
|
||||||
|
const stream = selectPrimaryAudioStream(audioProbeSchema.parse(JSON.parse(stdout)).streams)
|
||||||
|
if (!stream) {
|
||||||
|
throw ApplicationFailure.create({
|
||||||
|
message: transcriptionErrors.noAudio,
|
||||||
|
nonRetryable: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const wav = join(directory, 'audio.wav')
|
||||||
|
// Keep the container timeline and fill any leading gap before the primary audio starts.
|
||||||
|
await execFileAsync(
|
||||||
|
'ffmpeg',
|
||||||
|
[
|
||||||
|
'-nostdin',
|
||||||
|
'-v',
|
||||||
|
'error',
|
||||||
|
'-copyts',
|
||||||
|
'-start_at_zero',
|
||||||
|
'-i',
|
||||||
|
video,
|
||||||
|
'-map',
|
||||||
|
`0:${stream.index}`,
|
||||||
|
'-af',
|
||||||
|
'aresample=16000:async=1:first_pts=0',
|
||||||
|
'-ac',
|
||||||
|
'1',
|
||||||
|
'-c:a',
|
||||||
|
'pcm_s16le',
|
||||||
|
wav,
|
||||||
|
],
|
||||||
|
{ signal },
|
||||||
|
)
|
||||||
|
signal?.throwIfAborted()
|
||||||
|
await s3Service.uploadFileToKey(wav, audioKey, 'audio/wav')
|
||||||
|
} finally {
|
||||||
|
await removeTempDirectory(directory)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
export const transcribeAudioActivity = defineStep(async function transcribeAudioActivity({
|
||||||
|
taskId,
|
||||||
|
audioKey,
|
||||||
|
language,
|
||||||
|
model,
|
||||||
|
}: {
|
||||||
|
taskId: string
|
||||||
|
audioKey: string
|
||||||
|
language: string | null
|
||||||
|
model: string
|
||||||
|
}) {
|
||||||
|
const directory = await mkdtemp(join(tmpdir(), 'shumai-transcript-'))
|
||||||
|
try {
|
||||||
|
const path = await ensureLocalMediaFile(audioKey, join(directory, 'audio.wav'))
|
||||||
|
return await transcribeLocalAudio({
|
||||||
|
audio: Bun.file(path),
|
||||||
|
language,
|
||||||
|
model,
|
||||||
|
signal: getLocalTaskAbortSignal(taskId),
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof LocalTranscriptionError) {
|
||||||
|
const { status } = error
|
||||||
|
if (status >= 400 && status < 500 && status !== 408 && status !== 429) {
|
||||||
|
throw ApplicationFailure.create({
|
||||||
|
message: status === 413 ? transcriptionErrors.tooLarge : error.message,
|
||||||
|
nonRetryable: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (error instanceof z.ZodError || error instanceof SyntaxError) {
|
||||||
|
throw ApplicationFailure.create({
|
||||||
|
message: 'Invalid transcription response',
|
||||||
|
nonRetryable: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
throw error
|
||||||
|
} finally {
|
||||||
|
await removeTempDirectory(directory)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export const saveTranscriptActivity = defineStep(async function saveTranscriptActivity(
|
||||||
|
params: Parameters<typeof transcriptService.saveResult>[0],
|
||||||
|
): Promise<void> {
|
||||||
|
if (!(await transcriptService.saveResult(params))) {
|
||||||
|
throw ApplicationFailure.create({ message: 'Video is no longer available', nonRetryable: true })
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -3,9 +3,11 @@ import { registerWorkflow } from '@shumai/workflow-core'
|
|||||||
import { agentAutofillMedia } from './workflows/agent-autofill'
|
import { agentAutofillMedia } from './workflows/agent-autofill'
|
||||||
import { agentChat } from './workflows/agent-chat'
|
import { agentChat } from './workflows/agent-chat'
|
||||||
import { agentEmbeddingMedia } from './workflows/agent-embedding'
|
import { agentEmbeddingMedia } from './workflows/agent-embedding'
|
||||||
|
import { transcribeVideoWorkflow } from './workflows/transcribe-video'
|
||||||
|
|
||||||
export function initAgentWorkflows() {
|
export function initAgentWorkflows() {
|
||||||
registerWorkflow(WorkflowTaskType.ai_embedding, agentEmbeddingMedia)
|
registerWorkflow(WorkflowTaskType.ai_embedding, agentEmbeddingMedia)
|
||||||
|
registerWorkflow(WorkflowTaskType.ai_transcription, transcribeVideoWorkflow)
|
||||||
registerWorkflow(WorkflowTaskType.ai_metadata_autofill, agentAutofillMedia)
|
registerWorkflow(WorkflowTaskType.ai_metadata_autofill, agentAutofillMedia)
|
||||||
registerWorkflow(WorkflowTaskType.chat, agentChat)
|
registerWorkflow(WorkflowTaskType.chat, agentChat)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import { logger } from '@shumai/core/src/logger'
|
||||||
|
import type { WorkflowTask } from '@shumai/db'
|
||||||
|
import { ApplicationFailure } from '@shumai/workflow-core'
|
||||||
|
import { deleteS3ObjectActivity } from '../activities/ai'
|
||||||
|
import {
|
||||||
|
extractTranscriptAudioActivity,
|
||||||
|
saveTranscriptActivity,
|
||||||
|
transcribeAudioActivity,
|
||||||
|
} from '../activities/transcription'
|
||||||
|
|
||||||
|
export async function transcribeVideoWorkflow(task: WorkflowTask): Promise<void> {
|
||||||
|
const request = task.payload?.transcription
|
||||||
|
if (!request) {
|
||||||
|
throw ApplicationFailure.create({
|
||||||
|
message: 'Missing transcription request',
|
||||||
|
nonRetryable: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const taskId = task.id
|
||||||
|
const assetId = task.assetId
|
||||||
|
const audioKey = `temp/transcripts/${taskId}.wav`
|
||||||
|
try {
|
||||||
|
await extractTranscriptAudioActivity({ assetId, taskId, audioKey })
|
||||||
|
const transcript = await transcribeAudioActivity({ taskId, audioKey, ...request })
|
||||||
|
if (request.language && transcript.language && request.language !== transcript.language) {
|
||||||
|
throw ApplicationFailure.create({
|
||||||
|
message: 'Transcription returned an unexpected language',
|
||||||
|
nonRetryable: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
await saveTranscriptActivity({
|
||||||
|
taskId,
|
||||||
|
assetId,
|
||||||
|
model: request.model,
|
||||||
|
language: transcript.language,
|
||||||
|
segments: transcript.segments.map((segment) => ({
|
||||||
|
startMs: Math.round(segment.start * 1000),
|
||||||
|
endMs: Math.round(segment.end * 1000),
|
||||||
|
text: segment.text,
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
await deleteS3ObjectActivity({ key: audioKey })
|
||||||
|
} catch (error) {
|
||||||
|
logger.error({ err: error, taskId, audioKey }, 'Failed to delete staged transcript audio')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
"types": "./src/index.ts",
|
"types": "./src/index.ts",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@better-auth/mcp": "1.7.12",
|
"@better-auth/mcp": "1.7.12",
|
||||||
"@earendil-works/pi-durable": "1.5.0",
|
"@earendil-works/pi-durable": "1.7.0",
|
||||||
"@hono/zod-validator": "0.7.6",
|
"@hono/zod-validator": "0.7.6",
|
||||||
"@modelcontextprotocol/server": "2.0.0",
|
"@modelcontextprotocol/server": "2.0.0",
|
||||||
"@shumai/core": "workspace:*",
|
"@shumai/core": "workspace:*",
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import type { EntryRecord } from '@earendil-works/pi-durable'
|
import type { EntryRecord } from '@earendil-works/pi-durable'
|
||||||
|
import type { AgentSessionLogs } from '@shumai/dtos'
|
||||||
import type { TypedResponse } from 'hono'
|
import type { TypedResponse } from 'hono'
|
||||||
|
|
||||||
/** Pi records are already JSON; retain their public types without recursively remapping SDK schemas. */
|
/** Pi records are already JSON; retain their public types without recursively remapping SDK schemas. */
|
||||||
export function agentEntriesResponse(
|
export function agentEntriesResponse<T extends EntryRecord[] | AgentSessionLogs>(
|
||||||
entries: EntryRecord[],
|
body: T,
|
||||||
): Response & TypedResponse<EntryRecord[], 200, 'json'> {
|
): Response & TypedResponse<T, 200, 'json'> {
|
||||||
return new Response(JSON.stringify(entries), {
|
return new Response(JSON.stringify(body), {
|
||||||
headers: { 'Content-Type': 'application/json; charset=UTF-8' },
|
headers: { 'Content-Type': 'application/json; charset=UTF-8' },
|
||||||
}) as Response & TypedResponse<EntryRecord[], 200, 'json'>
|
}) as Response & TypedResponse<T, 200, 'json'>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ import { ROOT_CONVERSATION_ID, type EntryId, type EntryRecord } from '@earendil-
|
|||||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
||||||
import { HTTPException } from 'hono/http-exception'
|
import { HTTPException } from 'hono/http-exception'
|
||||||
import { agentService } from '@shumai/core/src/agent/agent'
|
import { agentService } from '@shumai/core/src/agent/agent'
|
||||||
|
import { agentSessionService } from '@shumai/core/src/agent/session-service'
|
||||||
import { authzService } from '@shumai/core/src/authz/authz'
|
import { authzService } from '@shumai/core/src/authz/authz'
|
||||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||||
import type { AgentInfo } from '@shumai/dtos'
|
import type { AgentInfo } from '@shumai/dtos'
|
||||||
import app from './agent'
|
import app from './agent'
|
||||||
|
|
||||||
vi.mock('@shumai/core/src/agent/agent')
|
vi.mock('@shumai/core/src/agent/agent')
|
||||||
|
vi.mock('@shumai/core/src/agent/session-service')
|
||||||
vi.mock('@shumai/core/src/authz/authz')
|
vi.mock('@shumai/core/src/authz/authz')
|
||||||
vi.mock('@shumai/core/src/auditLog/auditLog', () => ({
|
vi.mock('@shumai/core/src/auditLog/auditLog', () => ({
|
||||||
auditLogService: {
|
auditLogService: {
|
||||||
@@ -352,15 +354,16 @@ describe('Agent API', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('GET /agent-sessions/:sessionId/entries', () => {
|
describe('GET /agent-sessions/:sessionId/entries', () => {
|
||||||
|
const mockEntries: EntryRecord[] = [
|
||||||
|
{
|
||||||
|
id: 7 as EntryId,
|
||||||
|
conversationId: ROOT_CONVERSATION_ID,
|
||||||
|
kind: 'pi.user',
|
||||||
|
model: [{ role: 'user', content: 'Step 1', timestamp: 1 }],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
it('returns entries of agent session if user is admin', async () => {
|
it('returns entries of agent session if user is admin', async () => {
|
||||||
const mockEntries: EntryRecord[] = [
|
|
||||||
{
|
|
||||||
id: 7 as EntryId,
|
|
||||||
conversationId: ROOT_CONVERSATION_ID,
|
|
||||||
kind: 'pi.user',
|
|
||||||
model: [{ role: 'user', content: 'Step 1', timestamp: 1 }],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
vi.mocked(agentService.getSessionEntries).mockResolvedValue(mockEntries)
|
vi.mocked(agentService.getSessionEntries).mockResolvedValue(mockEntries)
|
||||||
|
|
||||||
const res = await app.request('/agent-sessions/session1/entries', {
|
const res = await app.request('/agent-sessions/session1/entries', {
|
||||||
@@ -373,6 +376,7 @@ describe('Agent API', () => {
|
|||||||
expect(data[0].id).toBe(7)
|
expect(data[0].id).toBe(7)
|
||||||
expect(data[0].kind).toBe('pi.user')
|
expect(data[0].kind).toBe('pi.user')
|
||||||
expect(data[0].model[0].content).toBe('Step 1')
|
expect(data[0].model[0].content).toBe('Step 1')
|
||||||
|
expect(agentSessionService.getLogs).not.toHaveBeenCalled()
|
||||||
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
||||||
user: undefined,
|
user: undefined,
|
||||||
permission: 'Admin',
|
permission: 'Admin',
|
||||||
@@ -381,6 +385,51 @@ describe('Agent API', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
{
|
||||||
|
inputTokens: 12800,
|
||||||
|
outputTokens: 1580,
|
||||||
|
cacheReadTokens: 10000,
|
||||||
|
totalTokens: 24380,
|
||||||
|
cost: 0.014,
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
])('includes requested usage with the session entries (%j)', async (usage) => {
|
||||||
|
vi.mocked(agentSessionService.getLogs).mockResolvedValue({ entries: mockEntries, usage })
|
||||||
|
|
||||||
|
const res = await app.request('/agent-sessions/session1/entries?includeUsage=true')
|
||||||
|
|
||||||
|
expect(res.status).toBe(200)
|
||||||
|
expect(await res.json()).toEqual({ entries: mockEntries, usage })
|
||||||
|
expect(agentSessionService.getLogs).toHaveBeenCalledWith('session1')
|
||||||
|
expect(agentService.getSessionEntries).not.toHaveBeenCalled()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('checks session admin permission before loading requested usage', async () => {
|
||||||
|
vi.mocked(authzService.hasPermission).mockRejectedValue(
|
||||||
|
new HTTPException(403, { message: 'Forbidden' }),
|
||||||
|
)
|
||||||
|
|
||||||
|
const res = await app.request('/agent-sessions/session1/entries?includeUsage=true')
|
||||||
|
|
||||||
|
expect(res.status).toBe(403)
|
||||||
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
||||||
|
user: undefined,
|
||||||
|
permission: 'Admin',
|
||||||
|
type: 'agentSession',
|
||||||
|
id: 'session1',
|
||||||
|
})
|
||||||
|
expect(agentSessionService.getLogs).not.toHaveBeenCalled()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('rejects invalid includeUsage values', async () => {
|
||||||
|
const res = await app.request('/agent-sessions/session1/entries?includeUsage=invalid')
|
||||||
|
|
||||||
|
expect(res.status).toBe(400)
|
||||||
|
expect(agentSessionService.getLogs).not.toHaveBeenCalled()
|
||||||
|
expect(agentService.getSessionEntries).not.toHaveBeenCalled()
|
||||||
|
})
|
||||||
|
|
||||||
it('denies access if user is not admin', async () => {
|
it('denies access if user is not admin', async () => {
|
||||||
vi.mocked(authzService.hasPermission).mockRejectedValue(new Error('Forbidden'))
|
vi.mocked(authzService.hasPermission).mockRejectedValue(new Error('Forbidden'))
|
||||||
|
|
||||||
|
|||||||
+22
-12
@@ -1,5 +1,6 @@
|
|||||||
import { zValidator } from '@hono/zod-validator'
|
import { zValidator } from '@hono/zod-validator'
|
||||||
import { agentService } from '@shumai/core/src/agent/agent'
|
import { agentService } from '@shumai/core/src/agent/agent'
|
||||||
|
import { agentSessionService } from '@shumai/core/src/agent/session-service'
|
||||||
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
|
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
|
||||||
import {
|
import {
|
||||||
AgentInfo,
|
AgentInfo,
|
||||||
@@ -11,6 +12,7 @@ import {
|
|||||||
} from '@shumai/dtos'
|
} from '@shumai/dtos'
|
||||||
import { Hono } from 'hono'
|
import { Hono } from 'hono'
|
||||||
import { HTTPException } from 'hono/http-exception'
|
import { HTTPException } from 'hono/http-exception'
|
||||||
|
import { z } from 'zod'
|
||||||
import { agentEntriesResponse } from './agent-entries'
|
import { agentEntriesResponse } from './agent-entries'
|
||||||
|
|
||||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||||
@@ -18,6 +20,8 @@ import type { Prisma } from '@shumai/db'
|
|||||||
|
|
||||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||||
|
|
||||||
|
const sessionEntriesQuerySchema = z.object({ includeUsage: z.enum(['true', 'false']).optional() })
|
||||||
|
|
||||||
const route = new Hono<{ Variables: { user: User } }>()
|
const route = new Hono<{ Variables: { user: User } }>()
|
||||||
.get('/teams/:teamId/agents', async (c) => {
|
.get('/teams/:teamId/agents', async (c) => {
|
||||||
const teamId = c.req.param('teamId')
|
const teamId = c.req.param('teamId')
|
||||||
@@ -208,20 +212,26 @@ const route = new Hono<{ Variables: { user: User } }>()
|
|||||||
|
|
||||||
return new Response(null, { status: 204 })
|
return new Response(null, { status: 204 })
|
||||||
})
|
})
|
||||||
.get('/agent-sessions/:sessionId/entries', async (c) => {
|
.get(
|
||||||
const sessionId = c.req.param('sessionId')
|
'/agent-sessions/:sessionId/entries',
|
||||||
const userReq = c.get('user')
|
zValidator('query', sessionEntriesQuerySchema),
|
||||||
|
async (c) => {
|
||||||
|
const sessionId = c.req.param('sessionId')
|
||||||
|
const userReq = c.get('user')
|
||||||
|
|
||||||
await authzService.hasPermission({
|
await authzService.hasPermission({
|
||||||
user: userReq,
|
user: userReq,
|
||||||
permission: Permission.Admin,
|
permission: Permission.Admin,
|
||||||
type: ResourceType.AgentSession,
|
type: ResourceType.AgentSession,
|
||||||
id: sessionId,
|
id: sessionId,
|
||||||
})
|
})
|
||||||
|
|
||||||
const entries = await agentService.getSessionEntries({ sessionId })
|
if (c.req.valid('query').includeUsage === 'true') {
|
||||||
return agentEntriesResponse(entries)
|
return agentEntriesResponse(await agentSessionService.getLogs(sessionId))
|
||||||
})
|
}
|
||||||
|
return agentEntriesResponse(await agentService.getSessionEntries({ sessionId }))
|
||||||
|
},
|
||||||
|
)
|
||||||
.get('/teams/:teamId/agent-sessions', zValidator('query', paginationParamsSchema), async (c) => {
|
.get('/teams/:teamId/agent-sessions', zValidator('query', paginationParamsSchema), async (c) => {
|
||||||
const teamId = c.req.param('teamId')
|
const teamId = c.req.param('teamId')
|
||||||
const userReq = c.get('user')
|
const userReq = c.get('user')
|
||||||
|
|||||||
@@ -13,9 +13,11 @@ describe('authn api', () => {
|
|||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
vi.restoreAllMocks()
|
vi.restoreAllMocks()
|
||||||
|
vi.unstubAllEnvs()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('GET /signup-info', async () => {
|
it('GET /signup-info', async () => {
|
||||||
|
vi.stubEnv('EMBEDDING_PROVIDER', 'gemini-embedding-2')
|
||||||
mockGetSignupInfo.mockResolvedValue({
|
mockGetSignupInfo.mockResolvedValue({
|
||||||
initialized: true,
|
initialized: true,
|
||||||
demoMode: false,
|
demoMode: false,
|
||||||
@@ -29,6 +31,16 @@ describe('authn api', () => {
|
|||||||
initialized: true,
|
initialized: true,
|
||||||
demoMode: false,
|
demoMode: false,
|
||||||
archiveStorageEnabled: false,
|
archiveStorageEnabled: false,
|
||||||
|
transcriptionEnabled: false,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('advertises transcription with the local embedding provider', async () => {
|
||||||
|
vi.stubEnv('EMBEDDING_PROVIDER', 'gemma-embedding-2-openai')
|
||||||
|
mockGetSignupInfo.mockResolvedValue({ initialized: true, demoMode: false })
|
||||||
|
|
||||||
|
const res = await new Hono().route('/', authnRoute).request('/signup-info')
|
||||||
|
|
||||||
|
expect(await res.json()).toMatchObject({ transcriptionEnabled: true })
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { userService } from '@shumai/core/src/user/user'
|
|||||||
import { auth } from '@shumai/core/src/auth/auth'
|
import { auth } from '@shumai/core/src/auth/auth'
|
||||||
import { createGuestToken } from '@shumai/core/src/auth/guest-token'
|
import { createGuestToken } from '@shumai/core/src/auth/guest-token'
|
||||||
import { isArchiveStorageEnabled } from '@shumai/core/src/s3/archive-storage'
|
import { isArchiveStorageEnabled } from '@shumai/core/src/s3/archive-storage'
|
||||||
|
import { isLocalTranscriptionEnabled } from '@shumai/core/src/transcript/local-transcription'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
import { zValidator } from '@hono/zod-validator'
|
import { zValidator } from '@hono/zod-validator'
|
||||||
import { ulid } from 'ulid'
|
import { ulid } from 'ulid'
|
||||||
@@ -24,6 +25,7 @@ const route = app
|
|||||||
initialized: info.initialized,
|
initialized: info.initialized,
|
||||||
demoMode: info.demoMode,
|
demoMode: info.demoMode,
|
||||||
archiveStorageEnabled: isArchiveStorageEnabled(),
|
archiveStorageEnabled: isArchiveStorageEnabled(),
|
||||||
|
transcriptionEnabled: isLocalTranscriptionEnabled(),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.get('/me', async (c) => {
|
.get('/me', async (c) => {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import versionStackRoute from './versionStack'
|
|||||||
import kanbanRoute from './kanban'
|
import kanbanRoute from './kanban'
|
||||||
import mediaGenerationRoute from './media-generation'
|
import mediaGenerationRoute from './media-generation'
|
||||||
import runnerWsRoute, { runnerWebsocket } from './runner-ws'
|
import runnerWsRoute, { runnerWebsocket } from './runner-ws'
|
||||||
|
import transcriptRoute from './transcript'
|
||||||
|
|
||||||
export { runnerWebsocket }
|
export { runnerWebsocket }
|
||||||
|
|
||||||
@@ -72,6 +73,7 @@ const apiRoute = new Hono<{ Variables: { user: User } }>()
|
|||||||
.route('/', teamRoute)
|
.route('/', teamRoute)
|
||||||
.route('/', versionStackRoute)
|
.route('/', versionStackRoute)
|
||||||
.route('/', fileRoute)
|
.route('/', fileRoute)
|
||||||
|
.route('/', transcriptRoute)
|
||||||
.route('/', folderRoute)
|
.route('/', folderRoute)
|
||||||
.route('/', agentRoute)
|
.route('/', agentRoute)
|
||||||
.route('/', chatRoute)
|
.route('/', chatRoute)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { describe, expect, it, vi, beforeEach } from 'vitest'
|
import { describe, expect, it, vi, beforeEach } from 'vitest'
|
||||||
import { Hono, type Context, type Next } from 'hono'
|
import { Hono, type Context, type Next } from 'hono'
|
||||||
|
import { HTTPException } from 'hono/http-exception'
|
||||||
import providerRoute from './provider'
|
import providerRoute from './provider'
|
||||||
import { providerService } from '@shumai/core/src/provider/provider'
|
import { providerService } from '@shumai/core/src/provider/provider'
|
||||||
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
|
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
|
||||||
@@ -34,6 +35,7 @@ describe('provider api', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.restoreAllMocks()
|
vi.restoreAllMocks()
|
||||||
|
vi.clearAllMocks()
|
||||||
vi.mocked(authzService.hasPermission).mockResolvedValue(undefined)
|
vi.mocked(authzService.hasPermission).mockResolvedValue(undefined)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -320,78 +322,57 @@ describe('provider api', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('POST /teams/:teamId/providers/sync-check checks for updates', async () => {
|
const modelsPath = '/teams/t1/providers/p1/models'
|
||||||
vi.mocked(providerService.checkUpdates).mockResolvedValue({
|
const providerUpdatedAt = '2026-11-29T09:15:00.000Z'
|
||||||
providers: [
|
const selection = {
|
||||||
{
|
providerUpdatedAt,
|
||||||
name: 'deepseek',
|
modelIds: ['test-model'],
|
||||||
isNewProvider: true,
|
}
|
||||||
config: { api: 'openai-responses', apiKey: 'DEEPSEEK_API_KEY' },
|
const importRequest = {
|
||||||
models: [],
|
method: 'POST',
|
||||||
},
|
headers: { 'Content-Type': 'application/json' },
|
||||||
],
|
body: JSON.stringify(selection),
|
||||||
totalNewProviders: 1,
|
}
|
||||||
totalNewModels: 0,
|
|
||||||
})
|
|
||||||
|
|
||||||
const res = await app.request('/teams/t1/providers/sync-check', {
|
it('previews refresh results for the requested provider as a team admin', async () => {
|
||||||
method: 'POST',
|
vi.mocked(providerService.refreshModels).mockResolvedValue({
|
||||||
|
status: 'ready',
|
||||||
|
providerUpdatedAt,
|
||||||
|
models: [],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const res = await app.request(modelsPath + '/refresh', { method: 'POST' })
|
||||||
expect(res.status).toBe(200)
|
expect(res.status).toBe(200)
|
||||||
const data = await res.json()
|
expect(res.headers.get('Cache-Control')).toBe('no-store')
|
||||||
expect(data.totalNewProviders).toBe(1)
|
expect(await res.json()).toEqual({ status: 'ready', providerUpdatedAt, models: [] })
|
||||||
expect(data.providers).toHaveLength(1)
|
expect(providerService.refreshModels).toHaveBeenCalledWith('t1', 'p1')
|
||||||
expect(providerService.checkUpdates).toHaveBeenCalledWith('t1')
|
|
||||||
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
||||||
user: expect.anything(),
|
user: expect.anything(),
|
||||||
permission: Permission.Admin,
|
permission: Permission.Admin,
|
||||||
type: ResourceType.Team,
|
type: ResourceType.Team,
|
||||||
id: 't1',
|
id: 't1',
|
||||||
})
|
})
|
||||||
|
expect(auditLogService.logAction).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('POST /teams/:teamId/providers/sync-apply applies sync selection', async () => {
|
it('returns the server reason for an unavailable refresh', async () => {
|
||||||
vi.mocked(providerService.applySync).mockResolvedValue({
|
vi.mocked(providerService.refreshModels).mockResolvedValue({
|
||||||
addedProviders: 1,
|
status: 'unavailable',
|
||||||
addedModels: 3,
|
reason: 'catalog_unavailable',
|
||||||
})
|
|
||||||
|
|
||||||
const payload = {
|
|
||||||
providers: [
|
|
||||||
{
|
|
||||||
name: 'deepseek',
|
|
||||||
isNewProvider: true,
|
|
||||||
config: { api: 'openai-responses', apiKey: 'KEY' },
|
|
||||||
models: [
|
|
||||||
{
|
|
||||||
modelId: 'deepseek-v4-flash',
|
|
||||||
name: 'DeepSeek V4 Flash',
|
|
||||||
config: {
|
|
||||||
api: 'openai-responses',
|
|
||||||
reasoning: true,
|
|
||||||
input: ['text'],
|
|
||||||
contextWindow: 128000,
|
|
||||||
maxTokens: 4096,
|
|
||||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
const res = await app.request('/teams/t1/providers/sync-apply', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify(payload),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const res = await app.request(modelsPath + '/refresh', { method: 'POST' })
|
||||||
expect(res.status).toBe(200)
|
expect(res.status).toBe(200)
|
||||||
const data = await res.json()
|
expect(await res.json()).toEqual({ status: 'unavailable', reason: 'catalog_unavailable' })
|
||||||
expect(data.addedProviders).toBe(1)
|
})
|
||||||
expect(data.addedModels).toBe(3)
|
|
||||||
expect(providerService.applySync).toHaveBeenCalledWith('t1', payload)
|
it('imports the selection into the scoped provider and records its audit entry', async () => {
|
||||||
|
vi.mocked(providerService.importModels).mockResolvedValue({ addedModels: 1 })
|
||||||
|
|
||||||
|
const res = await app.request(modelsPath + '/import', importRequest)
|
||||||
|
expect(res.status).toBe(200)
|
||||||
|
expect(await res.json()).toEqual({ addedModels: 1 })
|
||||||
|
expect(providerService.importModels).toHaveBeenCalledWith('t1', 'p1', selection)
|
||||||
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
expect(authzService.hasPermission).toHaveBeenCalledWith({
|
||||||
user: expect.anything(),
|
user: expect.anything(),
|
||||||
permission: Permission.Admin,
|
permission: Permission.Admin,
|
||||||
@@ -402,6 +383,36 @@ describe('provider api', () => {
|
|||||||
action: 'provider_update',
|
action: 'provider_update',
|
||||||
teamId: 't1',
|
teamId: 't1',
|
||||||
userId: 'user1',
|
userId: 'user1',
|
||||||
|
itemId: 'p1',
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('skips the audit entry when the selected models already exist', async () => {
|
||||||
|
vi.mocked(providerService.importModels).mockResolvedValue({ addedModels: 0 })
|
||||||
|
const res = await app.request(modelsPath + '/import', importRequest)
|
||||||
|
expect(res.status).toBe(200)
|
||||||
|
expect(await res.json()).toEqual({ addedModels: 0 })
|
||||||
|
expect(auditLogService.logAction).not.toHaveBeenCalled()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('rejects requests without team-admin permission before looking up the provider', async () => {
|
||||||
|
vi.mocked(authzService.hasPermission).mockRejectedValue(new HTTPException(403))
|
||||||
|
const refresh = await app.request(modelsPath + '/refresh', { method: 'POST' })
|
||||||
|
const apply = await app.request(modelsPath + '/import', importRequest)
|
||||||
|
expect(refresh.status).toBe(403)
|
||||||
|
expect(apply.status).toBe(403)
|
||||||
|
expect(providerService.refreshModels).not.toHaveBeenCalled()
|
||||||
|
expect(providerService.importModels).not.toHaveBeenCalled()
|
||||||
|
expect(auditLogService.logAction).not.toHaveBeenCalled()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('rejects an empty import selection before performing a write', async () => {
|
||||||
|
const res = await app.request(modelsPath + '/import', {
|
||||||
|
...importRequest,
|
||||||
|
body: JSON.stringify({ providerUpdatedAt, modelIds: [] }),
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(res.status).toBe(400)
|
||||||
|
expect(providerService.importModels).not.toHaveBeenCalled()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { providerService } from '@shumai/core/src/provider/provider'
|
|||||||
import {
|
import {
|
||||||
createModelRequestSchema,
|
createModelRequestSchema,
|
||||||
createProviderRequestSchema,
|
createProviderRequestSchema,
|
||||||
syncApplyRequestSchema,
|
importProviderModelsRequestSchema,
|
||||||
updateModelRequestSchema,
|
updateModelRequestSchema,
|
||||||
updateProviderRequestSchema,
|
updateProviderRequestSchema,
|
||||||
AuditAction,
|
AuditAction,
|
||||||
@@ -31,8 +31,8 @@ const route = new Hono<{ Variables: { user: User } }>()
|
|||||||
return c.json(providers)
|
return c.json(providers)
|
||||||
})
|
})
|
||||||
|
|
||||||
.post('/teams/:teamId/providers/sync-check', async (c) => {
|
.post('/teams/:teamId/providers/:providerId/models/refresh', async (c) => {
|
||||||
const teamId = c.req.param('teamId')
|
const { teamId, providerId } = c.req.param()
|
||||||
const user = c.get('user')
|
const user = c.get('user')
|
||||||
|
|
||||||
await authzService.hasPermission({
|
await authzService.hasPermission({
|
||||||
@@ -42,15 +42,16 @@ const route = new Hono<{ Variables: { user: User } }>()
|
|||||||
id: teamId,
|
id: teamId,
|
||||||
})
|
})
|
||||||
|
|
||||||
const result = await providerService.checkUpdates(teamId)
|
const result = await providerService.refreshModels(teamId, providerId)
|
||||||
|
c.header('Cache-Control', 'no-store')
|
||||||
return c.json(result)
|
return c.json(result)
|
||||||
})
|
})
|
||||||
|
|
||||||
.post(
|
.post(
|
||||||
'/teams/:teamId/providers/sync-apply',
|
'/teams/:teamId/providers/:providerId/models/import',
|
||||||
zValidator('json', syncApplyRequestSchema),
|
zValidator('json', importProviderModelsRequestSchema),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const teamId = c.req.param('teamId')
|
const { teamId, providerId } = c.req.param()
|
||||||
const user = c.get('user')
|
const user = c.get('user')
|
||||||
const body = c.req.valid('json')
|
const body = c.req.valid('json')
|
||||||
|
|
||||||
@@ -61,12 +62,15 @@ const route = new Hono<{ Variables: { user: User } }>()
|
|||||||
id: teamId,
|
id: teamId,
|
||||||
})
|
})
|
||||||
|
|
||||||
const result = await providerService.applySync(teamId, body)
|
const result = await providerService.importModels(teamId, providerId, body)
|
||||||
await auditLogService.logAction({
|
if (result.addedModels > 0) {
|
||||||
action: AuditAction.provider_update,
|
await auditLogService.logAction({
|
||||||
teamId,
|
action: AuditAction.provider_update,
|
||||||
userId: user?.id,
|
teamId,
|
||||||
})
|
userId: user?.id,
|
||||||
|
itemId: providerId,
|
||||||
|
})
|
||||||
|
}
|
||||||
return c.json(result)
|
return c.json(result)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
|
||||||
|
import { transcriptService } from '@shumai/core/src/transcript/transcript'
|
||||||
|
import { Hono } from 'hono'
|
||||||
|
import { HTTPException } from 'hono/http-exception'
|
||||||
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||||
|
import transcriptRoute from './transcript'
|
||||||
|
|
||||||
|
describe('Transcript API', () => {
|
||||||
|
const app = new Hono().route('/', transcriptRoute)
|
||||||
|
const submit = (body: { language?: string }) =>
|
||||||
|
app.request('/files/file-id/transcripts', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(body),
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(() => vi.restoreAllMocks())
|
||||||
|
|
||||||
|
it('proxies the server language list', async () => {
|
||||||
|
const list = { model: 'whisper-tiny', languages: [{ code: 'en', name: 'English' }] }
|
||||||
|
vi.spyOn(transcriptService, 'listLanguages').mockResolvedValue(list)
|
||||||
|
const response = await app.request('/transcription/languages')
|
||||||
|
expect(await response.json()).toEqual(list)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('requires asset edit permission and returns a queued Auto job', async () => {
|
||||||
|
const permission = vi.spyOn(authzService, 'hasPermission').mockResolvedValue(undefined)
|
||||||
|
const generate = vi
|
||||||
|
.spyOn(transcriptService, 'generate')
|
||||||
|
.mockResolvedValue({ kind: 'queued', taskId: 'task-id' })
|
||||||
|
|
||||||
|
const response = await submit({})
|
||||||
|
|
||||||
|
expect(response.status).toBe(202)
|
||||||
|
expect(await response.json()).toEqual({ kind: 'queued', taskId: 'task-id' })
|
||||||
|
expect(generate).toHaveBeenCalledWith('file-id', null)
|
||||||
|
expect(permission).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
type: ResourceType.Asset,
|
||||||
|
permission: Permission.Edit,
|
||||||
|
id: 'file-id',
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns a saved transcript for an explicit language', async () => {
|
||||||
|
vi.spyOn(authzService, 'hasPermission').mockResolvedValue(undefined)
|
||||||
|
const saved = { kind: 'existing', transcriptId: 'transcript-id', language: 'en' } as const
|
||||||
|
vi.spyOn(transcriptService, 'generate').mockResolvedValue(saved)
|
||||||
|
|
||||||
|
const response = await submit({ language: 'en' })
|
||||||
|
|
||||||
|
expect(response.status).toBe(200)
|
||||||
|
expect(await response.json()).toEqual(saved)
|
||||||
|
expect(transcriptService.generate).toHaveBeenCalledWith('file-id', 'en')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('rejects invalid language codes and denies reads and writes without edit permission', async () => {
|
||||||
|
vi.spyOn(authzService, 'hasPermission').mockRejectedValue(new HTTPException(403))
|
||||||
|
const generate = vi.spyOn(transcriptService, 'generate')
|
||||||
|
const status = vi.spyOn(transcriptService, 'getStatus')
|
||||||
|
|
||||||
|
expect((await submit({ language: 'auto' })).status).toBe(400)
|
||||||
|
expect((await submit({ language: 'en' })).status).toBe(403)
|
||||||
|
expect((await app.request('/files/file-id/transcription-status')).status).toBe(403)
|
||||||
|
expect(generate).not.toHaveBeenCalled()
|
||||||
|
expect(status).not.toHaveBeenCalled()
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import { zValidator } from '@hono/zod-validator'
|
||||||
|
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
|
||||||
|
import { transcriptService } from '@shumai/core/src/transcript/transcript'
|
||||||
|
import type { User } from '@shumai/db'
|
||||||
|
import { generateTranscriptRequestSchema } from '@shumai/dtos'
|
||||||
|
import { Hono } from 'hono'
|
||||||
|
|
||||||
|
const route = new Hono<{ Variables: { user: User } }>()
|
||||||
|
.get('/transcription/languages', async (c) => c.json(await transcriptService.listLanguages()))
|
||||||
|
.post(
|
||||||
|
'/files/:fileId/transcripts',
|
||||||
|
zValidator('json', generateTranscriptRequestSchema),
|
||||||
|
async (c) => {
|
||||||
|
const assetId = c.req.param('fileId')
|
||||||
|
await authzService.hasPermission({
|
||||||
|
user: c.get('user'),
|
||||||
|
permission: Permission.Edit,
|
||||||
|
type: ResourceType.Asset,
|
||||||
|
id: assetId,
|
||||||
|
})
|
||||||
|
|
||||||
|
const { language } = c.req.valid('json')
|
||||||
|
const result = await transcriptService.generate(assetId, language ?? null)
|
||||||
|
return c.json(result, result.kind === 'queued' || result.kind === 'busy' ? 202 : 200)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.get('/files/:fileId/transcription-status', async (c) => {
|
||||||
|
const assetId = c.req.param('fileId')
|
||||||
|
await authzService.hasPermission({
|
||||||
|
user: c.get('user'),
|
||||||
|
permission: Permission.Edit,
|
||||||
|
type: ResourceType.Asset,
|
||||||
|
id: assetId,
|
||||||
|
})
|
||||||
|
return c.json(await transcriptService.getStatus(assetId))
|
||||||
|
})
|
||||||
|
|
||||||
|
export default route
|
||||||
@@ -28,9 +28,9 @@
|
|||||||
"@aws-sdk/s3-request-presigner": "3.1121.0",
|
"@aws-sdk/s3-request-presigner": "3.1121.0",
|
||||||
"@better-auth/mcp": "1.7.12",
|
"@better-auth/mcp": "1.7.12",
|
||||||
"@better-auth/oauth-provider": "1.7.12",
|
"@better-auth/oauth-provider": "1.7.12",
|
||||||
"@earendil-works/chord": "1.5.0",
|
"@earendil-works/chord": "1.7.0",
|
||||||
"@earendil-works/pi-ai": "1.5.0",
|
"@earendil-works/pi-ai": "1.7.0",
|
||||||
"@earendil-works/pi-durable": "1.5.0",
|
"@earendil-works/pi-durable": "1.7.0",
|
||||||
"@google/genai": "2.28.0",
|
"@google/genai": "2.28.0",
|
||||||
"@modelcontextprotocol/client": "2.0.0",
|
"@modelcontextprotocol/client": "2.0.0",
|
||||||
"@shumai/db": "workspace:*",
|
"@shumai/db": "workspace:*",
|
||||||
|
|||||||
@@ -92,8 +92,10 @@ export async function openSessionCache(sessionId: string) {
|
|||||||
throw new Error('Session commit sequence mismatch')
|
throw new Error('Session commit sequence mismatch')
|
||||||
seq = receipt.seq
|
seq = receipt.seq
|
||||||
}
|
}
|
||||||
if (result.stored !== commits.length)
|
if (result.kind === 'refused') {
|
||||||
throw result.refused ?? new Error('Session restoration refused')
|
throw result.refused ?? new Error('Session restoration refused')
|
||||||
|
}
|
||||||
|
if (result.stored !== commits.length) throw new Error('Session restoration was incomplete')
|
||||||
}
|
}
|
||||||
await save(true)
|
await save(true)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -60,6 +60,16 @@ describe('Native session storage and PostgreSQL synchronization', () => {
|
|||||||
expect(await prisma.agentSessionEntry.count({ where: { sessionId: session.id } })).toBe(0)
|
expect(await prisma.agentSessionEntry.count({ where: { sessionId: session.id } })).toBe(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('returns logs with unavailable usage before a session has an accounting checkpoint', async () => {
|
||||||
|
const { session } = await fixture()
|
||||||
|
expect(await agentSessionService.getLogs(session.id)).toEqual({ entries: [], usage: null })
|
||||||
|
|
||||||
|
const entries = await appendSessionEntries(session.id, [
|
||||||
|
{ kind: 'pi.user', model: [{ role: 'user', content: 'No usage yet', timestamp: 1 }] },
|
||||||
|
])
|
||||||
|
expect(await agentSessionService.getLogs(session.id)).toEqual({ entries, usage: null })
|
||||||
|
})
|
||||||
|
|
||||||
it.each(['missing', 'corrupt', 'dirty'] as const)(
|
it.each(['missing', 'corrupt', 'dirty'] as const)(
|
||||||
'rebuilds a %s local cache from mirrored commits',
|
'rebuilds a %s local cache from mirrored commits',
|
||||||
async (failure) => {
|
async (failure) => {
|
||||||
@@ -438,6 +448,10 @@ describe('Native session storage and PostgreSQL synchronization', () => {
|
|||||||
expect(Number(usage.totalTokens)).toBeGreaterThan(0)
|
expect(Number(usage.totalTokens)).toBeGreaterThan(0)
|
||||||
expect(Number(usage.totalTokens)).toBe(checkpoint.totalTokens)
|
expect(Number(usage.totalTokens)).toBe(checkpoint.totalTokens)
|
||||||
expect(Number(usage.cost)).toBe(checkpoint.cost)
|
expect(Number(usage.cost)).toBe(checkpoint.cost)
|
||||||
|
const logs = await agentSessionService.getLogs(session.id)
|
||||||
|
expect(logs.entries).not.toHaveLength(0)
|
||||||
|
expect(logs.entries).toEqual(await agentSessionService.getEntries(session.id))
|
||||||
|
expect(logs.usage).toEqual(checkpoint)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('rolls back usage if PostgreSQL cannot persist the native commit', async () => {
|
it('rolls back usage if PostgreSQL cannot persist the native commit', async () => {
|
||||||
@@ -476,5 +490,6 @@ describe('Native session storage and PostgreSQL synchronization', () => {
|
|||||||
await prisma.agentSession.delete({ where: { id: session.id } })
|
await prisma.agentSession.delete({ where: { id: session.id } })
|
||||||
expect(await prisma.agentSessionCommit.count({ where: { sessionId: session.id } })).toBe(0)
|
expect(await prisma.agentSessionCommit.count({ where: { sessionId: session.id } })).toBe(0)
|
||||||
await expect(agentSessionService.getEntries(session.id)).rejects.toThrow('Session not found')
|
await expect(agentSessionService.getEntries(session.id)).rejects.toThrow('Session not found')
|
||||||
|
await expect(agentSessionService.getLogs(session.id)).rejects.toThrow('Session not found')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
} from '@earendil-works/pi-durable'
|
} from '@earendil-works/pi-durable'
|
||||||
import { prisma, type Prisma, type TeamMemberRole } from '@shumai/db'
|
import { prisma, type Prisma, type TeamMemberRole } from '@shumai/db'
|
||||||
import { acquireAdvisoryLock } from '@shumai/db/src/advisory-lock'
|
import { acquireAdvisoryLock } from '@shumai/db/src/advisory-lock'
|
||||||
|
import type { AgentSessionLogs } from '@shumai/dtos'
|
||||||
import { AiUsageService } from '../ai-usage/ai-usage'
|
import { AiUsageService } from '../ai-usage/ai-usage'
|
||||||
import { quotaService } from '../quota/quota-service'
|
import { quotaService } from '../quota/quota-service'
|
||||||
import { openSessionCache, removeSessionCaches } from './session-cache'
|
import { openSessionCache, removeSessionCaches } from './session-cache'
|
||||||
@@ -184,20 +185,22 @@ export class AgentSessionService {
|
|||||||
|
|
||||||
private async read<T>(
|
private async read<T>(
|
||||||
sessionId: string,
|
sessionId: string,
|
||||||
use: (storage: SessionReader) => Promise<T>,
|
use: (storage: SessionReader, usage: PrismaJson.AgentSessionUsage | null) => Promise<T>,
|
||||||
|
{ includeUsage = false } = {},
|
||||||
): Promise<T> {
|
): Promise<T> {
|
||||||
if (this.closing) throw new Error('Session service is closing')
|
if (this.closing) throw new Error('Session service is closing')
|
||||||
return this.withCacheAccess(sessionId, async () => {
|
return this.withCacheAccess(sessionId, async () => {
|
||||||
const session = await prisma.agentSession.findUnique({
|
const session = await prisma.agentSession.findUnique({
|
||||||
where: { id: sessionId },
|
where: { id: sessionId },
|
||||||
select: { id: true },
|
select: { id: true, accountedUsage: includeUsage },
|
||||||
})
|
})
|
||||||
if (!session) throw new Error('Session not found')
|
if (!session) throw new Error('Session not found')
|
||||||
|
const usage = session.accountedUsage ?? null
|
||||||
const writer = this.writers.get(sessionId)
|
const writer = this.writers.get(sessionId)
|
||||||
if (writer) return use(writer.reader)
|
if (writer) return use(writer.reader, usage)
|
||||||
const cache = await openSessionCache(sessionId)
|
const cache = await openSessionCache(sessionId)
|
||||||
try {
|
try {
|
||||||
return await use(cache.storage)
|
return await use(cache.storage, usage)
|
||||||
} finally {
|
} finally {
|
||||||
await cache.storage.close(BACKGROUND_CONTEXT)
|
await cache.storage.close(BACKGROUND_CONTEXT)
|
||||||
}
|
}
|
||||||
@@ -225,22 +228,32 @@ export class AgentSessionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getEntries(sessionId: string): Promise<EntryRecord[]> {
|
async getEntries(sessionId: string): Promise<EntryRecord[]> {
|
||||||
return this.read(sessionId, async (storage) => {
|
return this.read(sessionId, this.readAllEntries)
|
||||||
const entries: EntryRecord[] = []
|
}
|
||||||
if (!(await storage.conversation(ROOT_CONVERSATION_ID, BACKGROUND_CONTEXT))) return entries
|
|
||||||
let cursor: Cursor | undefined
|
async getLogs(sessionId: string): Promise<AgentSessionLogs> {
|
||||||
do {
|
return this.read(
|
||||||
const page = await storage.scanEntries(
|
sessionId,
|
||||||
{ conversationId: ROOT_CONVERSATION_ID, order: 'ascending' },
|
async (storage, usage) => ({ entries: await this.readAllEntries(storage), usage }),
|
||||||
100,
|
{ includeUsage: true },
|
||||||
cursor,
|
)
|
||||||
BACKGROUND_CONTEXT,
|
}
|
||||||
)
|
|
||||||
entries.push(...page.items)
|
private async readAllEntries(storage: SessionReader): Promise<EntryRecord[]> {
|
||||||
cursor = page.next
|
const entries: EntryRecord[] = []
|
||||||
} while (cursor)
|
if (!(await storage.conversation(ROOT_CONVERSATION_ID, BACKGROUND_CONTEXT))) return entries
|
||||||
return entries
|
let cursor: Cursor | undefined
|
||||||
})
|
do {
|
||||||
|
const page = await storage.scanEntries(
|
||||||
|
{ conversationId: ROOT_CONVERSATION_ID, order: 'ascending' },
|
||||||
|
100,
|
||||||
|
cursor,
|
||||||
|
BACKGROUND_CONTEXT,
|
||||||
|
)
|
||||||
|
entries.push(...page.items)
|
||||||
|
cursor = page.next
|
||||||
|
} while (cursor)
|
||||||
|
return entries
|
||||||
}
|
}
|
||||||
|
|
||||||
async getEntryForRequest(sessionId: string, requestId: string) {
|
async getEntryForRequest(sessionId: string, requestId: string) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export const ENV_MAP: Record<string, string> = {
|
|||||||
openai: 'OPENAI_API_KEY',
|
openai: 'OPENAI_API_KEY',
|
||||||
anthropic: 'ANTHROPIC_API_KEY',
|
anthropic: 'ANTHROPIC_API_KEY',
|
||||||
'github-copilot': 'COPILOT_GITHUB_TOKEN',
|
'github-copilot': 'COPILOT_GITHUB_TOKEN',
|
||||||
'azure-openai-responses': 'AZURE_OPENAI_API_KEY',
|
azure: 'AZURE_OPENAI_API_KEY',
|
||||||
deepseek: 'DEEPSEEK_API_KEY',
|
deepseek: 'DEEPSEEK_API_KEY',
|
||||||
google: 'GEMINI_API_KEY',
|
google: 'GEMINI_API_KEY',
|
||||||
'google-vertex': 'GOOGLE_CLOUD_API_KEY',
|
'google-vertex': 'GOOGLE_CLOUD_API_KEY',
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
{
|
|
||||||
"anthropic": {
|
|
||||||
"models": {
|
|
||||||
"claude-3-5-sonnet-20241022": {
|
|
||||||
"id": "claude-3-5-sonnet-20241022",
|
|
||||||
"name": "Claude 3.5 Sonnet",
|
|
||||||
"tool_call": true,
|
|
||||||
"reasoning": false,
|
|
||||||
"limit": {
|
|
||||||
"context": 200000,
|
|
||||||
"output": 8192
|
|
||||||
},
|
|
||||||
"cost": {
|
|
||||||
"input": 3,
|
|
||||||
"output": 15,
|
|
||||||
"cache_read": 0.3,
|
|
||||||
"cache_write": 3.75
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"openai": {
|
|
||||||
"models": {
|
|
||||||
"gpt-4o": {
|
|
||||||
"id": "gpt-4o",
|
|
||||||
"name": "GPT-4o",
|
|
||||||
"tool_call": true,
|
|
||||||
"reasoning": false,
|
|
||||||
"limit": {
|
|
||||||
"context": 128000,
|
|
||||||
"output": 4096
|
|
||||||
},
|
|
||||||
"cost": {
|
|
||||||
"input": 2.5,
|
|
||||||
"output": 10
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"gpt-4o-extra-new": {
|
|
||||||
"id": "gpt-4o-extra-new",
|
|
||||||
"name": "GPT-4o Extra New",
|
|
||||||
"tool_call": true,
|
|
||||||
"reasoning": false,
|
|
||||||
"limit": {
|
|
||||||
"context": 128000,
|
|
||||||
"output": 4096
|
|
||||||
},
|
|
||||||
"cost": {
|
|
||||||
"input": 2.5,
|
|
||||||
"output": 10
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"data": [
|
|
||||||
{
|
|
||||||
"id": "meta/llama-3.1-70b-instruct"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"data": [
|
|
||||||
{
|
|
||||||
"id": "meta-llama/llama-3.1-8b-instruct",
|
|
||||||
"name": "Meta: Llama 3.1 8B Instruct",
|
|
||||||
"context_length": 131072,
|
|
||||||
"pricing": {
|
|
||||||
"prompt": "0.00000005",
|
|
||||||
"completion": "0.00000008"
|
|
||||||
},
|
|
||||||
"top_provider": {
|
|
||||||
"max_completion_tokens": 8192
|
|
||||||
},
|
|
||||||
"supported_parameters": ["tools"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,42 +0,0 @@
|
|||||||
import type { ThinkingLevel, ThinkingLevelMap } from '@earendil-works/pi-ai'
|
|
||||||
|
|
||||||
export type ModelsDevReasoningOption =
|
|
||||||
| { type: 'toggle' }
|
|
||||||
| {
|
|
||||||
type: 'effort'
|
|
||||||
values: Array<
|
|
||||||
'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'default' | null
|
|
||||||
>
|
|
||||||
}
|
|
||||||
| { type: 'budget_tokens'; min?: number; max?: number }
|
|
||||||
|
|
||||||
const THINKING_LEVELS: readonly ThinkingLevel[] = [
|
|
||||||
'minimal',
|
|
||||||
'low',
|
|
||||||
'medium',
|
|
||||||
'high',
|
|
||||||
'xhigh',
|
|
||||||
'max',
|
|
||||||
]
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts models.dev verified effort values into Pi's selectable thinking levels.
|
|
||||||
* Values without a Pi equivalent (`default` and JSON `null`) are intentionally
|
|
||||||
* omitted.
|
|
||||||
*/
|
|
||||||
export function getEffortThinkingLevelMap(
|
|
||||||
options: readonly ModelsDevReasoningOption[],
|
|
||||||
): ThinkingLevelMap | undefined {
|
|
||||||
const effortValues = options.flatMap((option) => (option.type === 'effort' ? option.values : []))
|
|
||||||
if (effortValues.length === 0) return undefined
|
|
||||||
|
|
||||||
const supported = new Set(effortValues)
|
|
||||||
if (!THINKING_LEVELS.some((level) => supported.has(level)) && !supported.has('none'))
|
|
||||||
return undefined
|
|
||||||
|
|
||||||
const map: ThinkingLevelMap = { off: supported.has('none') ? 'none' : null }
|
|
||||||
for (const level of THINKING_LEVELS) {
|
|
||||||
map[level] = supported.has(level) ? level : null
|
|
||||||
}
|
|
||||||
return map
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,197 @@
|
|||||||
|
import { PI_AI_VERSION } from '@earendil-works/pi-ai'
|
||||||
|
import { getBuiltinModels, getBuiltinProviders } from '@earendil-works/pi-ai/providers/all'
|
||||||
|
import { CompatSchemasByApi } from '@earendil-works/pi-ai/providers/compat-schema'
|
||||||
|
import { ThinkingLevelMapSchema } from '@earendil-works/pi-ai/providers/model-schema'
|
||||||
|
import {
|
||||||
|
providerModelConfigSchema,
|
||||||
|
type ProviderConfigSerializable,
|
||||||
|
type ProviderRefreshUnavailableReason,
|
||||||
|
type RefreshedProviderModel,
|
||||||
|
} from '@shumai/dtos'
|
||||||
|
import { HTTPException } from 'hono/http-exception'
|
||||||
|
import { z } from 'zod'
|
||||||
|
import { ENV_MAP } from './builtin'
|
||||||
|
|
||||||
|
type RefreshConnection =
|
||||||
|
| { unavailableReason: ProviderRefreshUnavailableReason }
|
||||||
|
| { unavailableReason: null; piProviderId: string }
|
||||||
|
|
||||||
|
type CatalogResult =
|
||||||
|
| { status: 'unavailable'; reason: 'catalog_unavailable' }
|
||||||
|
| { status: 'ready'; models: RefreshedProviderModel[] }
|
||||||
|
|
||||||
|
const REFRESH_TIMEOUT_MS = 10_000
|
||||||
|
const builtinConnections = new Map<string, Set<string>>(
|
||||||
|
getBuiltinProviders().map((id) => [
|
||||||
|
id,
|
||||||
|
new Set(getBuiltinModels(id).map(({ api, baseUrl }) => connectionKey(api, baseUrl))),
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
const catalogSchema = z.record(
|
||||||
|
z.string(),
|
||||||
|
z.looseObject({
|
||||||
|
id: z.string().min(1),
|
||||||
|
provider: z.string(),
|
||||||
|
api: z.string(),
|
||||||
|
baseUrl: z.string(),
|
||||||
|
type: z.string().optional(),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
const compatSchemas = new Map(
|
||||||
|
Object.entries(CompatSchemasByApi).map(([api, schema]) => [api, z.fromJSONSchema(schema)]),
|
||||||
|
)
|
||||||
|
const thinkingLevelMapSchema = z.fromJSONSchema(ThinkingLevelMapSchema)
|
||||||
|
const catalogHeaderNames = new Set([
|
||||||
|
'user-agent',
|
||||||
|
'editor-version',
|
||||||
|
'editor-plugin-version',
|
||||||
|
'copilot-integration-id',
|
||||||
|
'nvcf-poll-seconds',
|
||||||
|
])
|
||||||
|
const catalogHeadersSchema = z.record(
|
||||||
|
z.string().refine((name) => catalogHeaderNames.has(name.toLowerCase())),
|
||||||
|
z.string().regex(/^[\t\x20-\x7E]*$/),
|
||||||
|
)
|
||||||
|
|
||||||
|
function normalizeBaseUrl(baseUrl?: string): string {
|
||||||
|
return baseUrl?.trim().replace(/\/+$/, '') ?? ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function connectionKey(api: string, baseUrl?: string): string {
|
||||||
|
return JSON.stringify([api, normalizeBaseUrl(baseUrl)])
|
||||||
|
}
|
||||||
|
|
||||||
|
function piProviderName(name: string): string {
|
||||||
|
return name === 'azure-openai-responses' ? 'azure' : name
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isProviderConfigured(name: string, config: ProviderConfigSerializable): boolean {
|
||||||
|
const key = config.apiKey?.trim()
|
||||||
|
if (key) {
|
||||||
|
const envValue = process.env[key]
|
||||||
|
if (envValue !== undefined) return Boolean(envValue.trim())
|
||||||
|
// Existing forms accept literal keys and names such as OPENAI_API_KEY in the same field.
|
||||||
|
return !/^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+$/.test(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
const envName = ENV_MAP[piProviderName(name)]
|
||||||
|
if (envName && process.env[envName]?.trim()) return true
|
||||||
|
if (name === 'amazon-bedrock' && config.api === 'bedrock-converse-stream') {
|
||||||
|
return Boolean(
|
||||||
|
process.env.AWS_BEARER_TOKEN_BEDROCK ||
|
||||||
|
process.env.AWS_PROFILE ||
|
||||||
|
(process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY) ||
|
||||||
|
process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI ||
|
||||||
|
process.env.AWS_CONTAINER_CREDENTIALS_FULL_URI ||
|
||||||
|
process.env.AWS_WEB_IDENTITY_TOKEN_FILE,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = URL.parse(config.baseUrl ?? '')
|
||||||
|
return Boolean(
|
||||||
|
url &&
|
||||||
|
config.api === 'openai-completions' &&
|
||||||
|
(config.authHeader === false ||
|
||||||
|
/^(?:localhost|127\.\d+\.\d+\.\d+|\[::1\])$/.test(url.hostname)),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function azureDeploymentIds(): Set<string> {
|
||||||
|
// Pi uses model-id=deployment-name mappings for Azure's deployment-specific API.
|
||||||
|
const entries = process.env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP?.split(',') ?? []
|
||||||
|
return new Set(
|
||||||
|
entries.flatMap((entry) => {
|
||||||
|
const [modelId, deployment] = entry.split('=', 2).map((value) => value.trim())
|
||||||
|
return modelId && deployment ? [modelId] : []
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getRefreshConnection(
|
||||||
|
name: string,
|
||||||
|
config: ProviderConfigSerializable,
|
||||||
|
): RefreshConnection {
|
||||||
|
const providerId = piProviderName(name)
|
||||||
|
if (providerId === 'azure' && config.api === 'azure-openai-responses') {
|
||||||
|
const endpoint =
|
||||||
|
config.baseUrl || process.env.AZURE_OPENAI_BASE_URL || process.env.AZURE_OPENAI_RESOURCE_NAME
|
||||||
|
return endpoint && azureDeploymentIds().size > 0
|
||||||
|
? { unavailableReason: null, piProviderId: providerId }
|
||||||
|
: { unavailableReason: 'azure_deployment_required' }
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
providerId === 'kimi-coding' &&
|
||||||
|
config.api === 'anthropic-messages' &&
|
||||||
|
normalizeBaseUrl(config.baseUrl) === 'https://api.kimi.com/coding'
|
||||||
|
) {
|
||||||
|
return { unavailableReason: 'legacy_kimi_connection' }
|
||||||
|
}
|
||||||
|
|
||||||
|
const key = connectionKey(config.api, config.baseUrl)
|
||||||
|
const namedConnections = builtinConnections.get(providerId)
|
||||||
|
if (namedConnections?.has(key)) return { unavailableReason: null, piProviderId: providerId }
|
||||||
|
// A renamed provider can still be resolved if its protocol and endpoint identify one catalog.
|
||||||
|
if (!namedConnections && config.baseUrl) {
|
||||||
|
const matches = [...builtinConnections].filter(([, connections]) => connections.has(key))
|
||||||
|
if (matches.length === 1) return { unavailableReason: null, piProviderId: matches[0][0] }
|
||||||
|
}
|
||||||
|
return { unavailableReason: 'unsupported_connection' }
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function discoverProviderModels(
|
||||||
|
piProviderId: string,
|
||||||
|
config: ProviderConfigSerializable,
|
||||||
|
): Promise<CatalogResult> {
|
||||||
|
const url = new URL(`/api/models/providers/${encodeURIComponent(piProviderId)}`, 'https://pi.dev')
|
||||||
|
url.searchParams.set('pi-version', PI_AI_VERSION)
|
||||||
|
let catalog: z.infer<typeof catalogSchema>
|
||||||
|
try {
|
||||||
|
const response = await fetch(url, {
|
||||||
|
headers: { Accept: 'application/json' },
|
||||||
|
redirect: 'error',
|
||||||
|
signal: AbortSignal.timeout(REFRESH_TIMEOUT_MS),
|
||||||
|
})
|
||||||
|
if (response.status === 404 || response.status === 501) {
|
||||||
|
return { status: 'unavailable', reason: 'catalog_unavailable' }
|
||||||
|
}
|
||||||
|
if (!response.ok) throw new Error(`Pi catalog returned HTTP ${response.status}`)
|
||||||
|
catalog = catalogSchema.parse(await response.json())
|
||||||
|
} catch (cause) {
|
||||||
|
throw new HTTPException(502, { message: 'Could not refresh provider models', cause })
|
||||||
|
}
|
||||||
|
|
||||||
|
const key = connectionKey(config.api, config.baseUrl)
|
||||||
|
const azureDeployments = piProviderId === 'azure' ? azureDeploymentIds() : undefined
|
||||||
|
const models = Object.entries(catalog).flatMap(([id, model]) => {
|
||||||
|
if (
|
||||||
|
model.id !== id ||
|
||||||
|
model.provider !== piProviderId ||
|
||||||
|
(model.type && model.type !== 'chat')
|
||||||
|
) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
const matches = azureDeployments
|
||||||
|
? model.api === config.api && model.baseUrl === '' && azureDeployments.has(id)
|
||||||
|
: connectionKey(model.api, model.baseUrl) === key
|
||||||
|
if (!matches) return []
|
||||||
|
if (
|
||||||
|
model.compat !== undefined &&
|
||||||
|
!compatSchemas.get(model.api)?.safeParse(model.compat).success
|
||||||
|
)
|
||||||
|
return []
|
||||||
|
if (
|
||||||
|
model.thinkingLevelMap !== undefined &&
|
||||||
|
!thinkingLevelMapSchema.safeParse(model.thinkingLevelMap).success
|
||||||
|
)
|
||||||
|
return []
|
||||||
|
if (model.headers !== undefined && !catalogHeadersSchema.safeParse(model.headers).success)
|
||||||
|
return []
|
||||||
|
|
||||||
|
// Keep omitted flags absent so Pi can apply model- and endpoint-specific defaults.
|
||||||
|
const modelConfig = providerModelConfigSchema.safeParse(model)
|
||||||
|
if (!modelConfig.success) return []
|
||||||
|
const name = typeof model.name === 'string' && model.name ? model.name : id
|
||||||
|
return [{ modelId: id, name, config: modelConfig.data }]
|
||||||
|
})
|
||||||
|
return { status: 'ready', models }
|
||||||
|
}
|
||||||
@@ -3,46 +3,53 @@ import { setupTestDbHooks } from '@shumai/db/test'
|
|||||||
import { teamService } from '@shumai/core/src/team/team'
|
import { teamService } from '@shumai/core/src/team/team'
|
||||||
import { agentService } from '@shumai/core/src/agent/agent'
|
import { agentService } from '@shumai/core/src/agent/agent'
|
||||||
import { providerService } from './provider'
|
import { providerService } from './provider'
|
||||||
import { describe, expect, it, vi } from 'vitest'
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||||
import * as generateModelsModule from './generator/generate-models'
|
|
||||||
import { ProviderConfigSerializable, providerModelSchema } from '@shumai/dtos'
|
import { ProviderConfigSerializable, providerModelSchema } from '@shumai/dtos'
|
||||||
import { getBuiltinProvidersMap } from '@shumai/core/src/provider/builtin'
|
import { getBuiltinProvidersMap } from '@shumai/core/src/provider/builtin'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
import modelsDevFixture from './fixtures/models-dev.json'
|
|
||||||
import openRouterFixture from './fixtures/openrouter.json'
|
|
||||||
import nvidiaFixture from './fixtures/nvidia.json'
|
|
||||||
|
|
||||||
const originalFetch = globalThis.fetch
|
const openaiConfig = {
|
||||||
|
api: 'openai-responses',
|
||||||
|
baseUrl: 'https://api.openai.com/v1',
|
||||||
|
apiKey: 'saved-test-key',
|
||||||
|
} satisfies ProviderConfigSerializable
|
||||||
|
|
||||||
function setupCatalogFetchMock() {
|
const candidateConfig = {
|
||||||
return vi.spyOn(globalThis, 'fetch').mockImplementation(async (input: RequestInfo | URL) => {
|
api: openaiConfig.api,
|
||||||
const url = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url
|
reasoning: true,
|
||||||
if (url.includes('models.dev')) {
|
input: ['text'],
|
||||||
return new Response(JSON.stringify(modelsDevFixture), {
|
contextWindow: 256000,
|
||||||
status: 200,
|
maxTokens: 16000,
|
||||||
headers: { 'Content-Type': 'application/json' },
|
cost: { input: 1, output: 2, cacheRead: 0, cacheWrite: 0 },
|
||||||
})
|
} satisfies ProviderModel['config']
|
||||||
|
|
||||||
|
function catalogModel(id: string, options?: Record<string, unknown>) {
|
||||||
|
return {
|
||||||
|
...candidateConfig,
|
||||||
|
provider: 'openai',
|
||||||
|
baseUrl: openaiConfig.baseUrl,
|
||||||
|
id,
|
||||||
|
name: id,
|
||||||
|
...options,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function mockCatalog(models: ReturnType<typeof catalogModel>[]) {
|
||||||
|
const requests: Request[] = []
|
||||||
|
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input, init) => {
|
||||||
|
const request = new Request(input, init)
|
||||||
|
requests.push(request)
|
||||||
|
if (new URL(request.url).origin !== 'https://pi.dev') {
|
||||||
|
throw new Error('Unexpected catalog host')
|
||||||
}
|
}
|
||||||
if (url.includes('openrouter.ai')) {
|
return Response.json(Object.fromEntries(models.map((model) => [model.id, model])))
|
||||||
return new Response(JSON.stringify(openRouterFixture), {
|
|
||||||
status: 200,
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if (url.includes('nvidia')) {
|
|
||||||
return new Response(JSON.stringify(nvidiaFixture), {
|
|
||||||
status: 200,
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if (url.includes('ai-gateway')) {
|
|
||||||
return new Response(JSON.stringify({ data: [] }), {
|
|
||||||
status: 200,
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return originalFetch(input)
|
|
||||||
})
|
})
|
||||||
|
return requests
|
||||||
|
}
|
||||||
|
|
||||||
|
function readyPreview(result: Awaited<ReturnType<typeof providerService.refreshModels>>) {
|
||||||
|
if (result.status !== 'ready') throw new Error('Expected refreshed models')
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProviderModel = z.infer<typeof providerModelSchema>
|
type ProviderModel = z.infer<typeof providerModelSchema>
|
||||||
@@ -385,182 +392,270 @@ describe('ProviderService', () => {
|
|||||||
expect((modelsAfterUpdate[1].config as { api: string }).api).toBe('anthropic-messages')
|
expect((modelsAfterUpdate[1].config as { api: string }).api).toBe('anthropic-messages')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should check for updates and correctly segregate new vs existing providers', async () => {
|
describe('model refresh', () => {
|
||||||
const fetchSpy = setupCatalogFetchMock()
|
afterEach(() => {
|
||||||
try {
|
vi.restoreAllMocks()
|
||||||
// 1. Check updates with empty team: all discovered providers are new
|
vi.unstubAllEnvs()
|
||||||
const emptyTeam = await prisma.team.create({
|
})
|
||||||
data: { name: 'Empty Provider Team' },
|
|
||||||
|
it('reports resolved credentials and eligibility separately and preserves legacy Kimi', async () => {
|
||||||
|
vi.stubEnv('CUSTOM_OPENAI_KEY', 'a-resolved-test-key')
|
||||||
|
vi.stubEnv('UNSET_ANTHROPIC_KEY', undefined)
|
||||||
|
const team = await prisma.team.create({ data: { name: 'Providers' } })
|
||||||
|
const configured = await providerService.create(team.id, 'OpenAI production', {
|
||||||
|
...openaiConfig,
|
||||||
|
apiKey: 'CUSTOM_OPENAI_KEY',
|
||||||
})
|
})
|
||||||
const initialCheck = await providerService.checkUpdates(emptyTeam.id)
|
const unconfigured = await providerService.create(team.id, 'anthropic', {
|
||||||
expect(initialCheck.totalNewProviders).toBeGreaterThan(0)
|
api: 'anthropic-messages',
|
||||||
expect(initialCheck.totalNewModels).toBeGreaterThan(0)
|
baseUrl: 'https://api.anthropic.com',
|
||||||
expect(initialCheck.providers.every((p) => p.isNewProvider)).toBe(true)
|
apiKey: 'UNSET_ANTHROPIC_KEY',
|
||||||
|
})
|
||||||
|
const legacyConfig = {
|
||||||
|
api: 'anthropic-messages',
|
||||||
|
baseUrl: 'https://api.kimi.com/coding',
|
||||||
|
apiKey: 'literal-kimi-key',
|
||||||
|
} satisfies ProviderConfigSerializable
|
||||||
|
const legacy = await providerService.create(team.id, 'kimi-coding', legacyConfig)
|
||||||
|
const local = await providerService.create(team.id, 'Local Ollama', {
|
||||||
|
api: 'openai-completions',
|
||||||
|
baseUrl: 'http://localhost:11434/v1',
|
||||||
|
})
|
||||||
|
vi.stubEnv('AWS_PROFILE', 'test-profile')
|
||||||
|
const bedrock = await providerService.create(team.id, 'amazon-bedrock', {
|
||||||
|
api: 'bedrock-converse-stream',
|
||||||
|
})
|
||||||
|
const providers = await providerService.listByTeam(team.id)
|
||||||
|
expect(providers).toHaveLength(5)
|
||||||
|
expect(providers).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
id: configured.id,
|
||||||
|
configured: true,
|
||||||
|
refreshUnavailableReason: null,
|
||||||
|
config: { ...openaiConfig, apiKey: 'CUSTOM_OPENAI_KEY' },
|
||||||
|
}),
|
||||||
|
expect.objectContaining({
|
||||||
|
id: unconfigured.id,
|
||||||
|
configured: false,
|
||||||
|
refreshUnavailableReason: null,
|
||||||
|
}),
|
||||||
|
expect.objectContaining({
|
||||||
|
id: legacy.id,
|
||||||
|
configured: true,
|
||||||
|
refreshUnavailableReason: 'legacy_kimi_connection',
|
||||||
|
}),
|
||||||
|
expect.objectContaining({
|
||||||
|
id: local.id,
|
||||||
|
configured: true,
|
||||||
|
refreshUnavailableReason: 'unsupported_connection',
|
||||||
|
}),
|
||||||
|
expect.objectContaining({ id: bedrock.id, configured: true }),
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
|
||||||
// 2. With default team (which has builtin providers initialized)
|
const requests = mockCatalog([])
|
||||||
const teamWithBuiltins = await teamService.ensureDefaultTeam()
|
await expect(providerService.refreshModels(team.id, unconfigured.id)).resolves.toMatchObject({
|
||||||
|
status: 'ready',
|
||||||
// 3. Check updates after init: existing providers should have isNewProvider: false
|
models: [],
|
||||||
const afterInitCheck = await providerService.checkUpdates(teamWithBuiltins.id)
|
})
|
||||||
const existing = afterInitCheck.providers.find((p) => !p.isNewProvider)
|
await expect(providerService.refreshModels(team.id, legacy.id)).resolves.toEqual({
|
||||||
expect(existing).toBeDefined()
|
status: 'unavailable',
|
||||||
if (existing) {
|
reason: 'legacy_kimi_connection',
|
||||||
expect(existing.isNewProvider).toBe(false)
|
})
|
||||||
const dbModels = await providerService.listModelsByProvider(
|
expect(requests.map(({ url }) => new URL(url).pathname)).toEqual([
|
||||||
teamWithBuiltins.id,
|
'/api/models/providers/anthropic',
|
||||||
(await providerService.listByTeam(teamWithBuiltins.id)).find(
|
])
|
||||||
(p) => p.name === existing.name,
|
expect(await providerService.getById(legacy.id)).toMatchObject({ config: legacyConfig })
|
||||||
)!.id,
|
|
||||||
)
|
|
||||||
const dbModelIds = new Set(dbModels.map((m) => m.modelId))
|
|
||||||
for (const m of existing.models) {
|
|
||||||
expect(dbModelIds.has(m.modelId)).toBe(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
fetchSpy.mockRestore()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should throw an error when upstream catalog fetch fails in checkUpdates', async () => {
|
|
||||||
const team = await teamService.ensureDefaultTeam()
|
|
||||||
const spy = vi
|
|
||||||
.spyOn(generateModelsModule, 'generateModels')
|
|
||||||
.mockRejectedValueOnce(new Error('Failed to load models.dev catalog: 502 Bad Gateway'))
|
|
||||||
|
|
||||||
await expect(providerService.checkUpdates(team.id)).rejects.toThrow(
|
|
||||||
'Failed to load models.dev catalog: 502 Bad Gateway',
|
|
||||||
)
|
|
||||||
spy.mockRestore()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should throw an error when upstream catalog is empty in checkUpdates', async () => {
|
|
||||||
const team = await teamService.ensureDefaultTeam()
|
|
||||||
const spy = vi.spyOn(generateModelsModule, 'generateModels').mockResolvedValueOnce({
|
|
||||||
providers: {},
|
|
||||||
groupedProviders: {},
|
|
||||||
sortedProviderIds: [],
|
|
||||||
})
|
})
|
||||||
|
|
||||||
await expect(providerService.checkUpdates(team.id)).rejects.toThrow(
|
it('refreshes only the requested provider and filters existing and incompatible models', async () => {
|
||||||
'Failed to retrieve model catalog from upstream services',
|
vi.stubEnv('OPENAI_API_KEY', openaiConfig.apiKey)
|
||||||
)
|
const team = await teamService.ensureDefaultTeam()
|
||||||
spy.mockRestore()
|
const providers = await providerService.listByTeam(team.id)
|
||||||
})
|
const openai = providers.find(({ name }) => name === 'openai')!
|
||||||
|
const existingModels = await providerService.listModelsByProvider(team.id, openai.id)
|
||||||
|
const requests = mockCatalog([
|
||||||
|
catalogModel(existingModels[0].modelId),
|
||||||
|
catalogModel('new-model', {
|
||||||
|
compat: { supportsStrictMode: true },
|
||||||
|
thinkingLevelMap: { low: 'low' },
|
||||||
|
}),
|
||||||
|
catalogModel('wrong-api', { api: 'openai-completions' }),
|
||||||
|
catalogModel('wrong-url', { baseUrl: 'https://other.example/v1' }),
|
||||||
|
catalogModel('wrong-provider', { provider: 'anthropic' }),
|
||||||
|
catalogModel('not-chat', { type: 'image' }),
|
||||||
|
catalogModel('invalid-compat', { compat: { supportsStrictMode: 'yes' } }),
|
||||||
|
])
|
||||||
|
|
||||||
it('should apply sync by adding selected providers and models without modifying existing ones', async () => {
|
const result = await providerService.refreshModels(team.id, openai.id)
|
||||||
const team = await teamService.ensureDefaultTeam()
|
expect(result).toMatchObject({
|
||||||
|
status: 'ready',
|
||||||
// Create an existing provider with 1 model and a custom apiKey
|
models: [
|
||||||
const existingProvider = await providerService.create(
|
{
|
||||||
team.id,
|
modelId: 'new-model',
|
||||||
'test-existing-provider',
|
name: 'new-model',
|
||||||
{ api: 'openai-responses', apiKey: 'custom-api-key', baseUrl: 'https://example.com' },
|
config: {
|
||||||
[
|
...candidateConfig,
|
||||||
{
|
compat: { supportsStrictMode: true },
|
||||||
modelId: 'existing-m1',
|
thinkingLevelMap: { low: 'low' },
|
||||||
name: 'Existing Model 1',
|
},
|
||||||
config: {
|
|
||||||
api: 'openai-responses',
|
|
||||||
reasoning: false,
|
|
||||||
input: ['text'],
|
|
||||||
contextWindow: 128000,
|
|
||||||
maxTokens: 4096,
|
|
||||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
],
|
})
|
||||||
)
|
expect(requests.map(({ url }) => new URL(url).pathname)).toEqual([
|
||||||
|
'/api/models/providers/openai',
|
||||||
// Apply sync with 1 new provider and 1 new model on the existing provider
|
])
|
||||||
const syncResult = await providerService.applySync(team.id, {
|
expect(requests[0].headers.has('Authorization')).toBe(false)
|
||||||
providers: [
|
expect(JSON.stringify(result)).not.toContain(openaiConfig.apiKey)
|
||||||
{
|
expect(await providerService.listModelsByProvider(team.id, openai.id)).toEqual(existingModels)
|
||||||
name: 'test-new-synced-provider',
|
expect(await providerService.listByTeam(team.id)).toEqual(providers)
|
||||||
isNewProvider: true,
|
|
||||||
config: {
|
|
||||||
api: 'anthropic-messages',
|
|
||||||
apiKey: 'ENV_SYNC_KEY',
|
|
||||||
baseUrl: 'https://api.anthropic.com',
|
|
||||||
},
|
|
||||||
models: [
|
|
||||||
{
|
|
||||||
modelId: 'new-p-m1',
|
|
||||||
name: 'New Provider Model 1',
|
|
||||||
config: {
|
|
||||||
api: 'anthropic-messages',
|
|
||||||
reasoning: false,
|
|
||||||
input: ['text'],
|
|
||||||
contextWindow: 200000,
|
|
||||||
maxTokens: 8192,
|
|
||||||
cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'test-existing-provider',
|
|
||||||
isNewProvider: false,
|
|
||||||
config: { api: 'openai-responses', apiKey: 'should-not-override' },
|
|
||||||
models: [
|
|
||||||
{
|
|
||||||
modelId: 'existing-m2',
|
|
||||||
name: 'Newly Added Model 2',
|
|
||||||
config: {
|
|
||||||
api: 'openai-responses',
|
|
||||||
reasoning: true,
|
|
||||||
input: ['text'],
|
|
||||||
contextWindow: 128000,
|
|
||||||
maxTokens: 4096,
|
|
||||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// Duplicate model that already exists: should be ignored
|
|
||||||
{
|
|
||||||
modelId: 'existing-m1',
|
|
||||||
name: 'Existing Model 1 Overwrite Attempt',
|
|
||||||
config: {
|
|
||||||
api: 'openai-responses',
|
|
||||||
reasoning: false,
|
|
||||||
input: ['text'],
|
|
||||||
contextWindow: 999999,
|
|
||||||
maxTokens: 999999,
|
|
||||||
cost: { input: 9, output: 9, cacheRead: 9, cacheWrite: 9 },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(syncResult.addedProviders).toBe(1)
|
it('uses the versioned public OpenRouter catalog without sending saved credentials', async () => {
|
||||||
expect(syncResult.addedModels).toBe(2)
|
const openRouterKey = 'saved-openrouter-test-key'
|
||||||
|
vi.stubEnv('SHUMAI_TEST_OPENROUTER_KEY', openRouterKey)
|
||||||
|
const team = await prisma.team.create({ data: { name: 'OpenRouter' } })
|
||||||
|
const baseUrl = 'https://openrouter.ai/api/v1'
|
||||||
|
const api = 'openai-completions' as const
|
||||||
|
const provider = await providerService.create(team.id, 'openrouter', {
|
||||||
|
api,
|
||||||
|
baseUrl: baseUrl + '/',
|
||||||
|
apiKey: 'SHUMAI_TEST_OPENROUTER_KEY',
|
||||||
|
})
|
||||||
|
const modelId = 'org/new-openrouter-model'
|
||||||
|
const requests: Request[] = []
|
||||||
|
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input, init) => {
|
||||||
|
const request = new Request(input, init)
|
||||||
|
requests.push(request)
|
||||||
|
return Response.json({
|
||||||
|
[modelId]: { ...catalogModel(modelId, { api, baseUrl }), provider: 'openrouter' },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// Verify existing provider config was NOT modified
|
const { models } = readyPreview(await providerService.refreshModels(team.id, provider.id))
|
||||||
const reloadedExisting = await providerService.getById(existingProvider.id)
|
expect(models.map(({ modelId }) => modelId)).toEqual([modelId])
|
||||||
expect((reloadedExisting?.config as { apiKey: string }).apiKey).toBe('custom-api-key')
|
expect(requests.map(({ url }) => url)).toEqual([
|
||||||
|
'https://pi.dev/api/models/providers/openrouter?pi-version=1.7.0',
|
||||||
|
])
|
||||||
|
expect(requests[0].headers.has('Authorization')).toBe(false)
|
||||||
|
|
||||||
// Verify existing model was NOT modified
|
const customProvider = await providerService.update(team.id, provider.id, {
|
||||||
const existingModels = await providerService.listModelsByProvider(team.id, existingProvider.id)
|
...provider.config,
|
||||||
expect(existingModels).toHaveLength(2)
|
baseUrl: 'https://openrouter-proxy.example/api/v1',
|
||||||
const m1 = existingModels.find((m) => m.modelId === 'existing-m1')
|
})
|
||||||
expect(m1?.name).toBe('Existing Model 1')
|
await expect(providerService.refreshModels(team.id, customProvider.id)).resolves.toEqual({
|
||||||
expect((m1?.config as { contextWindow: number }).contextWindow).toBe(128000)
|
status: 'unavailable',
|
||||||
|
reason: 'unsupported_connection',
|
||||||
|
})
|
||||||
|
expect(requests).toHaveLength(1)
|
||||||
|
})
|
||||||
|
|
||||||
// Verify newly added model on existing provider
|
it('distinguishes a successful empty preview from an upstream error', async () => {
|
||||||
const m2 = existingModels.find((m) => m.modelId === 'existing-m2')
|
vi.stubEnv('OPENAI_API_KEY', openaiConfig.apiKey)
|
||||||
expect(m2).toBeDefined()
|
const team = await teamService.ensureDefaultTeam()
|
||||||
expect(m2?.name).toBe('Newly Added Model 2')
|
const provider = (await providerService.listByTeam(team.id)).find(
|
||||||
|
({ name }) => name === 'openai',
|
||||||
|
)!
|
||||||
|
mockCatalog([])
|
||||||
|
await expect(providerService.refreshModels(team.id, provider.id)).resolves.toMatchObject({
|
||||||
|
status: 'ready',
|
||||||
|
models: [],
|
||||||
|
})
|
||||||
|
vi.restoreAllMocks()
|
||||||
|
const fetchMock = vi.spyOn(globalThis, 'fetch')
|
||||||
|
fetchMock.mockResolvedValueOnce(new Response(null, { status: 404 }))
|
||||||
|
await expect(providerService.refreshModels(team.id, provider.id)).resolves.toEqual({
|
||||||
|
status: 'unavailable',
|
||||||
|
reason: 'catalog_unavailable',
|
||||||
|
})
|
||||||
|
fetchMock.mockResolvedValueOnce(Response.json({ error: 'malformed catalog' }))
|
||||||
|
await expect(providerService.refreshModels(team.id, provider.id)).rejects.toMatchObject({
|
||||||
|
status: 502,
|
||||||
|
})
|
||||||
|
fetchMock.mockRejectedValueOnce(new DOMException('Timed out', 'TimeoutError'))
|
||||||
|
|
||||||
// Verify newly added provider
|
await expect(providerService.refreshModels(team.id, provider.id)).rejects.toMatchObject({
|
||||||
const providers = await providerService.listByTeam(team.id)
|
status: 502,
|
||||||
const newProvider = providers.find((p) => p.name === 'test-new-synced-provider')
|
})
|
||||||
expect(newProvider).toBeDefined()
|
})
|
||||||
expect(newProvider?.isBuiltin).toBe(true)
|
|
||||||
expect((newProvider?.config as { apiKey: string }).apiKey).toBe('ENV_SYNC_KEY')
|
|
||||||
|
|
||||||
const newProviderModels = await providerService.listModelsByProvider(team.id, newProvider!.id)
|
it('imports only the selected models once and preserves existing models and settings', async () => {
|
||||||
expect(newProviderModels).toHaveLength(1)
|
vi.stubEnv('OPENAI_API_KEY', openaiConfig.apiKey)
|
||||||
expect(newProviderModels[0].modelId).toBe('new-p-m1')
|
const team = await teamService.ensureDefaultTeam()
|
||||||
|
const provider = (await providerService.listByTeam(team.id)).find(
|
||||||
|
({ name }) => name === 'openai',
|
||||||
|
)!
|
||||||
|
const original = await providerService.getById(provider.id)
|
||||||
|
const existing = await providerService.listModelsByProvider(team.id, provider.id)
|
||||||
|
mockCatalog([catalogModel('new-model'), catalogModel('unselected-model')])
|
||||||
|
const preview = readyPreview(await providerService.refreshModels(team.id, provider.id))
|
||||||
|
const selection = { providerUpdatedAt: preview.providerUpdatedAt, modelIds: ['new-model'] }
|
||||||
|
|
||||||
|
await expect(providerService.importModels(team.id, provider.id, selection)).resolves.toEqual({
|
||||||
|
addedModels: 1,
|
||||||
|
})
|
||||||
|
await expect(providerService.importModels(team.id, provider.id, selection)).resolves.toEqual({
|
||||||
|
addedModels: 0,
|
||||||
|
})
|
||||||
|
expect(await providerService.listModelsByProvider(team.id, provider.id)).toEqual([
|
||||||
|
expect.objectContaining({ modelId: 'new-model', config: candidateConfig }),
|
||||||
|
...existing,
|
||||||
|
])
|
||||||
|
expect(await providerService.getById(provider.id)).toEqual(original)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('rejects out-of-team, unknown, and stale selections without adding models', async () => {
|
||||||
|
const team = await prisma.team.create({ data: { name: 'Refresh Team' } })
|
||||||
|
const otherTeam = await prisma.team.create({ data: { name: 'Other Team' } })
|
||||||
|
const provider = await providerService.create(team.id, 'openai', openaiConfig)
|
||||||
|
const requests = mockCatalog([catalogModel('new-model')])
|
||||||
|
await expect(providerService.refreshModels(otherTeam.id, provider.id)).rejects.toMatchObject({
|
||||||
|
status: 404,
|
||||||
|
})
|
||||||
|
expect(requests).toHaveLength(0)
|
||||||
|
|
||||||
|
const preview = readyPreview(await providerService.refreshModels(team.id, provider.id))
|
||||||
|
const selection = { providerUpdatedAt: preview.providerUpdatedAt, modelIds: ['new-model'] }
|
||||||
|
await expect(
|
||||||
|
providerService.importModels(otherTeam.id, provider.id, selection),
|
||||||
|
).rejects.toMatchObject({ status: 404 })
|
||||||
|
await expect(
|
||||||
|
providerService.importModels(team.id, provider.id, {
|
||||||
|
...selection,
|
||||||
|
modelIds: ['new-model', 'unknown'],
|
||||||
|
}),
|
||||||
|
).rejects.toMatchObject({ status: 409 })
|
||||||
|
|
||||||
|
await providerService.update(team.id, provider.id, { ...openaiConfig, apiKey: 'changed-key' })
|
||||||
|
await expect(
|
||||||
|
providerService.importModels(team.id, provider.id, selection),
|
||||||
|
).rejects.toMatchObject({ status: 409 })
|
||||||
|
expect(await providerService.listModelsByProvider(team.id, provider.id)).toEqual([])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('refreshes legacy Azure connections using only configured deployment mappings', async () => {
|
||||||
|
vi.stubEnv('AZURE_OPENAI_DEPLOYMENT_NAME_MAP', undefined)
|
||||||
|
const team = await prisma.team.create({ data: { name: 'Azure models' } })
|
||||||
|
const provider = await providerService.create(team.id, 'azure-openai-responses', {
|
||||||
|
api: 'azure-openai-responses',
|
||||||
|
baseUrl: 'https://example.openai.azure.com/openai/v1',
|
||||||
|
})
|
||||||
|
const azure = { provider: 'azure', api: 'azure-openai-responses', baseUrl: '' }
|
||||||
|
const requests = mockCatalog([
|
||||||
|
catalogModel('gpt-deployed', azure),
|
||||||
|
catalogModel('gpt-unmapped', azure),
|
||||||
|
])
|
||||||
|
await expect(providerService.refreshModels(team.id, provider.id)).resolves.toEqual({
|
||||||
|
status: 'unavailable',
|
||||||
|
reason: 'azure_deployment_required',
|
||||||
|
})
|
||||||
|
vi.stubEnv('AZURE_OPENAI_DEPLOYMENT_NAME_MAP', 'gpt-deployed=team-deployment')
|
||||||
|
const preview = readyPreview(await providerService.refreshModels(team.id, provider.id))
|
||||||
|
expect(preview.models.map(({ modelId }) => modelId)).toEqual(['gpt-deployed'])
|
||||||
|
expect(requests.map(({ url }) => new URL(url).pathname)).toEqual([
|
||||||
|
'/api/models/providers/azure',
|
||||||
|
])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,22 +1,16 @@
|
|||||||
import { prisma } from '@shumai/db'
|
import { prisma } from '@shumai/db'
|
||||||
import {
|
import {
|
||||||
CreateModelRequest,
|
CreateModelRequest,
|
||||||
|
ImportProviderModelsRequest,
|
||||||
ProviderConfigSerializable,
|
ProviderConfigSerializable,
|
||||||
|
ProviderModelRefreshResponse,
|
||||||
providerModelSchema,
|
providerModelSchema,
|
||||||
SyncApplyRequest,
|
|
||||||
SyncApplyResponse,
|
|
||||||
SyncCheckResponse,
|
|
||||||
SyncModelItem,
|
|
||||||
SyncProviderItem,
|
|
||||||
UpdateModelRequest,
|
UpdateModelRequest,
|
||||||
} from '@shumai/dtos'
|
} from '@shumai/dtos'
|
||||||
import {
|
import { getBuiltinProvidersMap } from '@shumai/core/src/provider/builtin'
|
||||||
ENV_MAP,
|
import { HTTPException } from 'hono/http-exception'
|
||||||
getBuiltinProvidersMap,
|
|
||||||
PRIORITY_PROVIDERS,
|
|
||||||
} from '@shumai/core/src/provider/builtin'
|
|
||||||
import { generateModels } from '@shumai/core/src/provider/generator/generate-models'
|
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
import { discoverProviderModels, getRefreshConnection, isProviderConfigured } from './model-refresh'
|
||||||
|
|
||||||
type ProviderModel = z.infer<typeof providerModelSchema>
|
type ProviderModel = z.infer<typeof providerModelSchema>
|
||||||
|
|
||||||
@@ -70,11 +64,23 @@ export class ProviderService {
|
|||||||
orderBy: { id: 'desc' },
|
orderBy: { id: 'desc' },
|
||||||
})
|
})
|
||||||
|
|
||||||
return providers.map((p) => ({
|
return providers.map(
|
||||||
...p,
|
({ _count, id, teamId, name, config, isBuiltin, createdAt, updatedAt }) => {
|
||||||
modelsCount: p._count.models,
|
const connection = getRefreshConnection(name, config)
|
||||||
_count: undefined,
|
return {
|
||||||
}))
|
id,
|
||||||
|
teamId,
|
||||||
|
name,
|
||||||
|
config,
|
||||||
|
isBuiltin,
|
||||||
|
createdAt,
|
||||||
|
updatedAt,
|
||||||
|
modelsCount: _count.models,
|
||||||
|
configured: isProviderConfigured(name, config),
|
||||||
|
refreshUnavailableReason: connection.unavailableReason,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async getById(id: string) {
|
async getById(id: string) {
|
||||||
@@ -124,6 +130,11 @@ export class ProviderService {
|
|||||||
name?: string,
|
name?: string,
|
||||||
) {
|
) {
|
||||||
return this.prismaClient.$transaction(async (tx) => {
|
return this.prismaClient.$transaction(async (tx) => {
|
||||||
|
const provider = await tx.provider.update({
|
||||||
|
where: { id, teamId },
|
||||||
|
data: { config, ...(name ? { name } : {}) },
|
||||||
|
})
|
||||||
|
|
||||||
if (models !== undefined) {
|
if (models !== undefined) {
|
||||||
const existingModels = await tx.model.findMany({
|
const existingModels = await tx.model.findMany({
|
||||||
where: { providerId: id },
|
where: { providerId: id },
|
||||||
@@ -189,15 +200,7 @@ export class ProviderService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update provider config and optional name
|
return { ...provider, models: await tx.model.findMany({ where: { providerId: id } }) }
|
||||||
return tx.provider.update({
|
|
||||||
where: { id, teamId },
|
|
||||||
data: {
|
|
||||||
config,
|
|
||||||
...(name ? { name } : {}),
|
|
||||||
},
|
|
||||||
include: { models: true },
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,179 +308,66 @@ export class ProviderService {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async checkUpdates(teamId: string): Promise<SyncCheckResponse> {
|
async refreshModels(teamId: string, providerId: string): Promise<ProviderModelRefreshResponse> {
|
||||||
const catalog = await generateModels({ strict: true, timeoutMs: 30000 })
|
const provider = await this.prismaClient.provider.findUnique({
|
||||||
|
where: { id: providerId, teamId },
|
||||||
if (!catalog || catalog.sortedProviderIds.length === 0) {
|
include: { models: { select: { modelId: true } } },
|
||||||
throw new Error('Failed to retrieve model catalog from upstream services')
|
|
||||||
}
|
|
||||||
|
|
||||||
const existingProviders = await this.prismaClient.provider.findMany({
|
|
||||||
where: { teamId },
|
|
||||||
include: { models: true },
|
|
||||||
})
|
})
|
||||||
|
if (!provider) throw new HTTPException(404, { message: 'Provider not found' })
|
||||||
|
|
||||||
const existingProviderMap = new Map<string, (typeof existingProviders)[number]>()
|
const connection = getRefreshConnection(provider.name, provider.config)
|
||||||
for (const p of existingProviders) {
|
if (connection.unavailableReason) {
|
||||||
existingProviderMap.set(p.name, p)
|
return { status: 'unavailable', reason: connection.unavailableReason }
|
||||||
}
|
}
|
||||||
|
const catalog = await discoverProviderModels(connection.piProviderId, provider.config)
|
||||||
const items: SyncProviderItem[] = []
|
if (catalog.status === 'unavailable') return catalog
|
||||||
let totalNewProviders = 0
|
const existingIds = new Set(provider.models.map(({ modelId }) => modelId))
|
||||||
let totalNewModels = 0
|
|
||||||
|
|
||||||
for (const providerId of catalog.sortedProviderIds) {
|
|
||||||
const modelsMap = catalog.providers[providerId]
|
|
||||||
if (!modelsMap) continue
|
|
||||||
const modelList = Object.values(modelsMap)
|
|
||||||
if (modelList.length === 0) continue
|
|
||||||
|
|
||||||
const existingProvider = existingProviderMap.get(providerId)
|
|
||||||
|
|
||||||
if (!existingProvider) {
|
|
||||||
const firstModel = modelList[0]
|
|
||||||
const newModels: SyncModelItem[] = modelList.map((m) => ({
|
|
||||||
modelId: m.id,
|
|
||||||
name: m.name || m.id,
|
|
||||||
config: {
|
|
||||||
api: m.api as ProviderConfigSerializable['api'],
|
|
||||||
reasoning: m.reasoning ?? false,
|
|
||||||
input: (m.input ?? ['text']) as ('text' | 'image')[],
|
|
||||||
contextWindow: m.contextWindow,
|
|
||||||
maxTokens: m.maxTokens,
|
|
||||||
cost: {
|
|
||||||
input: m.cost?.input ?? 0,
|
|
||||||
output: m.cost?.output ?? 0,
|
|
||||||
cacheRead: m.cost?.cacheRead ?? 0,
|
|
||||||
cacheWrite: m.cost?.cacheWrite ?? 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}))
|
|
||||||
|
|
||||||
items.push({
|
|
||||||
name: providerId,
|
|
||||||
isNewProvider: true,
|
|
||||||
config: {
|
|
||||||
api: firstModel.api as ProviderConfigSerializable['api'],
|
|
||||||
baseUrl: firstModel.baseUrl,
|
|
||||||
apiKey: ENV_MAP[providerId] || '',
|
|
||||||
},
|
|
||||||
models: newModels,
|
|
||||||
})
|
|
||||||
|
|
||||||
totalNewProviders++
|
|
||||||
totalNewModels += newModels.length
|
|
||||||
} else {
|
|
||||||
const existingModelIds = new Set(existingProvider.models.map((m) => m.modelId))
|
|
||||||
const newModels: SyncModelItem[] = []
|
|
||||||
|
|
||||||
for (const m of modelList) {
|
|
||||||
if (!existingModelIds.has(m.id)) {
|
|
||||||
newModels.push({
|
|
||||||
modelId: m.id,
|
|
||||||
name: m.name || m.id,
|
|
||||||
config: {
|
|
||||||
api: m.api as ProviderConfigSerializable['api'],
|
|
||||||
reasoning: m.reasoning ?? false,
|
|
||||||
input: (m.input ?? ['text']) as ('text' | 'image')[],
|
|
||||||
contextWindow: m.contextWindow,
|
|
||||||
maxTokens: m.maxTokens,
|
|
||||||
cost: {
|
|
||||||
input: m.cost?.input ?? 0,
|
|
||||||
output: m.cost?.output ?? 0,
|
|
||||||
cacheRead: m.cost?.cacheRead ?? 0,
|
|
||||||
cacheWrite: m.cost?.cacheWrite ?? 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newModels.length > 0) {
|
|
||||||
items.push({
|
|
||||||
name: providerId,
|
|
||||||
isNewProvider: false,
|
|
||||||
config: existingProvider.config as ProviderConfigSerializable,
|
|
||||||
models: newModels,
|
|
||||||
})
|
|
||||||
totalNewModels += newModels.length
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
items.sort((a, b) => {
|
|
||||||
const indexA = PRIORITY_PROVIDERS.indexOf(a.name)
|
|
||||||
const indexB = PRIORITY_PROVIDERS.indexOf(b.name)
|
|
||||||
if (indexA !== -1 && indexB !== -1) return indexA - indexB
|
|
||||||
if (indexA !== -1) return -1
|
|
||||||
if (indexB !== -1) return 1
|
|
||||||
return a.name.localeCompare(b.name)
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
providers: items,
|
status: 'ready',
|
||||||
totalNewProviders,
|
providerUpdatedAt: provider.updatedAt.toISOString(),
|
||||||
totalNewModels,
|
models: catalog.models.filter(({ modelId }) => !existingIds.has(modelId)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async applySync(teamId: string, payload: SyncApplyRequest): Promise<SyncApplyResponse> {
|
async importModels(
|
||||||
let addedProviders = 0
|
teamId: string,
|
||||||
let addedModels = 0
|
providerId: string,
|
||||||
|
{ modelIds, providerUpdatedAt }: ImportProviderModelsRequest,
|
||||||
await this.prismaClient.$transaction(async (tx) => {
|
) {
|
||||||
for (const providerItem of payload.providers) {
|
const provider = await this.prismaClient.provider.findUnique({
|
||||||
let providerId: string
|
where: { id: providerId, teamId },
|
||||||
|
include: { models: { where: { modelId: { in: modelIds } }, select: { modelId: true } } },
|
||||||
if (providerItem.isNewProvider) {
|
|
||||||
const existing = await tx.provider.findFirst({
|
|
||||||
where: { teamId, name: providerItem.name },
|
|
||||||
})
|
|
||||||
if (!existing) {
|
|
||||||
const created = await tx.provider.create({
|
|
||||||
data: {
|
|
||||||
teamId,
|
|
||||||
name: providerItem.name,
|
|
||||||
isBuiltin: true,
|
|
||||||
config: providerItem.config,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
providerId = created.id
|
|
||||||
addedProviders++
|
|
||||||
} else {
|
|
||||||
providerId = existing.id
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const existing = await tx.provider.findFirst({
|
|
||||||
where: { teamId, name: providerItem.name },
|
|
||||||
})
|
|
||||||
if (!existing) continue
|
|
||||||
providerId = existing.id
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const modelItem of providerItem.models) {
|
|
||||||
const existingModel = await tx.model.findFirst({
|
|
||||||
where: {
|
|
||||||
providerId,
|
|
||||||
modelId: modelItem.modelId,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if (!existingModel) {
|
|
||||||
await tx.model.create({
|
|
||||||
data: {
|
|
||||||
providerId,
|
|
||||||
modelId: modelItem.modelId,
|
|
||||||
name: modelItem.name || modelItem.modelId,
|
|
||||||
config: modelItem.config,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
addedModels++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
if (!provider) throw new HTTPException(404, { message: 'Provider not found' })
|
||||||
|
const staleSelection = () =>
|
||||||
|
new HTTPException(409, { message: 'Refresh the model list before importing' })
|
||||||
|
if (provider.updatedAt.toISOString() !== providerUpdatedAt) throw staleSelection()
|
||||||
|
const existingIds = new Set(provider.models.map(({ modelId }) => modelId))
|
||||||
|
const newIds = new Set(modelIds.filter((modelId) => !existingIds.has(modelId)))
|
||||||
|
if (newIds.size === 0) return { addedModels: 0 }
|
||||||
|
|
||||||
return { addedProviders, addedModels }
|
const connection = getRefreshConnection(provider.name, provider.config)
|
||||||
|
if (connection.unavailableReason) throw staleSelection()
|
||||||
|
const catalog = await discoverProviderModels(connection.piProviderId, provider.config)
|
||||||
|
if (catalog.status === 'unavailable') throw staleSelection()
|
||||||
|
const models = catalog.models.filter(({ modelId }) => newIds.has(modelId))
|
||||||
|
if (models.length !== newIds.size) throw staleSelection()
|
||||||
|
|
||||||
|
return this.prismaClient.$transaction(async (tx) => {
|
||||||
|
// The network request finishes before we lock the connection for the insert.
|
||||||
|
const [locked] = await tx.$queryRaw<{ updatedAt: Date }[]>`
|
||||||
|
SELECT updated_at AS "updatedAt" FROM providers
|
||||||
|
WHERE id = ${providerId} AND team_id = ${teamId} FOR NO KEY UPDATE
|
||||||
|
`
|
||||||
|
if (!locked) throw new HTTPException(404, { message: 'Provider not found' })
|
||||||
|
if (locked.updatedAt.toISOString() !== providerUpdatedAt) throw staleSelection()
|
||||||
|
|
||||||
|
const { count } = await tx.model.createMany({
|
||||||
|
data: models.map(({ modelId, name, config }) => ({ providerId, modelId, name, config })),
|
||||||
|
skipDuplicates: true,
|
||||||
|
})
|
||||||
|
return { addedModels: count }
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
export function getGemmaEmbeddingEndpoint(): string {
|
export function getGemmaOpenAiBaseUrl(): string {
|
||||||
const baseUrl = process.env.GEMMA_EMBEDDING_OPENAI_BASE_URL || 'http://localhost:9379/v1'
|
const baseUrl = process.env.GEMMA_EMBEDDING_OPENAI_BASE_URL || 'http://localhost:9379/v1'
|
||||||
const url = baseUrl.replace(/\/+$/, '')
|
const url = baseUrl.replace(/\/+$/, '').replace(/\/embeddings$/, '')
|
||||||
if (url.endsWith('/embeddings')) return url
|
return url.endsWith('/v1') ? url : `${url}/v1`
|
||||||
return url.endsWith('/v1') ? `${url}/embeddings` : `${url}/v1/embeddings`
|
}
|
||||||
|
|
||||||
|
export function getGemmaEmbeddingEndpoint(): string {
|
||||||
|
const baseUrl = process.env.GEMMA_EMBEDDING_OPENAI_BASE_URL?.replace(/\/+$/, '')
|
||||||
|
return baseUrl?.endsWith('/embeddings') ? baseUrl : `${getGemmaOpenAiBaseUrl()}/embeddings`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import { getGemmaOpenAiBaseUrl } from '@shumai/core/src/search/gemma-embedding-endpoint'
|
||||||
|
import { transcriptLanguageCodeSchema, transcriptLanguagesSchema } from '@shumai/dtos'
|
||||||
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
const transcriptEndpoint = () => `${getGemmaOpenAiBaseUrl()}/audio/transcriptions`
|
||||||
|
|
||||||
|
export function isLocalTranscriptionEnabled(): boolean {
|
||||||
|
return process.env.EMBEDDING_PROVIDER === 'gemma-embedding-2-openai'
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function listLocalTranscriptionLanguages() {
|
||||||
|
const response = await fetch(`${transcriptEndpoint()}/languages`, {
|
||||||
|
signal: AbortSignal.timeout(5_000),
|
||||||
|
})
|
||||||
|
if (!response.ok) throw new Error(`Transcription languages endpoint returned ${response.status}`)
|
||||||
|
return transcriptLanguagesSchema.parse(await response.json())
|
||||||
|
}
|
||||||
|
|
||||||
|
const transcriptResponseSchema = z
|
||||||
|
.object({
|
||||||
|
language: transcriptLanguageCodeSchema.nullable(),
|
||||||
|
segments: z.array(
|
||||||
|
z
|
||||||
|
.object({ start: z.number().min(0), end: z.number().min(0), text: z.string().min(1) })
|
||||||
|
.refine((segment) => segment.end >= segment.start && segment.end < 2_147_483),
|
||||||
|
),
|
||||||
|
})
|
||||||
|
.refine((result) => result.language !== null || result.segments.length === 0)
|
||||||
|
|
||||||
|
export class LocalTranscriptionError extends Error {
|
||||||
|
constructor(readonly status: number) {
|
||||||
|
super(`Transcription server returned HTTP ${status}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function transcribeLocalAudio({
|
||||||
|
audio,
|
||||||
|
language,
|
||||||
|
model,
|
||||||
|
signal,
|
||||||
|
}: {
|
||||||
|
audio: Blob
|
||||||
|
language: string | null
|
||||||
|
model: string
|
||||||
|
signal?: AbortSignal
|
||||||
|
}) {
|
||||||
|
const form = new FormData()
|
||||||
|
form.set('file', audio, 'audio.wav')
|
||||||
|
form.set('model', model)
|
||||||
|
form.set('response_format', 'verbose_json')
|
||||||
|
if (language) form.set('language', language)
|
||||||
|
|
||||||
|
const timeout = AbortSignal.timeout(90 * 60 * 1000)
|
||||||
|
const response = await fetch(transcriptEndpoint(), {
|
||||||
|
method: 'POST',
|
||||||
|
body: form,
|
||||||
|
redirect: 'error',
|
||||||
|
timeout: false,
|
||||||
|
signal: signal ? AbortSignal.any([signal, timeout]) : timeout,
|
||||||
|
})
|
||||||
|
if (!response.ok) {
|
||||||
|
await response.body?.cancel()
|
||||||
|
throw new LocalTranscriptionError(response.status)
|
||||||
|
}
|
||||||
|
return transcriptResponseSchema.parse(await response.json())
|
||||||
|
}
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
import { prisma, WorkflowTaskType } from '@shumai/db'
|
||||||
|
import { setupTestDbHooks } from '@shumai/db/test'
|
||||||
|
import { transcriptionErrors } from '@shumai/dtos'
|
||||||
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||||
|
import { transcriptService } from './transcript'
|
||||||
|
|
||||||
|
describe('TranscriptService', () => {
|
||||||
|
setupTestDbHooks()
|
||||||
|
let assetId: string
|
||||||
|
let projectId: string
|
||||||
|
const model = 'whisper-tiny'
|
||||||
|
const segments = [{ startMs: 125, endMs: 1425, text: 'Original segment' }]
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
vi.stubEnv('EMBEDDING_PROVIDER', 'gemma-embedding-2-openai')
|
||||||
|
const team = await prisma.team.create({ data: { name: 'Transcript test' } })
|
||||||
|
const project = await prisma.project.create({
|
||||||
|
data: { name: 'Transcript test', teamId: team.id },
|
||||||
|
})
|
||||||
|
projectId = project.id
|
||||||
|
const asset = await prisma.asset.create({
|
||||||
|
data: {
|
||||||
|
name: 'Video',
|
||||||
|
type: 'file',
|
||||||
|
status: 'processed',
|
||||||
|
mediaType: 'video/mp4',
|
||||||
|
project: { connect: { id: projectId } },
|
||||||
|
storageKey: { create: { key: 'files/transcript-video.mp4' } },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
assetId = asset.id
|
||||||
|
vi.spyOn(globalThis, 'fetch').mockImplementation(async () =>
|
||||||
|
Response.json({
|
||||||
|
model,
|
||||||
|
languages: [
|
||||||
|
{ code: 'en', name: 'English' },
|
||||||
|
{ code: 'zh', name: 'Chinese' },
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
vi.restoreAllMocks()
|
||||||
|
vi.unstubAllEnvs()
|
||||||
|
})
|
||||||
|
|
||||||
|
async function generateAndStart(language: string | null) {
|
||||||
|
const result = await transcriptService.generate(assetId, language)
|
||||||
|
if (result.kind !== 'queued') throw new Error(`Unexpected generation result ${result.kind}`)
|
||||||
|
await prisma.workflowTask.update({
|
||||||
|
where: { id: result.taskId },
|
||||||
|
data: { status: 'processing' },
|
||||||
|
})
|
||||||
|
return result.taskId
|
||||||
|
}
|
||||||
|
|
||||||
|
it('validates provider capability, language and asset eligibility before queuing', async () => {
|
||||||
|
await expect(transcriptService.listLanguages()).resolves.toMatchObject({ model })
|
||||||
|
await expect(transcriptService.generate(assetId, 'xx')).rejects.toMatchObject({ status: 400 })
|
||||||
|
await prisma.asset.update({ where: { id: assetId }, data: { mediaType: 'image/png' } })
|
||||||
|
await expect(transcriptService.generate(assetId, 'en')).rejects.toMatchObject({ status: 400 })
|
||||||
|
|
||||||
|
vi.stubEnv('EMBEDDING_PROVIDER', 'gemini-embedding-2')
|
||||||
|
await expect(transcriptService.listLanguages()).rejects.toMatchObject({ status: 503 })
|
||||||
|
await expect(transcriptService.generate(assetId, null)).rejects.toMatchObject({ status: 503 })
|
||||||
|
expect(await prisma.workflowTask.count({ where: { assetId } })).toBe(0)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('serializes requests for an asset and uses its project and workflow type', async () => {
|
||||||
|
const results = await Promise.all([
|
||||||
|
transcriptService.generate(assetId, 'en'),
|
||||||
|
transcriptService.generate(assetId, 'zh'),
|
||||||
|
])
|
||||||
|
|
||||||
|
expect(results.map((result) => result.kind).sort()).toEqual(['busy', 'queued'])
|
||||||
|
const tasks = await prisma.workflowTask.findMany({ where: { assetId } })
|
||||||
|
expect(tasks).toHaveLength(1)
|
||||||
|
expect(tasks[0]).toMatchObject({
|
||||||
|
projectId,
|
||||||
|
type: WorkflowTaskType.ai_transcription,
|
||||||
|
status: 'pending',
|
||||||
|
})
|
||||||
|
expect(await transcriptService.getStatus(assetId)).toEqual({
|
||||||
|
taskId: tasks[0].id,
|
||||||
|
status: 'pending',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('persists languages independently and preserves saved text on replay and requests for an existing language', async () => {
|
||||||
|
const enTaskId = await generateAndStart('en')
|
||||||
|
const first = { taskId: enTaskId, assetId, model, language: 'en', segments }
|
||||||
|
await transcriptService.saveResult(first)
|
||||||
|
const en = await prisma.assetTranscript.findUniqueOrThrow({
|
||||||
|
where: { assetIdLanguage: { assetId, language: 'en' } },
|
||||||
|
})
|
||||||
|
await prisma.assetTranscriptSegment.update({
|
||||||
|
where: { transcriptIdPosition: { transcriptId: en.id, position: 0 } },
|
||||||
|
data: { text: 'Edited' },
|
||||||
|
})
|
||||||
|
await transcriptService.saveResult(first)
|
||||||
|
expect(await transcriptService.generate(assetId, 'en')).toEqual({
|
||||||
|
kind: 'existing',
|
||||||
|
transcriptId: en.id,
|
||||||
|
language: 'en',
|
||||||
|
})
|
||||||
|
|
||||||
|
const autoTaskId = await generateAndStart(null)
|
||||||
|
await transcriptService.saveResult({ ...first, taskId: autoTaskId })
|
||||||
|
expect(await transcriptService.generate(assetId, null)).toEqual({
|
||||||
|
kind: 'existing',
|
||||||
|
transcriptId: en.id,
|
||||||
|
language: 'en',
|
||||||
|
})
|
||||||
|
expect(
|
||||||
|
await prisma.assetTranscriptSegment.findMany({ where: { transcriptId: en.id } }),
|
||||||
|
).toMatchObject([
|
||||||
|
{
|
||||||
|
position: 0,
|
||||||
|
startMs: 125,
|
||||||
|
endMs: 1425,
|
||||||
|
text: 'Edited',
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
const zhTaskId = await generateAndStart('zh')
|
||||||
|
await transcriptService.saveResult({ ...first, taskId: zhTaskId, language: 'zh' })
|
||||||
|
expect(await prisma.assetTranscript.count({ where: { assetId } })).toBe(2)
|
||||||
|
expect(await prisma.workflowTask.count({ where: { assetId } })).toBe(3)
|
||||||
|
expect(await transcriptService.getStatus(assetId)).toEqual({
|
||||||
|
taskId: zhTaskId,
|
||||||
|
status: 'completed',
|
||||||
|
})
|
||||||
|
|
||||||
|
await prisma.asset.delete({ where: { id: assetId } })
|
||||||
|
expect(await prisma.assetTranscript.count({ where: { assetId } })).toBe(0)
|
||||||
|
expect(await prisma.assetTranscriptSegment.count({ where: { transcriptId: en.id } })).toBe(0)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('completes silence without creating a row for an unknown language', async () => {
|
||||||
|
const taskId = await generateAndStart(null)
|
||||||
|
await transcriptService.saveResult({ taskId, assetId, model, language: null, segments: [] })
|
||||||
|
expect(await transcriptService.getStatus(assetId)).toEqual({ taskId, status: 'no_speech' })
|
||||||
|
expect(await transcriptService.generate(assetId, null)).toEqual({ kind: 'no_speech' })
|
||||||
|
expect(await prisma.assetTranscript.count({ where: { assetId } })).toBe(0)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('preserves a failed job and translates known failure reasons', async () => {
|
||||||
|
const taskId = await generateAndStart(null)
|
||||||
|
await prisma.workflowTask.update({
|
||||||
|
where: { id: taskId },
|
||||||
|
data: {
|
||||||
|
status: 'failed',
|
||||||
|
output: { error: transcriptionErrors.tooLarge },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
await transcriptService.saveResult({ taskId, assetId, model, language: 'en', segments })
|
||||||
|
expect(await transcriptService.getStatus(assetId)).toEqual({
|
||||||
|
taskId,
|
||||||
|
status: 'failed',
|
||||||
|
reason: 'tooLarge',
|
||||||
|
})
|
||||||
|
expect(await prisma.assetTranscript.count({ where: { assetId } })).toBe(0)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,232 @@
|
|||||||
|
import { logger } from '@shumai/core/src/logger'
|
||||||
|
import {
|
||||||
|
notifyWorkflowTaskCreated,
|
||||||
|
prisma,
|
||||||
|
Prisma,
|
||||||
|
WorkflowTaskType,
|
||||||
|
type WorkflowTask,
|
||||||
|
} from '@shumai/db'
|
||||||
|
import {
|
||||||
|
transcriptionErrors,
|
||||||
|
type GenerateTranscriptResult,
|
||||||
|
type TranscriptJobStatus,
|
||||||
|
} from '@shumai/dtos'
|
||||||
|
import { HTTPException } from 'hono/http-exception'
|
||||||
|
import { isLocalTranscriptionEnabled, listLocalTranscriptionLanguages } from './local-transcription'
|
||||||
|
|
||||||
|
const type = WorkflowTaskType.ai_transcription
|
||||||
|
|
||||||
|
const transcriptSelection = { id: true, language: true } as const
|
||||||
|
|
||||||
|
type Segment = { startMs: number; endMs: number; text: string }
|
||||||
|
|
||||||
|
export class TranscriptService {
|
||||||
|
async listLanguages() {
|
||||||
|
this.requireEnabled()
|
||||||
|
try {
|
||||||
|
return await listLocalTranscriptionLanguages()
|
||||||
|
} catch (error) {
|
||||||
|
logger.warn({ err: error }, 'Failed to load local transcription languages')
|
||||||
|
throw new HTTPException(503, { message: 'Transcription languages are unavailable' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async generate(assetId: string, language: string | null): Promise<GenerateTranscriptResult> {
|
||||||
|
this.requireEnabled()
|
||||||
|
const saved = await this.findSaved(prisma, assetId, language)
|
||||||
|
if (saved) return saved
|
||||||
|
|
||||||
|
const { model, languages } = await this.listLanguages()
|
||||||
|
if (language && !languages.some((entry) => entry.code === language)) {
|
||||||
|
throw new HTTPException(400, { message: 'Unsupported transcription language' })
|
||||||
|
}
|
||||||
|
|
||||||
|
const { result, task } = await prisma.$transaction(
|
||||||
|
async (tx): Promise<{ result: GenerateTranscriptResult; task?: WorkflowTask }> => {
|
||||||
|
// Serialize submissions and result commits for a single video asset.
|
||||||
|
await tx.$queryRaw`SELECT id FROM assets WHERE id = ${assetId} FOR UPDATE`
|
||||||
|
const savedAfterLock = await this.findSaved(tx, assetId, language)
|
||||||
|
if (savedAfterLock) return { result: savedAfterLock }
|
||||||
|
|
||||||
|
const asset = await tx.asset.findFirst({
|
||||||
|
where: {
|
||||||
|
id: assetId,
|
||||||
|
type: 'file',
|
||||||
|
status: 'processed',
|
||||||
|
isDeleted: false,
|
||||||
|
mediaType: { startsWith: 'video/' },
|
||||||
|
storageKey: { status: 'active', isArchived: false },
|
||||||
|
},
|
||||||
|
select: { project: { select: { id: true, teamId: true } } },
|
||||||
|
})
|
||||||
|
if (!asset?.project) {
|
||||||
|
throw new HTTPException(400, { message: 'Transcripts require a processed video file' })
|
||||||
|
}
|
||||||
|
|
||||||
|
const active = await tx.workflowTask.findFirst({
|
||||||
|
where: { assetId, type, status: { in: ['pending', 'processing'] } },
|
||||||
|
orderBy: { id: 'desc' },
|
||||||
|
})
|
||||||
|
if (active) return { result: { kind: 'busy', taskId: active.id }, task: active }
|
||||||
|
|
||||||
|
// Notify the worker after commit so it can observe the task row as soon as it starts.
|
||||||
|
const [created] = await tx.workflowTask.createManyAndReturn({
|
||||||
|
data: {
|
||||||
|
assetId,
|
||||||
|
teamId: asset.project.teamId,
|
||||||
|
projectId: asset.project.id,
|
||||||
|
type,
|
||||||
|
status: 'pending',
|
||||||
|
payload: { projectId: asset.project.id, transcription: { language, model } },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
return { result: { kind: 'queued', taskId: created.id }, task: created }
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if (task?.status === 'pending') {
|
||||||
|
try {
|
||||||
|
await notifyWorkflowTaskCreated(task)
|
||||||
|
} catch (error) {
|
||||||
|
logger.error({ err: error, taskId: task.id }, 'Failed to queue transcript generation')
|
||||||
|
await prisma.workflowTask.updateMany({
|
||||||
|
where: { id: task.id, status: 'pending' },
|
||||||
|
data: { status: 'failed', output: { error: 'Failed to queue transcript generation' } },
|
||||||
|
})
|
||||||
|
throw new HTTPException(503, { message: 'Could not queue transcript generation' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
async getStatus(assetId: string): Promise<TranscriptJobStatus | null> {
|
||||||
|
const task = await prisma.workflowTask.findFirst({
|
||||||
|
where: { assetId, type },
|
||||||
|
orderBy: { id: 'desc' },
|
||||||
|
select: { id: true, status: true, output: true },
|
||||||
|
})
|
||||||
|
if (!task?.status) return null
|
||||||
|
if (task.status === 'failed') {
|
||||||
|
const error = task.output?.error ?? ''
|
||||||
|
const reason = error.includes(transcriptionErrors.tooLarge)
|
||||||
|
? 'tooLarge'
|
||||||
|
: error.includes(transcriptionErrors.noAudio)
|
||||||
|
? 'noAudio'
|
||||||
|
: 'unknown'
|
||||||
|
return { status: 'failed', taskId: task.id, reason }
|
||||||
|
}
|
||||||
|
const transcript = task.output?.transcription
|
||||||
|
return {
|
||||||
|
taskId: task.id,
|
||||||
|
status:
|
||||||
|
task.status === 'completed' && transcript && 'noSpeech' in transcript
|
||||||
|
? 'no_speech'
|
||||||
|
: task.status,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async saveResult(params: {
|
||||||
|
taskId: string
|
||||||
|
assetId: string
|
||||||
|
model: string
|
||||||
|
language: string | null
|
||||||
|
segments: Segment[]
|
||||||
|
}): Promise<boolean> {
|
||||||
|
const { taskId, assetId, model, language, segments } = params
|
||||||
|
return await prisma.$transaction(async (tx) => {
|
||||||
|
const [asset] = await tx.$queryRaw<{ id: string }[]>`
|
||||||
|
SELECT id FROM assets
|
||||||
|
WHERE id = ${assetId} AND NOT is_deleted AND status = 'processed'
|
||||||
|
FOR UPDATE
|
||||||
|
`
|
||||||
|
if (!asset) return false
|
||||||
|
|
||||||
|
const task = await tx.workflowTask.updateMany({
|
||||||
|
where: { id: taskId, assetId, type, status: 'processing' },
|
||||||
|
data: { status: 'completed', model },
|
||||||
|
})
|
||||||
|
if (task.count === 0) return true
|
||||||
|
|
||||||
|
const existing = language
|
||||||
|
? await tx.assetTranscript.findUnique({
|
||||||
|
where: { assetIdLanguage: { assetId, language } },
|
||||||
|
select: transcriptSelection,
|
||||||
|
})
|
||||||
|
: null
|
||||||
|
|
||||||
|
const transcript =
|
||||||
|
existing ??
|
||||||
|
(language && segments.length > 0
|
||||||
|
? await tx.assetTranscript.create({
|
||||||
|
data: {
|
||||||
|
assetId,
|
||||||
|
language,
|
||||||
|
model,
|
||||||
|
workflowTaskId: taskId,
|
||||||
|
segments: {
|
||||||
|
createMany: {
|
||||||
|
data: segments.map((segment, position) => ({ ...segment, position })),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
select: transcriptSelection,
|
||||||
|
})
|
||||||
|
: null)
|
||||||
|
|
||||||
|
await tx.workflowTask.update({
|
||||||
|
where: { id: taskId },
|
||||||
|
data: {
|
||||||
|
output: {
|
||||||
|
transcription: transcript
|
||||||
|
? { transcriptId: transcript.id, language: transcript.language }
|
||||||
|
: { noSpeech: true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private requireEnabled(): void {
|
||||||
|
if (!isLocalTranscriptionEnabled()) {
|
||||||
|
throw new HTTPException(503, { message: 'Local transcription is disabled' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async findSaved(
|
||||||
|
db: Pick<Prisma.TransactionClient, 'assetTranscript' | 'workflowTask'>,
|
||||||
|
assetId: string,
|
||||||
|
language: string | null,
|
||||||
|
): Promise<GenerateTranscriptResult | null> {
|
||||||
|
if (language) {
|
||||||
|
const transcript = await db.assetTranscript.findUnique({
|
||||||
|
where: { assetIdLanguage: { assetId, language } },
|
||||||
|
select: transcriptSelection,
|
||||||
|
})
|
||||||
|
return transcript ? { kind: 'existing', transcriptId: transcript.id, language } : null
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto = await db.workflowTask.findFirst({
|
||||||
|
where: {
|
||||||
|
assetId,
|
||||||
|
type,
|
||||||
|
status: 'completed',
|
||||||
|
payload: { path: ['transcription', 'language'], equals: Prisma.JsonNull },
|
||||||
|
},
|
||||||
|
select: { output: true },
|
||||||
|
orderBy: { id: 'desc' },
|
||||||
|
})
|
||||||
|
const result = auto?.output?.transcription
|
||||||
|
if (!result) return null
|
||||||
|
if ('noSpeech' in result) return { kind: 'no_speech' }
|
||||||
|
const transcript = await db.assetTranscript.findUnique({
|
||||||
|
where: { id: result.transcriptId },
|
||||||
|
select: transcriptSelection,
|
||||||
|
})
|
||||||
|
return transcript
|
||||||
|
? { kind: 'existing', transcriptId: transcript.id, language: transcript.language }
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const transcriptService = new TranscriptService()
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
-- AlterEnum
|
||||||
|
ALTER TYPE "WorkflowTaskType" ADD VALUE 'ai_transcription';
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "asset_transcripts" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"asset_id" TEXT NOT NULL,
|
||||||
|
"language" TEXT NOT NULL,
|
||||||
|
"model" TEXT NOT NULL,
|
||||||
|
"workflow_task_id" TEXT NOT NULL,
|
||||||
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updated_at" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "asset_transcripts_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "asset_transcript_segments" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"transcript_id" TEXT NOT NULL,
|
||||||
|
"position" INTEGER NOT NULL,
|
||||||
|
"start_ms" INTEGER NOT NULL,
|
||||||
|
"end_ms" INTEGER NOT NULL,
|
||||||
|
"text" TEXT NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "asset_transcript_segments_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "asset_transcripts_asset_id_language_key" ON "asset_transcripts"("asset_id", "language");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "asset_transcript_segments_transcript_id_position_key" ON "asset_transcript_segments"("transcript_id", "position");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "asset_transcripts" ADD CONSTRAINT "asset_transcripts_asset_id_fkey" FOREIGN KEY ("asset_id") REFERENCES "assets"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "asset_transcript_segments" ADD CONSTRAINT "asset_transcript_segments_transcript_id_fkey" FOREIGN KEY ("transcript_id") REFERENCES "asset_transcripts"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
@@ -129,6 +129,7 @@ enum WorkflowTaskType {
|
|||||||
ai_metadata_autofill
|
ai_metadata_autofill
|
||||||
chat
|
chat
|
||||||
ai_embedding
|
ai_embedding
|
||||||
|
ai_transcription
|
||||||
query_embedding_for_search
|
query_embedding_for_search
|
||||||
agent_tool_call // @deprecated: Agent tools now execute directly in-process via Core services
|
agent_tool_call // @deprecated: Agent tools now execute directly in-process via Core services
|
||||||
kanban_agent_run
|
kanban_agent_run
|
||||||
@@ -619,6 +620,7 @@ model Asset {
|
|||||||
commentAttachments AssetCommentAttachment[] @relation("AssetToCommentAttachment")
|
commentAttachments AssetCommentAttachment[] @relation("AssetToCommentAttachment")
|
||||||
notifications Notification[] @relation("AssetToNotification")
|
notifications Notification[] @relation("AssetToNotification")
|
||||||
embeddings AssetEmbedding[] @relation("AssetToEmbedding")
|
embeddings AssetEmbedding[] @relation("AssetToEmbedding")
|
||||||
|
transcripts AssetTranscript[]
|
||||||
|
|
||||||
teamRootFolder Team? @relation("TeamToRootFolder")
|
teamRootFolder Team? @relation("TeamToRootFolder")
|
||||||
projectRootFolder Project? @relation("ProjectToRootFolder")
|
projectRootFolder Project? @relation("ProjectToRootFolder")
|
||||||
@@ -775,6 +777,34 @@ model AssetEmbedding {
|
|||||||
@@map("asset_embeddings")
|
@@map("asset_embeddings")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model AssetTranscript {
|
||||||
|
id String @id @default(ulid())
|
||||||
|
assetId String @map("asset_id")
|
||||||
|
asset Asset @relation(fields: [assetId], references: [id], onDelete: Cascade)
|
||||||
|
language String
|
||||||
|
model String
|
||||||
|
workflowTaskId String @map("workflow_task_id")
|
||||||
|
createdAt DateTime @default(now()) @map("created_at")
|
||||||
|
updatedAt DateTime @updatedAt @map("updated_at")
|
||||||
|
segments AssetTranscriptSegment[]
|
||||||
|
|
||||||
|
@@unique([assetId, language], name: "assetIdLanguage")
|
||||||
|
@@map("asset_transcripts")
|
||||||
|
}
|
||||||
|
|
||||||
|
model AssetTranscriptSegment {
|
||||||
|
id String @id @default(ulid())
|
||||||
|
transcriptId String @map("transcript_id")
|
||||||
|
transcript AssetTranscript @relation(fields: [transcriptId], references: [id], onDelete: Cascade)
|
||||||
|
position Int
|
||||||
|
startMs Int @map("start_ms")
|
||||||
|
endMs Int @map("end_ms")
|
||||||
|
text String @db.Text
|
||||||
|
|
||||||
|
@@unique([transcriptId, position], name: "transcriptIdPosition")
|
||||||
|
@@map("asset_transcript_segments")
|
||||||
|
}
|
||||||
|
|
||||||
model Invite {
|
model Invite {
|
||||||
id String @id @default(ulid())
|
id String @id @default(ulid())
|
||||||
code String @unique
|
code String @unique
|
||||||
|
|||||||
+10
@@ -137,6 +137,16 @@ export type AssetCommentReaction = Prisma.AssetCommentReactionModel
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export type AssetEmbedding = Prisma.AssetEmbeddingModel
|
export type AssetEmbedding = Prisma.AssetEmbeddingModel
|
||||||
|
/**
|
||||||
|
* Model AssetTranscript
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type AssetTranscript = Prisma.AssetTranscriptModel
|
||||||
|
/**
|
||||||
|
* Model AssetTranscriptSegment
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type AssetTranscriptSegment = Prisma.AssetTranscriptSegmentModel
|
||||||
/**
|
/**
|
||||||
* Model Invite
|
* Model Invite
|
||||||
*
|
*
|
||||||
|
|||||||
+10
@@ -161,6 +161,16 @@ export type AssetCommentReaction = Prisma.AssetCommentReactionModel
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export type AssetEmbedding = Prisma.AssetEmbeddingModel
|
export type AssetEmbedding = Prisma.AssetEmbeddingModel
|
||||||
|
/**
|
||||||
|
* Model AssetTranscript
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type AssetTranscript = Prisma.AssetTranscriptModel
|
||||||
|
/**
|
||||||
|
* Model AssetTranscriptSegment
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export type AssetTranscriptSegment = Prisma.AssetTranscriptSegmentModel
|
||||||
/**
|
/**
|
||||||
* Model Invite
|
* Model Invite
|
||||||
*
|
*
|
||||||
|
|||||||
+1
@@ -158,6 +158,7 @@ export const WorkflowTaskType = {
|
|||||||
ai_metadata_autofill: 'ai_metadata_autofill',
|
ai_metadata_autofill: 'ai_metadata_autofill',
|
||||||
chat: 'chat',
|
chat: 'chat',
|
||||||
ai_embedding: 'ai_embedding',
|
ai_embedding: 'ai_embedding',
|
||||||
|
ai_transcription: 'ai_transcription',
|
||||||
query_embedding_for_search: 'query_embedding_for_search',
|
query_embedding_for_search: 'query_embedding_for_search',
|
||||||
agent_tool_call: 'agent_tool_call',
|
agent_tool_call: 'agent_tool_call',
|
||||||
kanban_agent_run: 'kanban_agent_run',
|
kanban_agent_run: 'kanban_agent_run',
|
||||||
|
|||||||
+24
-4
File diff suppressed because one or more lines are too long
+178
-1
@@ -421,6 +421,8 @@ export const ModelName = {
|
|||||||
AssetCommentAttachment: 'AssetCommentAttachment',
|
AssetCommentAttachment: 'AssetCommentAttachment',
|
||||||
AssetCommentReaction: 'AssetCommentReaction',
|
AssetCommentReaction: 'AssetCommentReaction',
|
||||||
AssetEmbedding: 'AssetEmbedding',
|
AssetEmbedding: 'AssetEmbedding',
|
||||||
|
AssetTranscript: 'AssetTranscript',
|
||||||
|
AssetTranscriptSegment: 'AssetTranscriptSegment',
|
||||||
Invite: 'Invite',
|
Invite: 'Invite',
|
||||||
MetadataField: 'MetadataField',
|
MetadataField: 'MetadataField',
|
||||||
Notification: 'Notification',
|
Notification: 'Notification',
|
||||||
@@ -474,7 +476,7 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
|
|||||||
omit: GlobalOmitOptions
|
omit: GlobalOmitOptions
|
||||||
}
|
}
|
||||||
meta: {
|
meta: {
|
||||||
modelProps: "user" | "session" | "account" | "verification" | "authToken" | "team" | "runner" | "skill" | "teamMember" | "project" | "projectMember" | "shareLink" | "shareActivity" | "watermarkConfig" | "watermarkTemplate" | "watermarkFile" | "asset" | "storageKey" | "assetMetadataValue" | "assetAgentMd" | "assetComment" | "assetCommentAttachment" | "assetCommentReaction" | "assetEmbedding" | "invite" | "metadataField" | "notification" | "systemSettings" | "task" | "workflowTask" | "agent" | "agentSkill" | "mcpServer" | "agentMcpServer" | "mcpServerCredential" | "agentSession" | "agentSessionCommit" | "agentSessionEntry" | "userMetadata" | "model" | "provider" | "collection" | "apiToken" | "aiUsage" | "auditLog" | "quotaRule" | "quotaRecord" | "kanbanGoal" | "kanbanTask" | "kanbanTaskLink" | "kanbanTaskAsset" | "kanbanTaskComment" | "kanbanTaskEvent" | "recentFileItem" | "jwks" | "oauthClient" | "oauthResource" | "oauthClientResource" | "oauthRefreshToken" | "oauthAccessToken" | "oauthConsent" | "oauthClientAssertion"
|
modelProps: "user" | "session" | "account" | "verification" | "authToken" | "team" | "runner" | "skill" | "teamMember" | "project" | "projectMember" | "shareLink" | "shareActivity" | "watermarkConfig" | "watermarkTemplate" | "watermarkFile" | "asset" | "storageKey" | "assetMetadataValue" | "assetAgentMd" | "assetComment" | "assetCommentAttachment" | "assetCommentReaction" | "assetEmbedding" | "assetTranscript" | "assetTranscriptSegment" | "invite" | "metadataField" | "notification" | "systemSettings" | "task" | "workflowTask" | "agent" | "agentSkill" | "mcpServer" | "agentMcpServer" | "mcpServerCredential" | "agentSession" | "agentSessionCommit" | "agentSessionEntry" | "userMetadata" | "model" | "provider" | "collection" | "apiToken" | "aiUsage" | "auditLog" | "quotaRule" | "quotaRecord" | "kanbanGoal" | "kanbanTask" | "kanbanTaskLink" | "kanbanTaskAsset" | "kanbanTaskComment" | "kanbanTaskEvent" | "recentFileItem" | "jwks" | "oauthClient" | "oauthResource" | "oauthClientResource" | "oauthRefreshToken" | "oauthAccessToken" | "oauthConsent" | "oauthClientAssertion"
|
||||||
txIsolationLevel: TransactionIsolationLevel
|
txIsolationLevel: TransactionIsolationLevel
|
||||||
}
|
}
|
||||||
model: {
|
model: {
|
||||||
@@ -2254,6 +2256,154 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
AssetTranscript: {
|
||||||
|
payload: Prisma.$AssetTranscriptPayload<ExtArgs>
|
||||||
|
fields: Prisma.AssetTranscriptFieldRefs
|
||||||
|
operations: {
|
||||||
|
findUnique: {
|
||||||
|
args: Prisma.AssetTranscriptFindUniqueArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptPayload> | null
|
||||||
|
}
|
||||||
|
findUniqueOrThrow: {
|
||||||
|
args: Prisma.AssetTranscriptFindUniqueOrThrowArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptPayload>
|
||||||
|
}
|
||||||
|
findFirst: {
|
||||||
|
args: Prisma.AssetTranscriptFindFirstArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptPayload> | null
|
||||||
|
}
|
||||||
|
findFirstOrThrow: {
|
||||||
|
args: Prisma.AssetTranscriptFindFirstOrThrowArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptPayload>
|
||||||
|
}
|
||||||
|
findMany: {
|
||||||
|
args: Prisma.AssetTranscriptFindManyArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptPayload>[]
|
||||||
|
}
|
||||||
|
create: {
|
||||||
|
args: Prisma.AssetTranscriptCreateArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptPayload>
|
||||||
|
}
|
||||||
|
createMany: {
|
||||||
|
args: Prisma.AssetTranscriptCreateManyArgs<ExtArgs>
|
||||||
|
result: BatchPayload
|
||||||
|
}
|
||||||
|
createManyAndReturn: {
|
||||||
|
args: Prisma.AssetTranscriptCreateManyAndReturnArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptPayload>[]
|
||||||
|
}
|
||||||
|
delete: {
|
||||||
|
args: Prisma.AssetTranscriptDeleteArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptPayload>
|
||||||
|
}
|
||||||
|
update: {
|
||||||
|
args: Prisma.AssetTranscriptUpdateArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptPayload>
|
||||||
|
}
|
||||||
|
deleteMany: {
|
||||||
|
args: Prisma.AssetTranscriptDeleteManyArgs<ExtArgs>
|
||||||
|
result: BatchPayload
|
||||||
|
}
|
||||||
|
updateMany: {
|
||||||
|
args: Prisma.AssetTranscriptUpdateManyArgs<ExtArgs>
|
||||||
|
result: BatchPayload
|
||||||
|
}
|
||||||
|
updateManyAndReturn: {
|
||||||
|
args: Prisma.AssetTranscriptUpdateManyAndReturnArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptPayload>[]
|
||||||
|
}
|
||||||
|
upsert: {
|
||||||
|
args: Prisma.AssetTranscriptUpsertArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptPayload>
|
||||||
|
}
|
||||||
|
aggregate: {
|
||||||
|
args: Prisma.AssetTranscriptAggregateArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.Optional<Prisma.AggregateAssetTranscript>
|
||||||
|
}
|
||||||
|
groupBy: {
|
||||||
|
args: Prisma.AssetTranscriptGroupByArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.Optional<Prisma.AssetTranscriptGroupByOutputType>[]
|
||||||
|
}
|
||||||
|
count: {
|
||||||
|
args: Prisma.AssetTranscriptCountArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.Optional<Prisma.AssetTranscriptCountAggregateOutputType> | number
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AssetTranscriptSegment: {
|
||||||
|
payload: Prisma.$AssetTranscriptSegmentPayload<ExtArgs>
|
||||||
|
fields: Prisma.AssetTranscriptSegmentFieldRefs
|
||||||
|
operations: {
|
||||||
|
findUnique: {
|
||||||
|
args: Prisma.AssetTranscriptSegmentFindUniqueArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptSegmentPayload> | null
|
||||||
|
}
|
||||||
|
findUniqueOrThrow: {
|
||||||
|
args: Prisma.AssetTranscriptSegmentFindUniqueOrThrowArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptSegmentPayload>
|
||||||
|
}
|
||||||
|
findFirst: {
|
||||||
|
args: Prisma.AssetTranscriptSegmentFindFirstArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptSegmentPayload> | null
|
||||||
|
}
|
||||||
|
findFirstOrThrow: {
|
||||||
|
args: Prisma.AssetTranscriptSegmentFindFirstOrThrowArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptSegmentPayload>
|
||||||
|
}
|
||||||
|
findMany: {
|
||||||
|
args: Prisma.AssetTranscriptSegmentFindManyArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptSegmentPayload>[]
|
||||||
|
}
|
||||||
|
create: {
|
||||||
|
args: Prisma.AssetTranscriptSegmentCreateArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptSegmentPayload>
|
||||||
|
}
|
||||||
|
createMany: {
|
||||||
|
args: Prisma.AssetTranscriptSegmentCreateManyArgs<ExtArgs>
|
||||||
|
result: BatchPayload
|
||||||
|
}
|
||||||
|
createManyAndReturn: {
|
||||||
|
args: Prisma.AssetTranscriptSegmentCreateManyAndReturnArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptSegmentPayload>[]
|
||||||
|
}
|
||||||
|
delete: {
|
||||||
|
args: Prisma.AssetTranscriptSegmentDeleteArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptSegmentPayload>
|
||||||
|
}
|
||||||
|
update: {
|
||||||
|
args: Prisma.AssetTranscriptSegmentUpdateArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptSegmentPayload>
|
||||||
|
}
|
||||||
|
deleteMany: {
|
||||||
|
args: Prisma.AssetTranscriptSegmentDeleteManyArgs<ExtArgs>
|
||||||
|
result: BatchPayload
|
||||||
|
}
|
||||||
|
updateMany: {
|
||||||
|
args: Prisma.AssetTranscriptSegmentUpdateManyArgs<ExtArgs>
|
||||||
|
result: BatchPayload
|
||||||
|
}
|
||||||
|
updateManyAndReturn: {
|
||||||
|
args: Prisma.AssetTranscriptSegmentUpdateManyAndReturnArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptSegmentPayload>[]
|
||||||
|
}
|
||||||
|
upsert: {
|
||||||
|
args: Prisma.AssetTranscriptSegmentUpsertArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.PayloadToResult<Prisma.$AssetTranscriptSegmentPayload>
|
||||||
|
}
|
||||||
|
aggregate: {
|
||||||
|
args: Prisma.AssetTranscriptSegmentAggregateArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.Optional<Prisma.AggregateAssetTranscriptSegment>
|
||||||
|
}
|
||||||
|
groupBy: {
|
||||||
|
args: Prisma.AssetTranscriptSegmentGroupByArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.Optional<Prisma.AssetTranscriptSegmentGroupByOutputType>[]
|
||||||
|
}
|
||||||
|
count: {
|
||||||
|
args: Prisma.AssetTranscriptSegmentCountArgs<ExtArgs>
|
||||||
|
result: runtime.Types.Utils.Optional<Prisma.AssetTranscriptSegmentCountAggregateOutputType> | number
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Invite: {
|
Invite: {
|
||||||
payload: Prisma.$InvitePayload<ExtArgs>
|
payload: Prisma.$InvitePayload<ExtArgs>
|
||||||
fields: Prisma.InviteFieldRefs
|
fields: Prisma.InviteFieldRefs
|
||||||
@@ -5455,6 +5605,31 @@ export const AssetEmbeddingScalarFieldEnum = {
|
|||||||
export type AssetEmbeddingScalarFieldEnum = (typeof AssetEmbeddingScalarFieldEnum)[keyof typeof AssetEmbeddingScalarFieldEnum]
|
export type AssetEmbeddingScalarFieldEnum = (typeof AssetEmbeddingScalarFieldEnum)[keyof typeof AssetEmbeddingScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
|
export const AssetTranscriptScalarFieldEnum = {
|
||||||
|
id: 'id',
|
||||||
|
assetId: 'assetId',
|
||||||
|
language: 'language',
|
||||||
|
model: 'model',
|
||||||
|
workflowTaskId: 'workflowTaskId',
|
||||||
|
createdAt: 'createdAt',
|
||||||
|
updatedAt: 'updatedAt'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type AssetTranscriptScalarFieldEnum = (typeof AssetTranscriptScalarFieldEnum)[keyof typeof AssetTranscriptScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
|
export const AssetTranscriptSegmentScalarFieldEnum = {
|
||||||
|
id: 'id',
|
||||||
|
transcriptId: 'transcriptId',
|
||||||
|
position: 'position',
|
||||||
|
startMs: 'startMs',
|
||||||
|
endMs: 'endMs',
|
||||||
|
text: 'text'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type AssetTranscriptSegmentScalarFieldEnum = (typeof AssetTranscriptSegmentScalarFieldEnum)[keyof typeof AssetTranscriptSegmentScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
export const InviteScalarFieldEnum = {
|
export const InviteScalarFieldEnum = {
|
||||||
id: 'id',
|
id: 'id',
|
||||||
code: 'code',
|
code: 'code',
|
||||||
@@ -6747,6 +6922,8 @@ export type GlobalOmitConfig = {
|
|||||||
assetCommentAttachment?: Prisma.AssetCommentAttachmentOmit
|
assetCommentAttachment?: Prisma.AssetCommentAttachmentOmit
|
||||||
assetCommentReaction?: Prisma.AssetCommentReactionOmit
|
assetCommentReaction?: Prisma.AssetCommentReactionOmit
|
||||||
assetEmbedding?: Prisma.AssetEmbeddingOmit
|
assetEmbedding?: Prisma.AssetEmbeddingOmit
|
||||||
|
assetTranscript?: Prisma.AssetTranscriptOmit
|
||||||
|
assetTranscriptSegment?: Prisma.AssetTranscriptSegmentOmit
|
||||||
invite?: Prisma.InviteOmit
|
invite?: Prisma.InviteOmit
|
||||||
metadataField?: Prisma.MetadataFieldOmit
|
metadataField?: Prisma.MetadataFieldOmit
|
||||||
notification?: Prisma.NotificationOmit
|
notification?: Prisma.NotificationOmit
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ export const ModelName = {
|
|||||||
AssetCommentAttachment: 'AssetCommentAttachment',
|
AssetCommentAttachment: 'AssetCommentAttachment',
|
||||||
AssetCommentReaction: 'AssetCommentReaction',
|
AssetCommentReaction: 'AssetCommentReaction',
|
||||||
AssetEmbedding: 'AssetEmbedding',
|
AssetEmbedding: 'AssetEmbedding',
|
||||||
|
AssetTranscript: 'AssetTranscript',
|
||||||
|
AssetTranscriptSegment: 'AssetTranscriptSegment',
|
||||||
Invite: 'Invite',
|
Invite: 'Invite',
|
||||||
MetadataField: 'MetadataField',
|
MetadataField: 'MetadataField',
|
||||||
Notification: 'Notification',
|
Notification: 'Notification',
|
||||||
@@ -481,6 +483,31 @@ export const AssetEmbeddingScalarFieldEnum = {
|
|||||||
export type AssetEmbeddingScalarFieldEnum = (typeof AssetEmbeddingScalarFieldEnum)[keyof typeof AssetEmbeddingScalarFieldEnum]
|
export type AssetEmbeddingScalarFieldEnum = (typeof AssetEmbeddingScalarFieldEnum)[keyof typeof AssetEmbeddingScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
|
export const AssetTranscriptScalarFieldEnum = {
|
||||||
|
id: 'id',
|
||||||
|
assetId: 'assetId',
|
||||||
|
language: 'language',
|
||||||
|
model: 'model',
|
||||||
|
workflowTaskId: 'workflowTaskId',
|
||||||
|
createdAt: 'createdAt',
|
||||||
|
updatedAt: 'updatedAt'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type AssetTranscriptScalarFieldEnum = (typeof AssetTranscriptScalarFieldEnum)[keyof typeof AssetTranscriptScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
|
export const AssetTranscriptSegmentScalarFieldEnum = {
|
||||||
|
id: 'id',
|
||||||
|
transcriptId: 'transcriptId',
|
||||||
|
position: 'position',
|
||||||
|
startMs: 'startMs',
|
||||||
|
endMs: 'endMs',
|
||||||
|
text: 'text'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type AssetTranscriptSegmentScalarFieldEnum = (typeof AssetTranscriptSegmentScalarFieldEnum)[keyof typeof AssetTranscriptSegmentScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
export const InviteScalarFieldEnum = {
|
export const InviteScalarFieldEnum = {
|
||||||
id: 'id',
|
id: 'id',
|
||||||
code: 'code',
|
code: 'code',
|
||||||
|
|||||||
+2
@@ -32,6 +32,8 @@ export type * from './models/AssetComment.ts'
|
|||||||
export type * from './models/AssetCommentAttachment.ts'
|
export type * from './models/AssetCommentAttachment.ts'
|
||||||
export type * from './models/AssetCommentReaction.ts'
|
export type * from './models/AssetCommentReaction.ts'
|
||||||
export type * from './models/AssetEmbedding.ts'
|
export type * from './models/AssetEmbedding.ts'
|
||||||
|
export type * from './models/AssetTranscript.ts'
|
||||||
|
export type * from './models/AssetTranscriptSegment.ts'
|
||||||
export type * from './models/Invite.ts'
|
export type * from './models/Invite.ts'
|
||||||
export type * from './models/MetadataField.ts'
|
export type * from './models/MetadataField.ts'
|
||||||
export type * from './models/Notification.ts'
|
export type * from './models/Notification.ts'
|
||||||
|
|||||||
+346
File diff suppressed because it is too large
Load Diff
+1568
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,10 @@ export function registerWorkflowTrigger(cb: WorkflowTriggerCallback) {
|
|||||||
onWorkflowTaskCreated = cb
|
onWorkflowTaskCreated = cb
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function notifyWorkflowTaskCreated(task: WorkflowTask): Promise<void> {
|
||||||
|
if (task.status === 'pending') await onWorkflowTaskCreated?.(task)
|
||||||
|
}
|
||||||
|
|
||||||
// Global callback for workflow task cancellation (decouples db/core packages from workflow engine)
|
// Global callback for workflow task cancellation (decouples db/core packages from workflow engine)
|
||||||
type WorkflowCancelCallback = (taskId: string) => Promise<void>
|
type WorkflowCancelCallback = (taskId: string) => Promise<void>
|
||||||
let onWorkflowTaskCancelled: WorkflowCancelCallback | null = null
|
let onWorkflowTaskCancelled: WorkflowCancelCallback | null = null
|
||||||
@@ -149,9 +153,7 @@ function createPrismaClient() {
|
|||||||
workflowTask: {
|
workflowTask: {
|
||||||
async create({ args, query }) {
|
async create({ args, query }) {
|
||||||
const result = await query(args)
|
const result = await query(args)
|
||||||
if (onWorkflowTaskCreated && (result as WorkflowTask).status === 'pending') {
|
notifyWorkflowTaskCreated(result as WorkflowTask).catch(console.error)
|
||||||
onWorkflowTaskCreated(result as WorkflowTask).catch(console.error)
|
|
||||||
}
|
|
||||||
return result
|
return result
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,13 +8,7 @@ declare global {
|
|||||||
writes: import('./generated/prisma/internal/prismaNamespace').JsonValue[]
|
writes: import('./generated/prisma/internal/prismaNamespace').JsonValue[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AgentSessionUsage {
|
export type AgentSessionUsage = import('@shumai/dtos').AiUsageMetrics
|
||||||
inputTokens: number
|
|
||||||
outputTokens: number
|
|
||||||
cacheReadTokens: number
|
|
||||||
totalTokens: number
|
|
||||||
cost: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export type PiSessionEntryData = { [key: string]: unknown }
|
export type PiSessionEntryData = { [key: string]: unknown }
|
||||||
|
|
||||||
@@ -383,6 +377,7 @@ declare global {
|
|||||||
imageAnnotation?: ImageAnnotationSpec
|
imageAnnotation?: ImageAnnotationSpec
|
||||||
pdfPages?: PdfPagesSpec
|
pdfPages?: PdfPagesSpec
|
||||||
videoChunks?: VideoChunksSpec
|
videoChunks?: VideoChunksSpec
|
||||||
|
transcription?: { language: string | null; model: string }
|
||||||
/** Render that produced this result, if any (set by the read_asset pipeline). */
|
/** Render that produced this result, if any (set by the read_asset pipeline). */
|
||||||
assetRead?: AssetReadRequest
|
assetRead?: AssetReadRequest
|
||||||
watermark?: WatermarkTaskPayload
|
watermark?: WatermarkTaskPayload
|
||||||
@@ -409,6 +404,7 @@ declare global {
|
|||||||
|
|
||||||
export interface WorkflowTaskOutput {
|
export interface WorkflowTaskOutput {
|
||||||
error?: string
|
error?: string
|
||||||
|
transcription?: { transcriptId: string; language: string } | { noSpeech: true }
|
||||||
recoveryAttempts?: number
|
recoveryAttempts?: number
|
||||||
[key: string]: unknown
|
[key: string]: unknown
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
"main": "./src/index.ts",
|
"main": "./src/index.ts",
|
||||||
"types": "./src/index.ts",
|
"types": "./src/index.ts",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@earendil-works/pi-ai": "1.5.0",
|
"@earendil-works/pi-ai": "1.7.0",
|
||||||
"@earendil-works/pi-durable": "1.5.0",
|
"@earendil-works/pi-durable": "1.7.0",
|
||||||
"zod": "4.5.4"
|
"zod": "4.5.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
import type { EntryRecord } from '@earendil-works/pi-durable'
|
||||||
import { AgentType } from '@shumai/db/enums'
|
import { AgentType } from '@shumai/db/enums'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
import type { AiUsageMetrics } from './ai'
|
||||||
|
|
||||||
export * from './agent-avatar'
|
export * from './agent-avatar'
|
||||||
|
|
||||||
@@ -143,3 +145,8 @@ export const agentSessionSchema = z.object({
|
|||||||
agentId: z.string().optional(),
|
agentId: z.string().optional(),
|
||||||
})
|
})
|
||||||
export type AgentSessionInfo = z.infer<typeof agentSessionSchema>
|
export type AgentSessionInfo = z.infer<typeof agentSessionSchema>
|
||||||
|
|
||||||
|
export interface AgentSessionLogs {
|
||||||
|
entries: EntryRecord[]
|
||||||
|
usage: AiUsageMetrics | null
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export * from './search'
|
|||||||
export * from './share'
|
export * from './share'
|
||||||
export * from './skill'
|
export * from './skill'
|
||||||
export * from './team'
|
export * from './team'
|
||||||
|
export * from './transcript'
|
||||||
export * from './upload'
|
export * from './upload'
|
||||||
export * from './user-metadata'
|
export * from './user-metadata'
|
||||||
export * from './versionStack'
|
export * from './versionStack'
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ export const KNOWN_APIS = [
|
|||||||
'google-vertex',
|
'google-vertex',
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
|
const jsonObjectSchema = z
|
||||||
|
.record(z.string(), z.unknown())
|
||||||
|
.refine((value) => z.json().safeParse(value).success)
|
||||||
|
|
||||||
// We define a serializable version of ProviderConfig for our API and DB
|
// We define a serializable version of ProviderConfig for our API and DB
|
||||||
// as the original ProviderConfig interface includes non-serializable fields (functions)
|
// as the original ProviderConfig interface includes non-serializable fields (functions)
|
||||||
export const providerModelConfigSchema = z.object({
|
export const providerModelConfigSchema = z.object({
|
||||||
@@ -21,6 +25,9 @@ export const providerModelConfigSchema = z.object({
|
|||||||
input: z.array(z.enum(['text', 'image'])).default(['text']),
|
input: z.array(z.enum(['text', 'image'])).default(['text']),
|
||||||
contextWindow: z.number().int().positive().default(128000),
|
contextWindow: z.number().int().positive().default(128000),
|
||||||
maxTokens: z.number().int().positive().default(4096),
|
maxTokens: z.number().int().positive().default(4096),
|
||||||
|
compat: jsonObjectSchema.optional(),
|
||||||
|
thinkingLevelMap: jsonObjectSchema.optional(),
|
||||||
|
headers: z.record(z.string(), z.string()).optional(),
|
||||||
cost: z.object({
|
cost: z.object({
|
||||||
input: z.number().nonnegative().default(0),
|
input: z.number().nonnegative().default(0),
|
||||||
output: z.number().nonnegative().default(0),
|
output: z.number().nonnegative().default(0),
|
||||||
@@ -78,60 +85,58 @@ export const updateModelRequestSchema = z.object({
|
|||||||
|
|
||||||
export type UpdateModelRequest = z.infer<typeof updateModelRequestSchema>
|
export type UpdateModelRequest = z.infer<typeof updateModelRequestSchema>
|
||||||
|
|
||||||
|
export const providerRefreshUnavailableReasonSchema = z.enum([
|
||||||
|
'unsupported_connection',
|
||||||
|
'legacy_kimi_connection',
|
||||||
|
'azure_deployment_required',
|
||||||
|
'catalog_unavailable',
|
||||||
|
])
|
||||||
|
|
||||||
|
export type ProviderRefreshUnavailableReason = z.infer<
|
||||||
|
typeof providerRefreshUnavailableReasonSchema
|
||||||
|
>
|
||||||
|
|
||||||
export const providerResponseSchema = z.object({
|
export const providerResponseSchema = z.object({
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
|
teamId: z.string(),
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
isBuiltin: z.boolean(),
|
isBuiltin: z.boolean(),
|
||||||
config: providerConfigSchema,
|
config: providerConfigSchema,
|
||||||
models: z.array(providerModelSchema).optional(),
|
models: z.array(providerModelSchema).optional(),
|
||||||
modelsCount: z.number().optional(),
|
modelsCount: z.number().optional(),
|
||||||
|
configured: z.boolean(),
|
||||||
|
refreshUnavailableReason: providerRefreshUnavailableReasonSchema.nullable(),
|
||||||
createdAt: z.date(),
|
createdAt: z.date(),
|
||||||
updatedAt: z.date(),
|
updatedAt: z.date(),
|
||||||
})
|
})
|
||||||
|
|
||||||
export type ProviderResponse = z.infer<typeof providerResponseSchema>
|
export type ProviderResponse = z.infer<typeof providerResponseSchema>
|
||||||
|
|
||||||
export const syncModelItemSchema = z.object({
|
export const refreshedProviderModelSchema = createModelRequestSchema.pick({
|
||||||
modelId: z.string().min(1),
|
modelId: true,
|
||||||
name: z.string().default(''),
|
name: true,
|
||||||
config: providerModelConfigSchema,
|
config: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
export type SyncModelItem = z.infer<typeof syncModelItemSchema>
|
export type RefreshedProviderModel = z.infer<typeof refreshedProviderModelSchema>
|
||||||
|
|
||||||
export const syncProviderItemSchema = z.object({
|
export const providerModelRefreshResponseSchema = z.discriminatedUnion('status', [
|
||||||
name: z.string(),
|
z.object({
|
||||||
isNewProvider: z.boolean(),
|
status: z.literal('ready'),
|
||||||
config: providerConfigSchema,
|
providerUpdatedAt: z.iso.datetime(),
|
||||||
models: z.array(syncModelItemSchema),
|
models: z.array(refreshedProviderModelSchema),
|
||||||
|
}),
|
||||||
|
z.object({
|
||||||
|
status: z.literal('unavailable'),
|
||||||
|
reason: providerRefreshUnavailableReasonSchema,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
|
||||||
|
export type ProviderModelRefreshResponse = z.infer<typeof providerModelRefreshResponseSchema>
|
||||||
|
|
||||||
|
export const importProviderModelsRequestSchema = z.object({
|
||||||
|
providerUpdatedAt: z.iso.datetime(),
|
||||||
|
modelIds: z.array(z.string().min(1)).min(1),
|
||||||
})
|
})
|
||||||
|
|
||||||
export type SyncProviderItem = z.infer<typeof syncProviderItemSchema>
|
export type ImportProviderModelsRequest = z.infer<typeof importProviderModelsRequestSchema>
|
||||||
|
|
||||||
export const syncCheckResponseSchema = z.object({
|
|
||||||
providers: z.array(syncProviderItemSchema),
|
|
||||||
totalNewProviders: z.number(),
|
|
||||||
totalNewModels: z.number(),
|
|
||||||
})
|
|
||||||
|
|
||||||
export type SyncCheckResponse = z.infer<typeof syncCheckResponseSchema>
|
|
||||||
|
|
||||||
export const syncApplyRequestSchema = z.object({
|
|
||||||
providers: z.array(
|
|
||||||
z.object({
|
|
||||||
name: z.string(),
|
|
||||||
isNewProvider: z.boolean(),
|
|
||||||
config: providerConfigSchema,
|
|
||||||
models: z.array(syncModelItemSchema),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
})
|
|
||||||
|
|
||||||
export type SyncApplyRequest = z.infer<typeof syncApplyRequestSchema>
|
|
||||||
|
|
||||||
export const syncApplyResponseSchema = z.object({
|
|
||||||
addedProviders: z.number(),
|
|
||||||
addedModels: z.number(),
|
|
||||||
})
|
|
||||||
|
|
||||||
export type SyncApplyResponse = z.infer<typeof syncApplyResponseSchema>
|
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
export const transcriptLanguageCodeSchema = z.string().regex(/^[a-z]{2,3}$/)
|
||||||
|
|
||||||
|
export const generateTranscriptRequestSchema = z.object({
|
||||||
|
language: transcriptLanguageCodeSchema.optional(),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const transcriptLanguagesSchema = z.object({
|
||||||
|
model: z.string().min(1),
|
||||||
|
languages: z.array(z.object({ code: transcriptLanguageCodeSchema, name: z.string().min(1) })),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const transcriptionErrors = {
|
||||||
|
noAudio: 'The video does not contain an audio track',
|
||||||
|
tooLarge: 'Audio exceeds the embedding server upload limit',
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export type GenerateTranscriptResult =
|
||||||
|
| { kind: 'queued' | 'busy'; taskId: string }
|
||||||
|
| { kind: 'existing'; transcriptId: string; language: string }
|
||||||
|
| { kind: 'no_speech' }
|
||||||
|
|
||||||
|
export type TranscriptJobStatus =
|
||||||
|
| { status: 'pending' | 'processing' | 'completed' | 'no_speech'; taskId: string }
|
||||||
|
| { status: 'failed'; taskId: string; reason: keyof typeof transcriptionErrors | 'unknown' }
|
||||||
@@ -4,8 +4,8 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@earendil-works/pi-ai": "1.5.0",
|
"@earendil-works/pi-ai": "1.7.0",
|
||||||
"@earendil-works/pi-durable": "1.5.0",
|
"@earendil-works/pi-durable": "1.7.0",
|
||||||
"@google/genai": "2.28.0",
|
"@google/genai": "2.28.0",
|
||||||
"@shumai/agent": "workspace:*",
|
"@shumai/agent": "workspace:*",
|
||||||
"@shumai/core": "workspace:*",
|
"@shumai/core": "workspace:*",
|
||||||
|
|||||||
@@ -0,0 +1,213 @@
|
|||||||
|
import { execFile } from 'node:child_process'
|
||||||
|
import { mkdtemp, rm } from 'node:fs/promises'
|
||||||
|
import { tmpdir } from 'node:os'
|
||||||
|
import { join } from 'node:path'
|
||||||
|
import { promisify } from 'node:util'
|
||||||
|
import { initAgentWorkflows } from '@shumai/agent'
|
||||||
|
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||||
|
import { transcriptService } from '@shumai/core/src/transcript/transcript'
|
||||||
|
import { prisma } from '@shumai/db'
|
||||||
|
import { setupTestDbHooks } from '@shumai/db/test'
|
||||||
|
import { TaskQueueAgent, workflowService } from '@shumai/workflow-core'
|
||||||
|
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||||
|
|
||||||
|
const execFileAsync = promisify(execFile)
|
||||||
|
const bucket = 'shumai-e2e-transcript'
|
||||||
|
const languages = {
|
||||||
|
model: 'whisper-tiny',
|
||||||
|
languages: [
|
||||||
|
{ code: 'en', name: 'English' },
|
||||||
|
{ code: 'zh', name: 'Chinese' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('Transcribe video workflow', () => {
|
||||||
|
setupTestDbHooks()
|
||||||
|
let directory: string
|
||||||
|
let provider: ReturnType<typeof Bun.serve>
|
||||||
|
let responseStatus = 200
|
||||||
|
let firstRequestBusy = false
|
||||||
|
let uploads: Array<{
|
||||||
|
language: FormDataEntryValue | null
|
||||||
|
length: string | null
|
||||||
|
hasTransferEncoding: boolean
|
||||||
|
model: FormDataEntryValue | null
|
||||||
|
format: FormDataEntryValue | null
|
||||||
|
audio: Buffer
|
||||||
|
}> = []
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
directory = await mkdtemp(join(tmpdir(), 'shumai-e2e-transcripts-'))
|
||||||
|
await execFileAsync('ffmpeg', [
|
||||||
|
'-v',
|
||||||
|
'error',
|
||||||
|
'-f',
|
||||||
|
'lavfi',
|
||||||
|
'-i',
|
||||||
|
'color=size=64x64:duration=2',
|
||||||
|
'-itsoffset',
|
||||||
|
'1',
|
||||||
|
'-f',
|
||||||
|
'lavfi',
|
||||||
|
'-i',
|
||||||
|
'sine=frequency=440:duration=1',
|
||||||
|
'-c:v',
|
||||||
|
'mpeg4',
|
||||||
|
'-c:a',
|
||||||
|
'pcm_s16le',
|
||||||
|
join(directory, 'audio.mkv'),
|
||||||
|
])
|
||||||
|
await execFileAsync('ffmpeg', [
|
||||||
|
'-v',
|
||||||
|
'error',
|
||||||
|
'-f',
|
||||||
|
'lavfi',
|
||||||
|
'-i',
|
||||||
|
'color=size=64x64:duration=1',
|
||||||
|
'-c:v',
|
||||||
|
'mpeg4',
|
||||||
|
join(directory, 'silent.mkv'),
|
||||||
|
])
|
||||||
|
// Replace only the inference server and inspect what the worker sends over HTTP.
|
||||||
|
provider = Bun.serve({
|
||||||
|
hostname: '127.0.0.1',
|
||||||
|
port: 0,
|
||||||
|
async fetch(request) {
|
||||||
|
const path = new URL(request.url).pathname
|
||||||
|
if (path === '/v1/audio/transcriptions/languages') return Response.json(languages)
|
||||||
|
if (path !== '/v1/audio/transcriptions' || request.method !== 'POST')
|
||||||
|
return new Response(null, { status: 404 })
|
||||||
|
|
||||||
|
const form = await request.formData()
|
||||||
|
const file = form.get('file')
|
||||||
|
if (!(file instanceof File)) return new Response(null, { status: 400 })
|
||||||
|
uploads.push({
|
||||||
|
language: form.get('language'),
|
||||||
|
length: request.headers.get('content-length'),
|
||||||
|
hasTransferEncoding: request.headers.has('transfer-encoding'),
|
||||||
|
model: form.get('model'),
|
||||||
|
format: form.get('response_format'),
|
||||||
|
audio: Buffer.from(await file.arrayBuffer()),
|
||||||
|
})
|
||||||
|
if (firstRequestBusy && uploads.length === 1) return new Response(null, { status: 429 })
|
||||||
|
if (responseStatus !== 200) return new Response(null, { status: responseStatus })
|
||||||
|
return Response.json({
|
||||||
|
language: form.get('language') ?? 'en',
|
||||||
|
text: 'Hello',
|
||||||
|
segments: [{ start: 1.012, end: 1.875, text: 'Hello' }],
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
vi.stubEnv('S3_BUCKET', bucket)
|
||||||
|
vi.stubEnv('EMBEDDING_PROVIDER', 'gemma-embedding-2-openai')
|
||||||
|
vi.stubEnv('GEMMA_EMBEDDING_OPENAI_BASE_URL', `${provider.url}v1/embeddings/`)
|
||||||
|
initAgentWorkflows()
|
||||||
|
await workflowService.startWorkers(TaskQueueAgent)
|
||||||
|
})
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
uploads = []
|
||||||
|
responseStatus = 200
|
||||||
|
firstRequestBusy = false
|
||||||
|
})
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await workflowService.shutdownWorkers()
|
||||||
|
workflowService.close()
|
||||||
|
await provider?.stop(true)
|
||||||
|
await s3Service.deletePrefix(bucket, '')
|
||||||
|
if (directory) await rm(directory, { recursive: true, force: true })
|
||||||
|
vi.unstubAllEnvs()
|
||||||
|
})
|
||||||
|
|
||||||
|
async function submitVideo(name: string, language: string | null) {
|
||||||
|
const team = await prisma.team.create({ data: { name: 'Transcription E2E' } })
|
||||||
|
const project = await prisma.project.create({ data: { name: 'Videos', teamId: team.id } })
|
||||||
|
const key = `video/${name}`
|
||||||
|
await s3Service.uploadFileToKey(join(directory, name), key, 'video/x-matroska')
|
||||||
|
const asset = await prisma.asset.create({
|
||||||
|
data: {
|
||||||
|
name,
|
||||||
|
type: 'file',
|
||||||
|
status: 'processed',
|
||||||
|
project: { connect: { id: project.id } },
|
||||||
|
mediaType: 'video/x-matroska',
|
||||||
|
storageKey: { create: { key } },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const result = await transcriptService.generate(asset.id, language)
|
||||||
|
if (result.kind !== 'queued') throw new Error(`Unexpected generation result ${result.kind}`)
|
||||||
|
return {
|
||||||
|
assetId: asset.id,
|
||||||
|
task: await prisma.workflowTask.findUniqueOrThrow({ where: { id: result.taskId } }),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
it('sends a timeline-aligned WAV and saves the detected language and segments after retrying a busy server', async () => {
|
||||||
|
firstRequestBusy = true
|
||||||
|
const { task, assetId } = await submitVideo('audio.mkv', null)
|
||||||
|
await workflowService.executeWait(task, 20_000)
|
||||||
|
|
||||||
|
expect(uploads).toHaveLength(2)
|
||||||
|
const upload = uploads[1]
|
||||||
|
expect(upload).toMatchObject({
|
||||||
|
language: null,
|
||||||
|
hasTransferEncoding: false,
|
||||||
|
model: 'whisper-tiny',
|
||||||
|
format: 'verbose_json',
|
||||||
|
})
|
||||||
|
expect(Number(upload.length)).toBeGreaterThan(upload.audio.length)
|
||||||
|
expect(upload.audio.toString('ascii', 0, 4)).toBe('RIFF')
|
||||||
|
expect(upload.audio.readUInt16LE(22)).toBe(1)
|
||||||
|
expect(upload.audio.readUInt32LE(24)).toBe(16_000)
|
||||||
|
expect(upload.audio.readUInt16LE(34)).toBe(16)
|
||||||
|
const pcm = upload.audio.indexOf('data', 36) + 8
|
||||||
|
expect(upload.audio.subarray(pcm, pcm + 30_000).every((sample) => sample === 0)).toBe(true)
|
||||||
|
expect(upload.audio.subarray(pcm + 34_000).some((sample) => sample !== 0)).toBe(true)
|
||||||
|
|
||||||
|
const transcript = await prisma.assetTranscript.findUniqueOrThrow({
|
||||||
|
where: { assetIdLanguage: { assetId, language: 'en' } },
|
||||||
|
include: { segments: true },
|
||||||
|
})
|
||||||
|
expect(transcript).toMatchObject({
|
||||||
|
model: 'whisper-tiny',
|
||||||
|
workflowTaskId: task.id,
|
||||||
|
segments: [{ position: 0, startMs: 1012, endMs: 1875, text: 'Hello' }],
|
||||||
|
})
|
||||||
|
await vi.waitFor(async () =>
|
||||||
|
expect(await s3Service.listObjects(bucket, 'temp/transcripts/')).toEqual([]),
|
||||||
|
)
|
||||||
|
}, 24_000)
|
||||||
|
|
||||||
|
it('passes an explicit language and treats an upload limit error as permanent', async () => {
|
||||||
|
responseStatus = 413
|
||||||
|
const { task, assetId } = await submitVideo('audio.mkv', 'zh')
|
||||||
|
await expect(workflowService.executeWait(task, 20_000)).rejects.toThrow(
|
||||||
|
'Audio exceeds the embedding server upload limit',
|
||||||
|
)
|
||||||
|
expect(uploads).toHaveLength(1)
|
||||||
|
expect(uploads[0].language).toBe('zh')
|
||||||
|
expect(await transcriptService.getStatus(assetId)).toEqual({
|
||||||
|
taskId: task.id,
|
||||||
|
status: 'failed',
|
||||||
|
reason: 'tooLarge',
|
||||||
|
})
|
||||||
|
expect(await prisma.assetTranscript.count({ where: { assetId } })).toBe(0)
|
||||||
|
await vi.waitFor(async () =>
|
||||||
|
expect(await s3Service.listObjects(bucket, 'temp/transcripts/')).toEqual([]),
|
||||||
|
)
|
||||||
|
}, 24_000)
|
||||||
|
|
||||||
|
it('fails with a clear message when the video has no audio track', async () => {
|
||||||
|
const { task, assetId } = await submitVideo('silent.mkv', null)
|
||||||
|
await expect(workflowService.executeWait(task, 20_000)).rejects.toThrow(
|
||||||
|
'The video does not contain an audio track',
|
||||||
|
)
|
||||||
|
expect(uploads).toHaveLength(0)
|
||||||
|
expect(await transcriptService.getStatus(assetId)).toEqual({
|
||||||
|
taskId: task.id,
|
||||||
|
status: 'failed',
|
||||||
|
reason: 'noAudio',
|
||||||
|
})
|
||||||
|
}, 24_000)
|
||||||
|
})
|
||||||
@@ -34,7 +34,15 @@ import { execFile } from 'child_process'
|
|||||||
import { promisify } from 'util'
|
import { promisify } from 'util'
|
||||||
import { ulid } from 'ulid'
|
import { ulid } from 'ulid'
|
||||||
import { logger } from '@shumai/core/src/logger'
|
import { logger } from '@shumai/core/src/logger'
|
||||||
import { ApplicationFailure, defineStep, getLocalTaskAbortSignal } from '@shumai/workflow-core'
|
import {
|
||||||
|
ApplicationFailure,
|
||||||
|
defineStep,
|
||||||
|
ensureLocalMediaFile,
|
||||||
|
getErrorDetails,
|
||||||
|
getLocalTaskAbortSignal,
|
||||||
|
} from '@shumai/workflow-core'
|
||||||
|
|
||||||
|
export { ensureLocalMediaFile } from '@shumai/workflow-core'
|
||||||
|
|
||||||
const execFileAsync = promisify(execFile)
|
const execFileAsync = promisify(execFile)
|
||||||
|
|
||||||
@@ -42,59 +50,6 @@ function getActivityCancellationSignal(taskId?: string): AbortSignal | undefined
|
|||||||
return getLocalTaskAbortSignal(taskId)
|
return getLocalTaskAbortSignal(taskId)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getErrorDetails(err: unknown): { code?: string; message: string; name?: string } {
|
|
||||||
if (err && typeof err === 'object') {
|
|
||||||
const record = err as Record<string, unknown>
|
|
||||||
return {
|
|
||||||
code: typeof record.code === 'string' ? record.code : undefined,
|
|
||||||
message:
|
|
||||||
typeof record.message === 'string'
|
|
||||||
? record.message
|
|
||||||
: err instanceof Error
|
|
||||||
? err.message
|
|
||||||
: String(err),
|
|
||||||
name: typeof record.name === 'string' ? record.name : undefined,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
message: String(err),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function ensureLocalMediaFile(assetKey: string, filePath: string): Promise<string> {
|
|
||||||
if (fs.existsSync(filePath)) {
|
|
||||||
return filePath
|
|
||||||
}
|
|
||||||
const dir = path.dirname(filePath)
|
|
||||||
if (!fs.existsSync(dir)) {
|
|
||||||
fs.mkdirSync(dir, { recursive: true })
|
|
||||||
}
|
|
||||||
const bucket = process.env.S3_BUCKET || 'shumai'
|
|
||||||
try {
|
|
||||||
await s3Service.downloadToFile(bucket, assetKey, filePath)
|
|
||||||
} catch (err) {
|
|
||||||
const { code, message, name } = getErrorDetails(err)
|
|
||||||
const lowerMsg = message.toLowerCase()
|
|
||||||
const lowerCode = (code || '').toLowerCase()
|
|
||||||
const lowerName = (name || '').toLowerCase()
|
|
||||||
if (
|
|
||||||
lowerCode === 'enoent' ||
|
|
||||||
lowerCode === 'nosuchkey' ||
|
|
||||||
lowerName === 'nosuchkey' ||
|
|
||||||
lowerMsg.includes('enoent') ||
|
|
||||||
lowerMsg.includes('nosuchkey')
|
|
||||||
) {
|
|
||||||
throw ApplicationFailure.create({
|
|
||||||
message: `Failed to download media to local file: ${message}`,
|
|
||||||
nonRetryable: true,
|
|
||||||
cause: err instanceof Error ? err : undefined,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
return filePath
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface GetMediaInfoActivityParams {
|
export interface GetMediaInfoActivityParams {
|
||||||
assetId: string
|
assetId: string
|
||||||
assetKey: string
|
assetKey: string
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { client } from '@/ui/api/client'
|
import { client } from '@/ui/api/client'
|
||||||
|
import { Button } from '@/ui/components/ui/button'
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
@@ -6,18 +7,21 @@ import {
|
|||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from '@/ui/components/ui/dialog'
|
} from '@/ui/components/ui/dialog'
|
||||||
|
import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from '@/ui/components/ui/popover'
|
||||||
import { ScrollArea } from '@/ui/components/ui/scroll-area'
|
import { ScrollArea } from '@/ui/components/ui/scroll-area'
|
||||||
import { Skeleton } from '@/ui/components/ui/skeleton'
|
import { Skeleton } from '@/ui/components/ui/skeleton'
|
||||||
import { formatTimeAgo } from '@/ui/lib/time'
|
import { formatTimeAgo } from '@/ui/lib/time'
|
||||||
import { m } from '@/ui/paraglide/messages.js'
|
import { m } from '@/ui/paraglide/messages.js'
|
||||||
|
import { getLocale } from '@/ui/paraglide/runtime.js'
|
||||||
import type { EntryRecord } from '@earendil-works/pi-durable'
|
import type { EntryRecord } from '@earendil-works/pi-durable'
|
||||||
import { getShumaiMessage, serializeContextToXml } from '@shumai/dtos'
|
import { getShumaiMessage, serializeContextToXml, type AiUsageMetrics } from '@shumai/dtos'
|
||||||
import { useQuery } from '@tanstack/react-query'
|
import { useQuery } from '@tanstack/react-query'
|
||||||
import { Terminal } from 'lucide-react'
|
import { Terminal } from 'lucide-react'
|
||||||
import Markdown from 'react-markdown'
|
import Markdown from 'react-markdown'
|
||||||
|
|
||||||
interface AgentSessionLogsDialogProps {
|
interface AgentSessionLogsDialogProps {
|
||||||
sessionId?: string | null
|
sessionId?: string | null
|
||||||
|
showUsage?: boolean
|
||||||
open: boolean
|
open: boolean
|
||||||
onOpenChange: (open: boolean) => void
|
onOpenChange: (open: boolean) => void
|
||||||
}
|
}
|
||||||
@@ -61,20 +65,85 @@ function EntryLog({ entry }: { entry: EntryRecord }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function SessionUsage({ usage }: { usage: AiUsageMetrics }) {
|
||||||
|
const locale = getLocale()
|
||||||
|
const tokens = new Intl.NumberFormat(locale)
|
||||||
|
const currency = new Intl.NumberFormat(locale, {
|
||||||
|
style: 'currency',
|
||||||
|
currency: 'USD',
|
||||||
|
currencyDisplay: 'narrowSymbol',
|
||||||
|
maximumFractionDigits: 3,
|
||||||
|
})
|
||||||
|
const cost =
|
||||||
|
usage.cost > 0 && usage.cost < 0.001
|
||||||
|
? `<${currency.format(0.001)}`
|
||||||
|
: currency.format(usage.cost)
|
||||||
|
const breakdown = [
|
||||||
|
{ label: m.input_tokens(), count: usage.inputTokens },
|
||||||
|
{ label: m.output_tokens(), count: usage.outputTokens },
|
||||||
|
{ label: m.cache_read_tokens(), count: usage.cacheReadTokens },
|
||||||
|
]
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="flex flex-wrap gap-x-3 gap-y-1 tabular-nums">
|
||||||
|
<span>
|
||||||
|
{tokens.format(usage.totalTokens)} {m.tokens()}
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
{cost} {m.session_usage_estimated_cost()}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<PopoverTrigger asChild>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="ghost"
|
||||||
|
size="xs"
|
||||||
|
className="font-normal text-muted-foreground"
|
||||||
|
>
|
||||||
|
{m.session_usage_breakdown()}
|
||||||
|
</Button>
|
||||||
|
</PopoverTrigger>
|
||||||
|
<PopoverContent
|
||||||
|
side="top"
|
||||||
|
align="end"
|
||||||
|
aria-label={m.session_usage_token_breakdown()}
|
||||||
|
className="w-60 space-y-2 p-3 text-sm"
|
||||||
|
>
|
||||||
|
<p className="font-semibold">{m.session_usage_token_breakdown()}</p>
|
||||||
|
<dl className="space-y-1 tabular-nums">
|
||||||
|
{breakdown.map(({ label, count }) => (
|
||||||
|
<div key={label} className="flex justify-between gap-3">
|
||||||
|
<dt className="text-muted-foreground">{label}</dt>
|
||||||
|
<dd>{tokens.format(count)}</dd>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</dl>
|
||||||
|
<p className="border-t pt-2 text-xs text-muted-foreground">
|
||||||
|
{m.session_usage_cost_explanation()}
|
||||||
|
</p>
|
||||||
|
</PopoverContent>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export function AgentSessionLogsDialog({
|
export function AgentSessionLogsDialog({
|
||||||
sessionId,
|
sessionId,
|
||||||
|
showUsage = false,
|
||||||
open,
|
open,
|
||||||
onOpenChange,
|
onOpenChange,
|
||||||
}: AgentSessionLogsDialogProps) {
|
}: AgentSessionLogsDialogProps) {
|
||||||
const { data: entries, isLoading } = useQuery({
|
const { data: logs, isLoading } = useQuery({
|
||||||
queryKey: ['agent-sessions', sessionId, 'entries'],
|
queryKey: ['agent-sessions', sessionId, 'entries', showUsage],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!sessionId) return []
|
if (!sessionId) return { entries: [], usage: null }
|
||||||
const response = await client.api['agent-sessions'][':sessionId'].entries.$get({
|
const response = await client.api['agent-sessions'][':sessionId'].entries.$get({
|
||||||
param: { sessionId },
|
param: { sessionId },
|
||||||
|
query: showUsage ? { includeUsage: 'true' } : {},
|
||||||
})
|
})
|
||||||
if (!response.ok) throw new Error('Failed to fetch session logs')
|
if (!response.ok) throw new Error('Failed to fetch session logs')
|
||||||
return (await response.json()) as EntryRecord[]
|
const data = await response.json()
|
||||||
|
return Array.isArray(data) ? { entries: data, usage: null } : data
|
||||||
},
|
},
|
||||||
enabled: open && !!sessionId,
|
enabled: open && !!sessionId,
|
||||||
})
|
})
|
||||||
@@ -93,10 +162,29 @@ export function AgentSessionLogsDialog({
|
|||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<Skeleton className="h-32 w-full" />
|
<Skeleton className="h-32 w-full" />
|
||||||
) : (
|
) : (
|
||||||
entries?.map((entry) => <EntryLog key={entry.id} entry={entry} />)
|
logs?.entries.map((entry) => <EntryLog key={entry.id} entry={entry} />)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
|
{showUsage && (
|
||||||
|
<Popover>
|
||||||
|
<PopoverAnchor asChild>
|
||||||
|
<footer
|
||||||
|
aria-label={m.session_usage()}
|
||||||
|
aria-busy={isLoading}
|
||||||
|
className="-mx-6 -mb-6 flex min-h-8 shrink-0 flex-wrap items-center justify-between gap-x-3 border-t bg-muted/30 px-3 py-0.5 text-xs text-muted-foreground"
|
||||||
|
>
|
||||||
|
{isLoading ? (
|
||||||
|
<Skeleton className="h-4 w-44" />
|
||||||
|
) : logs?.usage ? (
|
||||||
|
<SessionUsage usage={logs.usage} />
|
||||||
|
) : (
|
||||||
|
m.session_usage_unavailable()
|
||||||
|
)}
|
||||||
|
</footer>
|
||||||
|
</PopoverAnchor>
|
||||||
|
</Popover>
|
||||||
|
)}
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ export function AgentSessionsDashboard({ teamId }: AgentSessionsDashboardProps)
|
|||||||
|
|
||||||
<AgentSessionLogsDialog
|
<AgentSessionLogsDialog
|
||||||
sessionId={selectedSessionId}
|
sessionId={selectedSessionId}
|
||||||
|
showUsage
|
||||||
open={!!selectedSessionId}
|
open={!!selectedSessionId}
|
||||||
onOpenChange={(open) => {
|
onOpenChange={(open) => {
|
||||||
if (!open) setSelectedSessionId(null)
|
if (!open) setSelectedSessionId(null)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import type { AssetInfo } from '@shumai/dtos'
|
|||||||
describe('FileBrowserContextMenu', () => {
|
describe('FileBrowserContextMenu', () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
cleanup()
|
cleanup()
|
||||||
|
vi.restoreAllMocks()
|
||||||
})
|
})
|
||||||
|
|
||||||
const stackItem: AssetInfo = {
|
const stackItem: AssetInfo = {
|
||||||
@@ -60,6 +61,73 @@ describe('FileBrowserContextMenu', () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
it('opens the supplied URL in a new tab for a read-only member', () => {
|
||||||
|
const url = '/projects/project-123/files/file-123'
|
||||||
|
const open = vi.spyOn(window, 'open').mockReturnValue(null)
|
||||||
|
renderWithMenu(fileItem, { canEdit: false, openInNewTabHref: url })
|
||||||
|
|
||||||
|
fireEvent.contextMenu(screen.getByTestId('context-trigger'))
|
||||||
|
const newTabItem = screen.getByRole('menuitem', { name: 'Open in new tab' })
|
||||||
|
fireEvent.pointerUp(newTabItem, { button: 2, pointerType: 'mouse' })
|
||||||
|
expect(open).not.toHaveBeenCalled()
|
||||||
|
|
||||||
|
fireEvent.click(newTabItem)
|
||||||
|
expect(open).toHaveBeenCalledWith(url, '_blank', 'noopener,noreferrer')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('omits the new-tab action for a multi-item selection', () => {
|
||||||
|
renderWithMenu(fileItem, {
|
||||||
|
files: [fileItem, stackItem],
|
||||||
|
selectedIds: new Set([fileItem.id, stackItem.id]),
|
||||||
|
openInNewTabHref: '/projects/project-123/files/file-123',
|
||||||
|
})
|
||||||
|
|
||||||
|
fireEvent.contextMenu(screen.getByTestId('context-trigger'))
|
||||||
|
|
||||||
|
expect(screen.queryByRole('menuitem', { name: 'Open in new tab' })).toBeNull()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('starts transcription on the displayed video file in a stack', () => {
|
||||||
|
const onGenerateTranscripts = vi.fn()
|
||||||
|
renderWithMenu(
|
||||||
|
{
|
||||||
|
...stackItem,
|
||||||
|
proxyType: 'video',
|
||||||
|
versionStack: {
|
||||||
|
id: stackItem.id,
|
||||||
|
versions: [
|
||||||
|
{ id: 'old', name: 'old.mp4', version: 1, current: false },
|
||||||
|
{ id: 'current', name: 'current.mp4', version: 2, current: true },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ onGenerateTranscripts },
|
||||||
|
)
|
||||||
|
|
||||||
|
fireEvent.contextMenu(screen.getByTestId('context-trigger'))
|
||||||
|
fireEvent.click(screen.getByRole('menuitem', { name: 'Generate Transcripts' }))
|
||||||
|
|
||||||
|
expect(onGenerateTranscripts).toHaveBeenCalledWith('current', 'current.mp4')
|
||||||
|
})
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
{
|
||||||
|
label: 'a read-only member',
|
||||||
|
item: { ...fileItem, proxyType: 'video' as const },
|
||||||
|
canEdit: false,
|
||||||
|
},
|
||||||
|
{ label: 'a non-video asset', item: fileItem, canEdit: true },
|
||||||
|
{
|
||||||
|
label: 'an archived video',
|
||||||
|
item: { ...fileItem, proxyType: 'video' as const, status: 'archived' },
|
||||||
|
canEdit: true,
|
||||||
|
},
|
||||||
|
])('hides the action for $label', ({ item, canEdit }) => {
|
||||||
|
renderWithMenu(item, { canEdit, onGenerateTranscripts: vi.fn() })
|
||||||
|
fireEvent.contextMenu(screen.getByTestId('context-trigger'))
|
||||||
|
expect(screen.queryByRole('menuitem', { name: 'Generate Transcripts' })).toBeNull()
|
||||||
|
})
|
||||||
|
|
||||||
it('renders Manage versions for version_stack item when canEdit is true', () => {
|
it('renders Manage versions for version_stack item when canEdit is true', () => {
|
||||||
const onManageVersions = vi.fn()
|
const onManageVersions = vi.fn()
|
||||||
renderWithMenu(stackItem, { onManageVersions })
|
renderWithMenu(stackItem, { onManageVersions })
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
ArchiveRestore,
|
ArchiveRestore,
|
||||||
Download,
|
Download,
|
||||||
Edit,
|
Edit,
|
||||||
|
ExternalLink,
|
||||||
FolderPlus,
|
FolderPlus,
|
||||||
Trash2,
|
Trash2,
|
||||||
UploadCloud,
|
UploadCloud,
|
||||||
@@ -26,6 +27,7 @@ import {
|
|||||||
Copy,
|
Copy,
|
||||||
Layers,
|
Layers,
|
||||||
ScanSearch,
|
ScanSearch,
|
||||||
|
Captions,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import { CopyContextMenuSub } from './copy-submenu'
|
import { CopyContextMenuSub } from './copy-submenu'
|
||||||
import { isImageItem, type CopyKind } from './copy-options'
|
import { isImageItem, type CopyKind } from './copy-options'
|
||||||
@@ -33,11 +35,13 @@ import { isImageItem, type CopyKind } from './copy-options'
|
|||||||
interface FileBrowserContextMenuProps {
|
interface FileBrowserContextMenuProps {
|
||||||
item: AssetInfo | null
|
item: AssetInfo | null
|
||||||
selectedIds: Set<string>
|
selectedIds: Set<string>
|
||||||
|
openInNewTabHref?: string
|
||||||
onRename: (item: AssetInfo) => void
|
onRename: (item: AssetInfo) => void
|
||||||
onDelete: (items: AssetInfo[]) => void
|
onDelete: (items: AssetInfo[]) => void
|
||||||
onDownload: (items: AssetInfo[]) => void
|
onDownload: (items: AssetInfo[]) => void
|
||||||
onCopy?: (kind: CopyKind, items: AssetInfo[]) => void
|
onCopy?: (kind: CopyKind, items: AssetInfo[]) => void
|
||||||
onFindSimilar?: (item: AssetInfo) => void
|
onFindSimilar?: (item: AssetInfo) => void
|
||||||
|
onGenerateTranscripts?: (assetId: string, name: string) => void
|
||||||
onRestore: (items: AssetInfo[]) => void
|
onRestore: (items: AssetInfo[]) => void
|
||||||
onArchive?: (items: AssetInfo[]) => void
|
onArchive?: (items: AssetInfo[]) => void
|
||||||
onRestoreArchive?: (items: AssetInfo[]) => void
|
onRestoreArchive?: (items: AssetInfo[]) => void
|
||||||
@@ -67,11 +71,13 @@ interface FileBrowserContextMenuProps {
|
|||||||
export function FileBrowserContextMenu({
|
export function FileBrowserContextMenu({
|
||||||
item,
|
item,
|
||||||
selectedIds,
|
selectedIds,
|
||||||
|
openInNewTabHref,
|
||||||
onRename,
|
onRename,
|
||||||
onDelete,
|
onDelete,
|
||||||
onDownload,
|
onDownload,
|
||||||
onCopy,
|
onCopy,
|
||||||
onFindSimilar,
|
onFindSimilar,
|
||||||
|
onGenerateTranscripts,
|
||||||
onRestore,
|
onRestore,
|
||||||
onArchive,
|
onArchive,
|
||||||
onRestoreArchive,
|
onRestoreArchive,
|
||||||
@@ -234,6 +240,12 @@ export function FileBrowserContextMenu({
|
|||||||
</ContextMenuItem>
|
</ContextMenuItem>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const videoVersion =
|
||||||
|
item.type === 'version_stack'
|
||||||
|
? item.versionStack?.versions.find((version) => version.current)
|
||||||
|
: undefined
|
||||||
|
const transcriptAssetId = item.type === 'file' ? item.id : videoVersion?.id
|
||||||
|
|
||||||
const contextMenuContent =
|
const contextMenuContent =
|
||||||
isItemSelected && selectedIds.size > 1 ? (
|
isItemSelected && selectedIds.size > 1 ? (
|
||||||
<ContextMenuContent
|
<ContextMenuContent
|
||||||
@@ -330,6 +342,18 @@ export function FileBrowserContextMenu({
|
|||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{openInNewTabHref && (
|
||||||
|
<ContextMenuItem
|
||||||
|
onPointerUp={(event) => {
|
||||||
|
// Radix can synthesize a click as the right button that opened the menu is released.
|
||||||
|
if (event.button !== 0) event.preventDefault()
|
||||||
|
}}
|
||||||
|
onSelect={() => window.open(openInNewTabHref, '_blank', 'noopener,noreferrer')}
|
||||||
|
>
|
||||||
|
<ExternalLink className="mr-2 h-4 w-4" />
|
||||||
|
<span>{m.open_in_new_tab()}</span>
|
||||||
|
</ContextMenuItem>
|
||||||
|
)}
|
||||||
{canEdit && (
|
{canEdit && (
|
||||||
<ContextMenuItem
|
<ContextMenuItem
|
||||||
onSelect={() => {
|
onSelect={() => {
|
||||||
@@ -345,6 +369,20 @@ export function FileBrowserContextMenu({
|
|||||||
<span>{m.download()}</span>
|
<span>{m.download()}</span>
|
||||||
</ContextMenuItem>
|
</ContextMenuItem>
|
||||||
{findSimilarItem}
|
{findSimilarItem}
|
||||||
|
{canEdit &&
|
||||||
|
onGenerateTranscripts &&
|
||||||
|
transcriptAssetId &&
|
||||||
|
item.status === 'processed' &&
|
||||||
|
item.proxyType === 'video' && (
|
||||||
|
<ContextMenuItem
|
||||||
|
onSelect={() =>
|
||||||
|
onGenerateTranscripts(transcriptAssetId, videoVersion?.name || item.name)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Captions className="mr-2 h-4 w-4" />
|
||||||
|
<span>{m.generate_transcripts()}</span>
|
||||||
|
</ContextMenuItem>
|
||||||
|
)}
|
||||||
<CopyContextMenuSub
|
<CopyContextMenuSub
|
||||||
items={itemsToModify}
|
items={itemsToModify}
|
||||||
context={{
|
context={{
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ import { FilePreviewDialog } from '../file-preview-dialog'
|
|||||||
import { ShareLinkCreatedDialog } from '../share-link-created-dialog'
|
import { ShareLinkCreatedDialog } from '../share-link-created-dialog'
|
||||||
import { FileBrowserContentSkeleton } from '../loading-skeletons'
|
import { FileBrowserContentSkeleton } from '../loading-skeletons'
|
||||||
import { FileBrowserContextMenu } from './context-menu'
|
import { FileBrowserContextMenu } from './context-menu'
|
||||||
|
import { GenerateTranscriptsDialog } from './generate-transcripts-dialog'
|
||||||
|
import { getItemInAppUrl } from './copy-options'
|
||||||
import { FindSimilarDialog } from '../search/find-similar-dialog'
|
import { FindSimilarDialog } from '../search/find-similar-dialog'
|
||||||
import { useSemanticSearchEnabled } from '../search/use-semantic-search-enabled'
|
import { useSemanticSearchEnabled } from '../search/use-semantic-search-enabled'
|
||||||
|
|
||||||
@@ -62,6 +64,7 @@ import { FileBrowserToolbar } from './toolbar'
|
|||||||
import { useFileActions } from './use-file-actions'
|
import { useFileActions } from './use-file-actions'
|
||||||
import { useBatchFileStatus } from '@/ui/hooks/use-batch-file-status'
|
import { useBatchFileStatus } from '@/ui/hooks/use-batch-file-status'
|
||||||
import { useArchiveConfig } from '@/ui/hooks/use-archive-config'
|
import { useArchiveConfig } from '@/ui/hooks/use-archive-config'
|
||||||
|
import { useServerFeatures } from '@/ui/hooks/use-server-features'
|
||||||
import { ArchiveConfirmDialog } from '../archive-confirm-dialog'
|
import { ArchiveConfirmDialog } from '../archive-confirm-dialog'
|
||||||
|
|
||||||
interface FileBrowserProps {
|
interface FileBrowserProps {
|
||||||
@@ -160,6 +163,8 @@ export function FileBrowser({
|
|||||||
}: FileBrowserProps) {
|
}: FileBrowserProps) {
|
||||||
const [contextMenuItem, setContextMenuItem] = useState<AssetInfo | null>(null)
|
const [contextMenuItem, setContextMenuItem] = useState<AssetInfo | null>(null)
|
||||||
const [similarImage, setSimilarImage] = useState<AssetInfo | null>(null)
|
const [similarImage, setSimilarImage] = useState<AssetInfo | null>(null)
|
||||||
|
const [transcriptVideo, setTranscriptVideo] = useState<{ id: string; name: string } | null>(null)
|
||||||
|
const transcriptionEnabled = useServerFeatures().data?.transcriptionEnabled
|
||||||
const semanticSearchEnabled = useSemanticSearchEnabled(
|
const semanticSearchEnabled = useSemanticSearchEnabled(
|
||||||
teamId,
|
teamId,
|
||||||
Boolean(
|
Boolean(
|
||||||
@@ -1111,6 +1116,9 @@ export function FileBrowser({
|
|||||||
<FileBrowserContextMenu
|
<FileBrowserContextMenu
|
||||||
item={contextMenuItem}
|
item={contextMenuItem}
|
||||||
selectedIds={selectedIds}
|
selectedIds={selectedIds}
|
||||||
|
openInNewTabHref={
|
||||||
|
contextMenuItem ? getItemInAppUrl(contextMenuItem, '', projectId) : undefined
|
||||||
|
}
|
||||||
folders={folders}
|
folders={folders}
|
||||||
files={displayedFiles}
|
files={displayedFiles}
|
||||||
onRename={handleRename}
|
onRename={handleRename}
|
||||||
@@ -1118,6 +1126,11 @@ export function FileBrowser({
|
|||||||
onDownload={handleDownload}
|
onDownload={handleDownload}
|
||||||
onCopy={handleCopy}
|
onCopy={handleCopy}
|
||||||
onFindSimilar={semanticSearchEnabled && rootFolderId ? setSimilarImage : undefined}
|
onFindSimilar={semanticSearchEnabled && rootFolderId ? setSimilarImage : undefined}
|
||||||
|
onGenerateTranscripts={
|
||||||
|
transcriptionEnabled && !isShareView && !isPublic
|
||||||
|
? (id, name) => setTranscriptVideo({ id, name })
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
onNewFolder={handleNewFolder}
|
onNewFolder={handleNewFolder}
|
||||||
onUploadFile={handleUploadFilesClick}
|
onUploadFile={handleUploadFilesClick}
|
||||||
onUploadFolder={handleUploadFolderClick}
|
onUploadFolder={handleUploadFolderClick}
|
||||||
@@ -1178,6 +1191,15 @@ export function FileBrowser({
|
|||||||
)}
|
)}
|
||||||
{renderContent()}
|
{renderContent()}
|
||||||
|
|
||||||
|
{transcriptVideo && (
|
||||||
|
<GenerateTranscriptsDialog
|
||||||
|
key={transcriptVideo.id}
|
||||||
|
assetId={transcriptVideo.id}
|
||||||
|
name={transcriptVideo.name}
|
||||||
|
onClose={() => setTranscriptVideo(null)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
{semanticSearchEnabled && similarImage && rootFolderId && (
|
{semanticSearchEnabled && similarImage && rootFolderId && (
|
||||||
<FindSimilarDialog
|
<FindSimilarDialog
|
||||||
image={similarImage}
|
image={similarImage}
|
||||||
|
|||||||
@@ -0,0 +1,202 @@
|
|||||||
|
import { useRef, useState } from 'react'
|
||||||
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||||
|
import type { TranscriptJobStatus } from '@shumai/dtos'
|
||||||
|
import { toast } from 'sonner'
|
||||||
|
import { client } from '@/ui/api/client'
|
||||||
|
import { m } from '@/ui/paraglide/messages.js'
|
||||||
|
import { Button } from '@/ui/components/ui/button'
|
||||||
|
import {
|
||||||
|
Combobox,
|
||||||
|
ComboboxContent,
|
||||||
|
ComboboxEmpty,
|
||||||
|
ComboboxInput,
|
||||||
|
ComboboxItem,
|
||||||
|
ComboboxList,
|
||||||
|
} from '@/ui/components/ui/combobox'
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from '@/ui/components/ui/dialog'
|
||||||
|
|
||||||
|
function isActive(status?: TranscriptJobStatus | null) {
|
||||||
|
return status?.status === 'pending' || status?.status === 'processing'
|
||||||
|
}
|
||||||
|
|
||||||
|
function statusMessage(job: TranscriptJobStatus) {
|
||||||
|
switch (job.status) {
|
||||||
|
case 'pending':
|
||||||
|
return m.transcript_queued()
|
||||||
|
case 'processing':
|
||||||
|
return m.transcript_generating()
|
||||||
|
case 'completed':
|
||||||
|
return m.transcript_completed()
|
||||||
|
case 'no_speech':
|
||||||
|
return m.transcript_no_speech()
|
||||||
|
case 'failed':
|
||||||
|
if (job.reason === 'tooLarge') return m.transcript_audio_too_large()
|
||||||
|
if (job.reason === 'noAudio') return m.transcript_no_audio()
|
||||||
|
return m.transcript_failed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function GenerateTranscriptsDialog({
|
||||||
|
assetId,
|
||||||
|
name,
|
||||||
|
onClose,
|
||||||
|
}: {
|
||||||
|
assetId: string
|
||||||
|
name: string
|
||||||
|
onClose: () => void
|
||||||
|
}) {
|
||||||
|
const dialogRef = useRef<HTMLDivElement>(null)
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
const [language, setLanguage] = useState('')
|
||||||
|
const param = { fileId: assetId }
|
||||||
|
const statusKey = ['transcription-status', assetId]
|
||||||
|
|
||||||
|
const languages = useQuery({
|
||||||
|
queryKey: ['transcription-languages'],
|
||||||
|
queryFn: async () => {
|
||||||
|
const response = await client.api.transcription.languages.$get()
|
||||||
|
if (!response.ok) throw new Error(m.transcript_languages_unavailable())
|
||||||
|
return await response.json()
|
||||||
|
},
|
||||||
|
staleTime: 5 * 60 * 1000,
|
||||||
|
retry: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
const job = useQuery({
|
||||||
|
queryKey: statusKey,
|
||||||
|
queryFn: async () => {
|
||||||
|
const response = await client.api.files[':fileId']['transcription-status'].$get({ param })
|
||||||
|
if (!response.ok) throw new Error(m.transcript_status_unavailable())
|
||||||
|
return await response.json()
|
||||||
|
},
|
||||||
|
refetchInterval: (query) => (isActive(query.state.data) ? 2_000 : false),
|
||||||
|
})
|
||||||
|
|
||||||
|
const generate = useMutation({
|
||||||
|
mutationFn: async () => {
|
||||||
|
const response = await client.api.files[':fileId'].transcripts.$post({
|
||||||
|
param,
|
||||||
|
json: { language: language || undefined },
|
||||||
|
})
|
||||||
|
if (!response.ok) throw new Error(m.transcript_submit_failed())
|
||||||
|
return await response.json()
|
||||||
|
},
|
||||||
|
onSuccess: (result) => {
|
||||||
|
if (result.kind === 'existing' || result.kind === 'no_speech') {
|
||||||
|
toast.info(
|
||||||
|
result.kind === 'existing' ? m.transcript_already_exists() : m.transcript_no_speech(),
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
queryClient.setQueryData<TranscriptJobStatus>(statusKey, {
|
||||||
|
status: 'pending',
|
||||||
|
taskId: result.taskId,
|
||||||
|
})
|
||||||
|
void queryClient.invalidateQueries({ queryKey: statusKey })
|
||||||
|
if (result.kind === 'queued') toast.success(m.transcript_queued())
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const choices = [
|
||||||
|
{ code: '', name: m.transcript_language_auto() },
|
||||||
|
...(languages.data?.languages ?? []),
|
||||||
|
]
|
||||||
|
const busy = generate.isPending || isActive(job.data)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
open
|
||||||
|
onOpenChange={(open) => {
|
||||||
|
if (!open) onClose()
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DialogContent ref={dialogRef} showCloseButton={false}>
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>{m.generate_transcripts()}</DialogTitle>
|
||||||
|
<DialogDescription>{name}</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
|
||||||
|
<Combobox
|
||||||
|
items={choices}
|
||||||
|
value={choices.find((choice) => choice.code === language)}
|
||||||
|
onValueChange={(choice) => setLanguage(choice?.code ?? '')}
|
||||||
|
itemToStringLabel={(choice) => choice.name}
|
||||||
|
isItemEqualToValue={(choice, value) => choice.code === value.code}
|
||||||
|
disabled={busy || languages.isPending || languages.isError}
|
||||||
|
>
|
||||||
|
<label htmlFor="transcript-language" className="text-sm font-medium">
|
||||||
|
{m.language()}
|
||||||
|
</label>
|
||||||
|
<ComboboxInput id="transcript-language" />
|
||||||
|
<ComboboxContent container={dialogRef}>
|
||||||
|
<ComboboxEmpty>{m.transcript_no_languages_found()}</ComboboxEmpty>
|
||||||
|
<ComboboxList>
|
||||||
|
{(choice) => (
|
||||||
|
<ComboboxItem key={choice.code} value={choice}>
|
||||||
|
{choice.name}
|
||||||
|
</ComboboxItem>
|
||||||
|
)}
|
||||||
|
</ComboboxList>
|
||||||
|
</ComboboxContent>
|
||||||
|
</Combobox>
|
||||||
|
|
||||||
|
{languages.isPending && (
|
||||||
|
<p role="status" className="text-sm text-muted-foreground">
|
||||||
|
{m.loading()}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{languages.isError && (
|
||||||
|
<div className="flex items-center justify-between gap-2">
|
||||||
|
<p role="alert" className="text-sm text-destructive">
|
||||||
|
{m.transcript_languages_unavailable()}
|
||||||
|
</p>
|
||||||
|
<Button variant="outline" size="sm" onClick={() => languages.refetch()}>
|
||||||
|
{m.retry()}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{generate.isError && (
|
||||||
|
<p role="alert" className="text-sm text-destructive">
|
||||||
|
{generate.error.message}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{job.isError && (
|
||||||
|
<p role="alert" className="text-sm text-destructive">
|
||||||
|
{m.transcript_status_unavailable()}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{job.data && (
|
||||||
|
<p
|
||||||
|
role="status"
|
||||||
|
className={
|
||||||
|
job.data.status === 'failed'
|
||||||
|
? 'text-sm text-destructive'
|
||||||
|
: 'text-sm text-muted-foreground'
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{statusMessage(job.data)}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<DialogFooter>
|
||||||
|
<Button variant="outline" onClick={onClose}>
|
||||||
|
{m.close()}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
disabled={busy || !languages.data || job.isPending}
|
||||||
|
onClick={() => generate.mutate()}
|
||||||
|
>
|
||||||
|
{m.generate()}
|
||||||
|
</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -38,30 +38,32 @@ import {
|
|||||||
SelectValue,
|
SelectValue,
|
||||||
} from '@/ui/components/ui/select'
|
} from '@/ui/components/ui/select'
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/ui/components/ui/tabs'
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/ui/components/ui/tabs'
|
||||||
import { providerConfigSchema, KNOWN_APIS, type SyncCheckResponse } from '@shumai/dtos'
|
import {
|
||||||
|
providerConfigSchema,
|
||||||
|
KNOWN_APIS,
|
||||||
|
type ProviderRefreshUnavailableReason,
|
||||||
|
type RefreshedProviderModel,
|
||||||
|
} from '@shumai/dtos'
|
||||||
import { useForm } from '@tanstack/react-form'
|
import { useForm } from '@tanstack/react-form'
|
||||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||||
import { InferResponseType } from 'hono/client'
|
import { InferResponseType } from 'hono/client'
|
||||||
import {
|
import {
|
||||||
ChevronRight,
|
|
||||||
Cpu,
|
Cpu,
|
||||||
Globe,
|
|
||||||
Info,
|
|
||||||
Loader2,
|
Loader2,
|
||||||
Maximize2,
|
|
||||||
MoreVertical,
|
MoreVertical,
|
||||||
|
Pencil,
|
||||||
Plus,
|
Plus,
|
||||||
RefreshCw,
|
RefreshCw,
|
||||||
Search,
|
Search,
|
||||||
Trash2,
|
Trash2,
|
||||||
Zap,
|
Zap,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import { useEffect, useMemo, useState } from 'react'
|
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import { toast } from 'sonner'
|
import { toast } from 'sonner'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
import { m } from '@/ui/paraglide/messages.js'
|
import { m } from '@/ui/paraglide/messages.js'
|
||||||
import { ModelFormDialog, ModelFormValues } from './ModelFormDialog'
|
import { ModelFormDialog, ModelFormValues } from './ModelFormDialog'
|
||||||
import { SyncProvidersDialog } from './SyncProvidersDialog'
|
import { RefreshProviderModelsDialog } from './RefreshProviderModelsDialog'
|
||||||
|
|
||||||
const API_PROTOCOL_LABELS: Record<(typeof KNOWN_APIS)[number], string> = {
|
const API_PROTOCOL_LABELS: Record<(typeof KNOWN_APIS)[number], string> = {
|
||||||
'openai-completions': 'OpenAI Completions',
|
'openai-completions': 'OpenAI Completions',
|
||||||
@@ -87,38 +89,63 @@ interface ProvidersSettingsProps {
|
|||||||
teamId: string
|
teamId: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function refreshUnavailableText(reason: ProviderRefreshUnavailableReason) {
|
||||||
|
switch (reason) {
|
||||||
|
case 'legacy_kimi_connection':
|
||||||
|
return m.provider_refresh_legacy_kimi_connection()
|
||||||
|
case 'azure_deployment_required':
|
||||||
|
return m.provider_refresh_azure_deployment_required()
|
||||||
|
case 'catalog_unavailable':
|
||||||
|
return m.provider_refresh_catalog_unavailable()
|
||||||
|
case 'unsupported_connection':
|
||||||
|
return m.provider_refresh_unsupported_connection()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function ProvidersSettings({ teamId }: ProvidersSettingsProps) {
|
export function ProvidersSettings({ teamId }: ProvidersSettingsProps) {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const [editingProviderId, setEditingProviderId] = useState<string | null>(null)
|
const [editing, setEditing] = useState<{
|
||||||
|
providerId: string
|
||||||
|
trigger: HTMLButtonElement
|
||||||
|
} | null>(null)
|
||||||
const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false)
|
const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false)
|
||||||
const [searchQuery, setSearchQuery] = useState('')
|
const [searchQuery, setSearchQuery] = useState('')
|
||||||
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false)
|
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false)
|
||||||
const [providerToDelete, setProviderToDelete] = useState<Provider | null>(null)
|
const [providerToDelete, setProviderToDelete] = useState<Provider | null>(null)
|
||||||
const [isSyncDialogOpen, setIsSyncDialogOpen] = useState(false)
|
const [preview, setPreview] = useState<{
|
||||||
const [syncData, setSyncData] = useState<SyncCheckResponse | null>(null)
|
provider: Provider
|
||||||
|
providerUpdatedAt: string
|
||||||
|
models: RefreshedProviderModel[]
|
||||||
|
trigger: HTMLButtonElement
|
||||||
|
} | null>(null)
|
||||||
|
|
||||||
// Check updates mutation
|
const refreshMutation = useMutation({
|
||||||
const syncCheckMutation = useMutation({
|
mutationFn: async ({ provider }: { provider: Provider; trigger: HTMLButtonElement }) => {
|
||||||
mutationFn: async () => {
|
const res = await client.api.teams[':teamId'].providers[':providerId'].models.refresh.$post({
|
||||||
const res = await client.api.teams[':teamId'].providers['sync-check'].$post({
|
param: { teamId, providerId: provider.id },
|
||||||
param: { teamId },
|
|
||||||
})
|
})
|
||||||
if (!res.ok) {
|
if (!res.ok) throw new Error(m.provider_refresh_failed())
|
||||||
const err = await res.json().catch(() => ({ message: 'Failed to check updates' }))
|
return res.json()
|
||||||
throw new Error((err as { message?: string }).message || 'Failed to check updates')
|
|
||||||
}
|
|
||||||
return await res.json()
|
|
||||||
},
|
},
|
||||||
onSuccess: (data) => {
|
onSuccess: (data, { provider, trigger }) => {
|
||||||
if (data.totalNewModels === 0 && data.totalNewProviders === 0) {
|
if (data.status === 'unavailable') {
|
||||||
toast.info(m.sync_providers_up_to_date())
|
toast.info(refreshUnavailableText(data.reason))
|
||||||
|
void queryClient.invalidateQueries({ queryKey: ['teams', teamId, 'providers'] })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setSyncData(data)
|
if (data.models.length === 0) {
|
||||||
setIsSyncDialogOpen(true)
|
toast.info(m.provider_refresh_no_new_models({ name: provider.name }))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setPreview({
|
||||||
|
provider,
|
||||||
|
providerUpdatedAt: data.providerUpdatedAt,
|
||||||
|
models: data.models,
|
||||||
|
trigger,
|
||||||
|
})
|
||||||
},
|
},
|
||||||
onError: (error: Error) => {
|
onError: () => {
|
||||||
toast.error(error.message)
|
toast.error(m.provider_refresh_failed())
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -135,17 +162,18 @@ export function ProvidersSettings({ teamId }: ProvidersSettingsProps) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const editingProvider = useMemo(
|
const editingProvider = useMemo(
|
||||||
() => providers?.find((p) => p.id === editingProviderId) || null,
|
() => providers?.find((p) => p.id === editing?.providerId) || null,
|
||||||
[providers, editingProviderId],
|
[providers, editing?.providerId],
|
||||||
)
|
)
|
||||||
|
|
||||||
const existingProviderNames = useMemo(() => providers?.map((p) => p.name) || [], [providers])
|
const existingProviderNames = useMemo(() => providers?.map((p) => p.name) || [], [providers])
|
||||||
|
|
||||||
const filteredProviders = useMemo(() => {
|
const filteredProviders = useMemo(() => {
|
||||||
if (!providers) return []
|
if (!providers) return []
|
||||||
if (!searchQuery.trim()) return providers
|
const query = searchQuery.trim().toLowerCase()
|
||||||
const query = searchQuery.toLowerCase()
|
return providers
|
||||||
return providers.filter((p) => p.name.toLowerCase().includes(query))
|
.filter((p) => p.name.toLowerCase().includes(query))
|
||||||
|
.sort((a, b) => Number(b.configured) - Number(a.configured))
|
||||||
}, [providers, searchQuery])
|
}, [providers, searchQuery])
|
||||||
|
|
||||||
// Create Mutation
|
// Create Mutation
|
||||||
@@ -187,7 +215,7 @@ export function ProvidersSettings({ teamId }: ProvidersSettingsProps) {
|
|||||||
},
|
},
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['teams', teamId, 'providers'] })
|
queryClient.invalidateQueries({ queryKey: ['teams', teamId, 'providers'] })
|
||||||
setEditingProviderId(null)
|
setEditing(null)
|
||||||
setIsDeleteDialogOpen(false)
|
setIsDeleteDialogOpen(false)
|
||||||
setProviderToDelete(null)
|
setProviderToDelete(null)
|
||||||
toast.success(m.provider_deleted_successfully())
|
toast.success(m.provider_deleted_successfully())
|
||||||
@@ -207,120 +235,40 @@ export function ProvidersSettings({ teamId }: ProvidersSettingsProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full flex flex-col space-y-0">
|
<div className="h-full flex flex-col space-y-0">
|
||||||
<div className="flex-none space-y-4 pb-4">
|
<div className="flex flex-none flex-wrap items-center gap-3 pb-4">
|
||||||
<div className="flex items-center justify-between">
|
<div className="relative min-w-0 flex-[1_1_10rem] px-0.5">
|
||||||
<h3 className="text-lg font-semibold text-foreground flex items-center gap-2">
|
|
||||||
<Cpu className="w-5 h-5 text-primary" />
|
|
||||||
{m.configured_ai_providers()}
|
|
||||||
</h3>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
onClick={() => syncCheckMutation.mutate()}
|
|
||||||
disabled={syncCheckMutation.isPending}
|
|
||||||
className="gap-2"
|
|
||||||
>
|
|
||||||
{syncCheckMutation.isPending ? (
|
|
||||||
<>
|
|
||||||
<Loader2 className="w-4 h-4 animate-spin" />
|
|
||||||
{m.sync_providers_checking()}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<RefreshCw className="w-4 h-4" />
|
|
||||||
{m.sync_providers()}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
onClick={() => setIsCreateDialogOpen(true)}
|
|
||||||
className="bg-primary hover:bg-primary/90 text-primary-foreground gap-2"
|
|
||||||
>
|
|
||||||
<Plus className="w-4 h-4" />
|
|
||||||
{m.add_provider()}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="relative px-0.5">
|
|
||||||
<Search className="absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground" />
|
<Search className="absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground" />
|
||||||
<Input
|
<Input
|
||||||
|
aria-label={m.search_providers_placeholder()}
|
||||||
placeholder={m.search_providers_placeholder()}
|
placeholder={m.search_providers_placeholder()}
|
||||||
value={searchQuery}
|
value={searchQuery}
|
||||||
onChange={(e) => setSearchQuery(e.target.value)}
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
className="pl-10 bg-card border-border focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-0"
|
className="pl-10 bg-card border-border focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-0"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<Button onClick={() => setIsCreateDialogOpen(true)} className="gap-2">
|
||||||
|
<Plus className="size-4" aria-hidden="true" />
|
||||||
|
{m.add_provider()}
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ScrollArea className="flex-1 min-h-0">
|
<ScrollArea className="flex-1 min-h-0">
|
||||||
<div className="pr-4 py-2 grid grid-cols-1 gap-4">
|
<div className="pr-4 py-2 grid grid-cols-1 gap-4">
|
||||||
{filteredProviders.map((provider) => (
|
{filteredProviders.map((provider) => (
|
||||||
<Card
|
<ProviderCard
|
||||||
key={provider.id}
|
key={provider.id}
|
||||||
className="group cursor-pointer hover:border-primary/50 transition-all hover:shadow-md overflow-hidden"
|
provider={provider}
|
||||||
onClick={() => setEditingProviderId(provider.id)}
|
isRefreshing={
|
||||||
>
|
refreshMutation.isPending && refreshMutation.variables?.provider.id === provider.id
|
||||||
<CardContent className="p-5 flex items-center justify-between gap-4">
|
}
|
||||||
<div className="flex items-center gap-4 min-w-0 flex-1">
|
refreshInProgress={refreshMutation.isPending}
|
||||||
<div className="flex-none p-3 bg-muted rounded-xl group-hover:bg-primary/10 transition-colors">
|
onEdit={(trigger) => setEditing({ providerId: provider.id, trigger })}
|
||||||
<Globe className="w-6 h-6 text-muted-foreground group-hover:text-primary" />
|
onRefresh={(trigger) => refreshMutation.mutate({ provider, trigger })}
|
||||||
</div>
|
onDelete={() => {
|
||||||
<div className="min-w-0 flex-1">
|
setProviderToDelete(provider)
|
||||||
<div className="flex items-center gap-2">
|
setIsDeleteDialogOpen(true)
|
||||||
<span className="font-bold text-foreground truncate">{provider.name}</span>
|
}}
|
||||||
</div>
|
/>
|
||||||
<div className="flex flex-wrap items-center gap-x-3 gap-y-1.5 text-xs text-muted-foreground mt-1">
|
|
||||||
<span className="flex items-center gap-1 flex-none">
|
|
||||||
<Zap className="w-3 h-3" />
|
|
||||||
{provider.config.api}
|
|
||||||
</span>
|
|
||||||
{provider.config.baseUrl && (
|
|
||||||
<span className="flex items-center gap-1 min-w-0">
|
|
||||||
<span className="h-1 w-1 rounded-full bg-muted-foreground/30 flex-none" />
|
|
||||||
<Info className="w-3 h-3 flex-none" />
|
|
||||||
<span className="truncate max-w-[200px] md:max-w-[300px]">
|
|
||||||
{provider.config.baseUrl}
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
<span className="flex items-center gap-1 flex-none">
|
|
||||||
<span className="h-1 w-1 rounded-full bg-muted-foreground/30 flex-none" />
|
|
||||||
<Maximize2 className="w-3 h-3" />
|
|
||||||
{m.n_models_count({ count: provider.modelsCount })}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex items-center gap-1">
|
|
||||||
<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()
|
|
||||||
setProviderToDelete(provider)
|
|
||||||
setIsDeleteDialogOpen(true)
|
|
||||||
}}
|
|
||||||
className="text-destructive focus:text-destructive gap-2 cursor-pointer"
|
|
||||||
>
|
|
||||||
<Trash2 className="w-4 h-4" /> {m.delete()}
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
<ChevronRight className="flex-none w-5 h-5 text-muted-foreground/50 group-hover:text-primary transition-colors" />
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{providers?.length === 0 && (
|
{providers?.length === 0 && (
|
||||||
@@ -359,10 +307,11 @@ export function ProvidersSettings({ teamId }: ProvidersSettingsProps) {
|
|||||||
existingProviderNames={existingProviderNames}
|
existingProviderNames={existingProviderNames}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{editingProvider && (
|
{editing && editingProvider && (
|
||||||
<EditProviderDialog
|
<EditProviderDialog
|
||||||
isOpen={!!editingProvider}
|
isOpen
|
||||||
onClose={() => setEditingProviderId(null)}
|
onClose={() => setEditing(null)}
|
||||||
|
onCloseAutoFocus={() => editing.trigger.focus()}
|
||||||
provider={editingProvider}
|
provider={editingProvider}
|
||||||
teamId={teamId}
|
teamId={teamId}
|
||||||
existingProviderNames={existingProviderNames}
|
existingProviderNames={existingProviderNames}
|
||||||
@@ -400,19 +349,129 @@ export function ProvidersSettings({ teamId }: ProvidersSettingsProps) {
|
|||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
</AlertDialog>
|
</AlertDialog>
|
||||||
|
|
||||||
<SyncProvidersDialog
|
{preview && (
|
||||||
isOpen={isSyncDialogOpen}
|
<RefreshProviderModelsDialog
|
||||||
onClose={() => setIsSyncDialogOpen(false)}
|
teamId={teamId}
|
||||||
teamId={teamId}
|
providerId={preview.provider.id}
|
||||||
syncData={syncData}
|
providerUpdatedAt={preview.providerUpdatedAt}
|
||||||
onSuccess={() => {
|
providerName={preview.provider.name}
|
||||||
queryClient.invalidateQueries({ queryKey: ['teams', teamId, 'providers'] })
|
models={preview.models}
|
||||||
}}
|
onClose={() => setPreview(null)}
|
||||||
/>
|
onCloseAutoFocus={() => preview.trigger.focus()}
|
||||||
|
onImported={() => {
|
||||||
|
void queryClient.invalidateQueries({ queryKey: ['teams', teamId, 'providers'] })
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ProviderCard({
|
||||||
|
provider,
|
||||||
|
isRefreshing,
|
||||||
|
refreshInProgress,
|
||||||
|
onEdit,
|
||||||
|
onRefresh,
|
||||||
|
onDelete,
|
||||||
|
}: {
|
||||||
|
provider: Provider
|
||||||
|
isRefreshing: boolean
|
||||||
|
refreshInProgress: boolean
|
||||||
|
onEdit: (button: HTMLButtonElement) => void
|
||||||
|
onRefresh: (button: HTMLButtonElement) => void
|
||||||
|
onDelete: () => void
|
||||||
|
}) {
|
||||||
|
const menuTrigger = useRef<HTMLButtonElement>(null)
|
||||||
|
const unavailable = provider.refreshUnavailableReason
|
||||||
|
const reasonId = `provider-refresh-reason-${provider.id}`
|
||||||
|
const displayUrl = provider.config.baseUrl?.replace(/^https?:\/\//, '')
|
||||||
|
return (
|
||||||
|
<Card className="relative gap-0 rounded-xl py-0 shadow-none transition-colors hover:border-primary/35">
|
||||||
|
<CardContent className="grid grid-cols-[minmax(0,1fr)_auto] items-start gap-3 p-3.5">
|
||||||
|
<div className="min-w-0">
|
||||||
|
<div className="flex flex-wrap items-center gap-x-2 gap-y-1">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={(event) => onEdit(event.currentTarget)}
|
||||||
|
aria-label={m.edit_item({ name: provider.name })}
|
||||||
|
aria-haspopup="dialog"
|
||||||
|
className="max-w-full cursor-pointer text-start font-semibold wrap-anywhere text-foreground after:absolute after:inset-0 after:rounded-xl focus-visible:outline-none focus-visible:after:ring-2 focus-visible:after:ring-ring"
|
||||||
|
>
|
||||||
|
{provider.name}
|
||||||
|
</button>
|
||||||
|
{provider.configured && (
|
||||||
|
<Badge variant="secondary" className="px-2 text-xs font-medium">
|
||||||
|
{m.provider_configured_badge()}
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground">
|
||||||
|
<span>{API_PROTOCOL_LABELS[provider.config.api] ?? provider.config.api}</span>
|
||||||
|
<span aria-hidden="true">·</span>
|
||||||
|
<span>{m.n_models_count({ count: provider.modelsCount })}</span>
|
||||||
|
</div>
|
||||||
|
{unavailable ? (
|
||||||
|
<p id={reasonId} className="mt-1 text-xs text-muted-foreground">
|
||||||
|
{refreshUnavailableText(unavailable)}
|
||||||
|
</p>
|
||||||
|
) : displayUrl ? (
|
||||||
|
<p className="mt-1 wrap-anywhere text-xs text-muted-foreground" dir="ltr">
|
||||||
|
{displayUrl}
|
||||||
|
</p>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
<div className="relative z-10 flex items-center gap-1">
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
size="icon"
|
||||||
|
variant="ghost"
|
||||||
|
className="size-11 text-muted-foreground hover:text-foreground sm:size-9"
|
||||||
|
disabled={unavailable !== null || refreshInProgress}
|
||||||
|
aria-label={m.provider_refresh_action({ name: provider.name })}
|
||||||
|
aria-describedby={unavailable ? reasonId : undefined}
|
||||||
|
aria-busy={isRefreshing}
|
||||||
|
title={isRefreshing ? m.provider_refresh_loading() : m.provider_refresh_models()}
|
||||||
|
onClick={(event) => onRefresh(event.currentTarget)}
|
||||||
|
>
|
||||||
|
{isRefreshing ? (
|
||||||
|
<Loader2 aria-hidden="true" className="size-4 motion-safe:animate-spin" />
|
||||||
|
) : (
|
||||||
|
<RefreshCw aria-hidden="true" className="size-4" />
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
<DropdownMenu modal={false}>
|
||||||
|
<DropdownMenuTrigger asChild>
|
||||||
|
<Button
|
||||||
|
ref={menuTrigger}
|
||||||
|
type="button"
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
aria-label={m.provider_options({ name: provider.name })}
|
||||||
|
className="size-11 text-muted-foreground hover:text-foreground sm:size-9"
|
||||||
|
>
|
||||||
|
<MoreVertical aria-hidden="true" className="size-4" />
|
||||||
|
</Button>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent align="end" className="w-32 data-[state=closed]:hidden">
|
||||||
|
<DropdownMenuItem
|
||||||
|
onSelect={() => {
|
||||||
|
if (menuTrigger.current) onEdit(menuTrigger.current)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Pencil aria-hidden="true" className="size-4" /> {m.edit()}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onSelect={onDelete} variant="destructive">
|
||||||
|
<Trash2 aria-hidden="true" className="size-4" /> {m.delete()}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Create Provider Dialog
|
// Create Provider Dialog
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -779,6 +838,7 @@ function CreateProviderDialog({
|
|||||||
interface EditProviderDialogProps {
|
interface EditProviderDialogProps {
|
||||||
isOpen: boolean
|
isOpen: boolean
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
|
onCloseAutoFocus: () => void
|
||||||
provider: Provider
|
provider: Provider
|
||||||
teamId: string
|
teamId: string
|
||||||
existingProviderNames: string[]
|
existingProviderNames: string[]
|
||||||
@@ -787,6 +847,7 @@ interface EditProviderDialogProps {
|
|||||||
function EditProviderDialog({
|
function EditProviderDialog({
|
||||||
isOpen,
|
isOpen,
|
||||||
onClose,
|
onClose,
|
||||||
|
onCloseAutoFocus,
|
||||||
provider,
|
provider,
|
||||||
teamId,
|
teamId,
|
||||||
existingProviderNames,
|
existingProviderNames,
|
||||||
@@ -961,7 +1022,13 @@ function EditProviderDialog({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={isOpen} onOpenChange={onClose}>
|
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||||
<DialogContent className="sm:max-w-3xl h-[88vh] flex flex-col p-0 overflow-hidden">
|
<DialogContent
|
||||||
|
className="sm:max-w-3xl h-[88vh] flex flex-col p-0 overflow-hidden"
|
||||||
|
onCloseAutoFocus={(event) => {
|
||||||
|
event.preventDefault()
|
||||||
|
onCloseAutoFocus()
|
||||||
|
}}
|
||||||
|
>
|
||||||
<DialogHeader className="p-6 pb-2 shrink-0">
|
<DialogHeader className="p-6 pb-2 shrink-0">
|
||||||
<DialogTitle className="text-xl">{m.edit_item({ name: provider.name })}</DialogTitle>
|
<DialogTitle className="text-xl">{m.edit_item({ name: provider.name })}</DialogTitle>
|
||||||
<DialogDescription>{m.configure_provider_description()}</DialogDescription>
|
<DialogDescription>{m.configure_provider_description()}</DialogDescription>
|
||||||
|
|||||||
@@ -0,0 +1,107 @@
|
|||||||
|
// @vitest-environment happy-dom
|
||||||
|
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
|
||||||
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||||
|
import type { RefreshedProviderModel } from '@shumai/dtos'
|
||||||
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||||
|
import { RefreshProviderModelsDialog } from './RefreshProviderModelsDialog'
|
||||||
|
|
||||||
|
const { importModels } = vi.hoisted(() => ({ importModels: vi.fn() }))
|
||||||
|
|
||||||
|
vi.mock('@/ui/api/client', () => ({
|
||||||
|
client: {
|
||||||
|
api: {
|
||||||
|
teams: {
|
||||||
|
':teamId': {
|
||||||
|
providers: { ':providerId': { models: { import: { $post: importModels } } } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
|
||||||
|
const models = Array.from({ length: 6 }, (_, index): RefreshedProviderModel => ({
|
||||||
|
modelId: `model-${index + 1}`,
|
||||||
|
name: `Model ${index + 1}`,
|
||||||
|
config: {
|
||||||
|
api: 'openai-responses',
|
||||||
|
reasoning: false,
|
||||||
|
input: ['text'],
|
||||||
|
contextWindow: 128000,
|
||||||
|
maxTokens: 4096,
|
||||||
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
|
||||||
|
function renderDialog() {
|
||||||
|
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
||||||
|
const onClose = vi.fn()
|
||||||
|
const onImported = vi.fn()
|
||||||
|
render(
|
||||||
|
<QueryClientProvider client={queryClient}>
|
||||||
|
<RefreshProviderModelsDialog
|
||||||
|
teamId="team-1"
|
||||||
|
providerId="provider-1"
|
||||||
|
providerUpdatedAt="2026-11-29T09:15:00.000Z"
|
||||||
|
providerName="OpenAI"
|
||||||
|
models={models}
|
||||||
|
onClose={onClose}
|
||||||
|
onCloseAutoFocus={vi.fn()}
|
||||||
|
onImported={onImported}
|
||||||
|
/>
|
||||||
|
</QueryClientProvider>,
|
||||||
|
)
|
||||||
|
return { onClose, onImported }
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('RefreshProviderModelsDialog', () => {
|
||||||
|
afterEach(() => {
|
||||||
|
cleanup()
|
||||||
|
importModels.mockReset()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('opens a single-provider preview with selectable models and an empty selection', () => {
|
||||||
|
renderDialog()
|
||||||
|
expect(screen.getByRole('heading', { name: 'New models for OpenAI' })).toBeTruthy()
|
||||||
|
expect(screen.getByText('Select the models you want to add.')).toBeTruthy()
|
||||||
|
expect(screen.getAllByRole('checkbox')).toHaveLength(models.length)
|
||||||
|
expect(screen.getByRole('button', { name: 'Add selected' }).hasAttribute('disabled')).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('filters models and selects or deselects the visible results', () => {
|
||||||
|
renderDialog()
|
||||||
|
const search = screen.getByRole('textbox')
|
||||||
|
fireEvent.change(search, { target: { value: 'model-2' } })
|
||||||
|
expect(screen.queryByText('Model 1')).toBeNull()
|
||||||
|
expect(screen.getAllByRole('checkbox')).toHaveLength(1)
|
||||||
|
|
||||||
|
fireEvent.click(screen.getByRole('button', { name: 'Select visible' }))
|
||||||
|
expect(screen.getByRole('checkbox').getAttribute('aria-checked')).toBe('true')
|
||||||
|
expect(screen.getByRole('button', { name: 'Add selected (1)' })).toBeTruthy()
|
||||||
|
fireEvent.click(screen.getByRole('button', { name: 'Deselect visible' }))
|
||||||
|
expect(screen.getByRole('checkbox').getAttribute('aria-checked')).toBe('false')
|
||||||
|
expect(screen.getByRole('button', { name: 'Add selected' }).hasAttribute('disabled')).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('imports only the selected models into the previewed provider', async () => {
|
||||||
|
importModels.mockResolvedValueOnce(Response.json({ addedModels: 1 }))
|
||||||
|
const { onClose, onImported } = renderDialog()
|
||||||
|
fireEvent.click(screen.getAllByRole('checkbox')[1])
|
||||||
|
fireEvent.click(screen.getByRole('button', { name: 'Add selected (1)' }))
|
||||||
|
|
||||||
|
await waitFor(() => expect(onClose).toHaveBeenCalledOnce())
|
||||||
|
expect(onImported).toHaveBeenCalledOnce()
|
||||||
|
expect(importModels).toHaveBeenCalledWith({
|
||||||
|
param: { teamId: 'team-1', providerId: 'provider-1' },
|
||||||
|
json: { providerUpdatedAt: '2026-11-29T09:15:00.000Z', modelIds: ['model-2'] },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('shows an actionable error when the preview becomes stale', async () => {
|
||||||
|
importModels.mockResolvedValueOnce(new Response(null, { status: 409 }))
|
||||||
|
const { onImported } = renderDialog()
|
||||||
|
fireEvent.click(screen.getAllByRole('checkbox')[0])
|
||||||
|
fireEvent.click(screen.getByRole('button', { name: 'Add selected (1)' }))
|
||||||
|
expect((await screen.findByRole('alert')).textContent).toContain('Refresh models again.')
|
||||||
|
expect(onImported).not.toHaveBeenCalled()
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,187 @@
|
|||||||
|
import { useState } from 'react'
|
||||||
|
import { useMutation } from '@tanstack/react-query'
|
||||||
|
import { Loader2 } from 'lucide-react'
|
||||||
|
import { toast } from 'sonner'
|
||||||
|
import type { RefreshedProviderModel } from '@shumai/dtos'
|
||||||
|
import { client } from '@/ui/api/client'
|
||||||
|
import { Badge } from '@/ui/components/ui/badge'
|
||||||
|
import { Button } from '@/ui/components/ui/button'
|
||||||
|
import { Checkbox } from '@/ui/components/ui/checkbox'
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from '@/ui/components/ui/dialog'
|
||||||
|
import { Input } from '@/ui/components/ui/input'
|
||||||
|
import { ScrollArea } from '@/ui/components/ui/scroll-area'
|
||||||
|
import { m } from '@/ui/paraglide/messages.js'
|
||||||
|
|
||||||
|
interface RefreshProviderModelsDialogProps {
|
||||||
|
teamId: string
|
||||||
|
providerId: string
|
||||||
|
providerUpdatedAt: string
|
||||||
|
providerName: string
|
||||||
|
models: RefreshedProviderModel[]
|
||||||
|
onClose: () => void
|
||||||
|
onCloseAutoFocus: () => void
|
||||||
|
onImported: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
export function RefreshProviderModelsDialog({
|
||||||
|
teamId,
|
||||||
|
providerId,
|
||||||
|
providerUpdatedAt,
|
||||||
|
providerName,
|
||||||
|
models,
|
||||||
|
onClose,
|
||||||
|
onCloseAutoFocus,
|
||||||
|
onImported,
|
||||||
|
}: RefreshProviderModelsDialogProps) {
|
||||||
|
const [selectedIds, setSelectedIds] = useState(() => new Set<string>())
|
||||||
|
const [search, setSearch] = useState('')
|
||||||
|
const query = search.trim().toLowerCase()
|
||||||
|
const filteredModels = models.filter(
|
||||||
|
({ name, modelId }) =>
|
||||||
|
name.toLowerCase().includes(query) || modelId.toLowerCase().includes(query),
|
||||||
|
)
|
||||||
|
const allVisibleSelected =
|
||||||
|
filteredModels.length > 0 && filteredModels.every(({ modelId }) => selectedIds.has(modelId))
|
||||||
|
|
||||||
|
const importMutation = useMutation({
|
||||||
|
mutationFn: async () => {
|
||||||
|
const res = await client.api.teams[':teamId'].providers[':providerId'].models.import.$post({
|
||||||
|
param: { teamId, providerId },
|
||||||
|
json: { providerUpdatedAt, modelIds: [...selectedIds] },
|
||||||
|
})
|
||||||
|
if (res.status === 409) throw new Error(m.provider_refresh_stale())
|
||||||
|
if (!res.ok) throw new Error(m.provider_refresh_import_failed())
|
||||||
|
return res.json()
|
||||||
|
},
|
||||||
|
onSuccess: ({ addedModels }) => {
|
||||||
|
if (addedModels > 0) {
|
||||||
|
toast.success(m.provider_refresh_imported({ count: addedModels, name: providerName }))
|
||||||
|
} else {
|
||||||
|
toast.info(m.provider_refresh_no_new_models({ name: providerName }))
|
||||||
|
}
|
||||||
|
onImported()
|
||||||
|
onClose()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
function selectModels(modelIds: string[], selected: boolean) {
|
||||||
|
setSelectedIds((previous) => {
|
||||||
|
const next = new Set(previous)
|
||||||
|
for (const modelId of modelIds) {
|
||||||
|
if (selected) next.add(modelId)
|
||||||
|
else next.delete(modelId)
|
||||||
|
}
|
||||||
|
return next
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog open onOpenChange={(open) => !open && !importMutation.isPending && onClose()}>
|
||||||
|
<DialogContent
|
||||||
|
className="sm:max-w-lg"
|
||||||
|
showCloseButton={!importMutation.isPending}
|
||||||
|
onCloseAutoFocus={(event) => {
|
||||||
|
event.preventDefault()
|
||||||
|
onCloseAutoFocus()
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DialogHeader className="pr-6">
|
||||||
|
<DialogTitle>{m.provider_refresh_dialog_title({ name: providerName })}</DialogTitle>
|
||||||
|
<DialogDescription>{m.provider_refresh_dialog_description()}</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
{models.length > 5 && (
|
||||||
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
|
<Input
|
||||||
|
className="min-w-36 flex-1"
|
||||||
|
aria-label={m.search_models_placeholder()}
|
||||||
|
placeholder={m.search_models_placeholder()}
|
||||||
|
value={search}
|
||||||
|
onChange={(event) => setSearch(event.target.value)}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
disabled={filteredModels.length === 0 || importMutation.isPending}
|
||||||
|
onClick={() =>
|
||||||
|
selectModels(
|
||||||
|
filteredModels.map(({ modelId }) => modelId),
|
||||||
|
!allVisibleSelected,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{allVisibleSelected
|
||||||
|
? m.provider_refresh_deselect_visible()
|
||||||
|
: m.provider_refresh_select_visible()}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<ScrollArea className="[&>[data-slot=scroll-area-viewport]]:max-h-[min(24rem,45dvh)]">
|
||||||
|
<ul className="divide-y divide-border pr-3">
|
||||||
|
{filteredModels.map(({ name, modelId, config }) => (
|
||||||
|
<li key={modelId}>
|
||||||
|
<label className="flex min-h-11 cursor-pointer items-center gap-3 rounded-sm px-1 py-2">
|
||||||
|
<Checkbox
|
||||||
|
checked={selectedIds.has(modelId)}
|
||||||
|
disabled={importMutation.isPending}
|
||||||
|
onCheckedChange={(checked) => selectModels([modelId], checked === true)}
|
||||||
|
/>
|
||||||
|
<span className="min-w-0 flex-1 wrap-anywhere text-sm font-medium">
|
||||||
|
{name}
|
||||||
|
{name !== modelId && (
|
||||||
|
<span className="block text-xs font-normal text-muted-foreground">
|
||||||
|
{modelId}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
{config.reasoning && (
|
||||||
|
<Badge variant="secondary" className="font-normal">
|
||||||
|
{m.reasoning_support()}
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
</label>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
{filteredModels.length === 0 && (
|
||||||
|
<p className="py-3 text-sm text-muted-foreground">{m.no_matches_found()}</p>
|
||||||
|
)}
|
||||||
|
</ScrollArea>
|
||||||
|
{importMutation.error && (
|
||||||
|
<p role="alert" className="text-sm text-destructive">
|
||||||
|
{importMutation.error.message}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
<DialogFooter>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
disabled={importMutation.isPending}
|
||||||
|
onClick={onClose}
|
||||||
|
>
|
||||||
|
{m.cancel()}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
disabled={selectedIds.size === 0 || importMutation.isPending}
|
||||||
|
onClick={() => importMutation.mutate()}
|
||||||
|
>
|
||||||
|
{importMutation.isPending && (
|
||||||
|
<Loader2 aria-hidden="true" className="size-4 motion-safe:animate-spin" />
|
||||||
|
)}
|
||||||
|
{selectedIds.size
|
||||||
|
? m.provider_refresh_add_selection({ count: selectedIds.size })
|
||||||
|
: m.provider_refresh_add_selected()}
|
||||||
|
</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,275 +0,0 @@
|
|||||||
// @vitest-environment happy-dom
|
|
||||||
import { cleanup, render, screen, fireEvent } from '@testing-library/react'
|
|
||||||
import React from 'react'
|
|
||||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
||||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
||||||
import { SyncProvidersDialog } from './SyncProvidersDialog'
|
|
||||||
import type { SyncCheckResponse } from '@shumai/dtos'
|
|
||||||
|
|
||||||
describe('SyncProvidersDialog', () => {
|
|
||||||
afterEach(() => {
|
|
||||||
cleanup()
|
|
||||||
})
|
|
||||||
|
|
||||||
const mockSyncData: SyncCheckResponse = {
|
|
||||||
totalNewProviders: 1,
|
|
||||||
totalNewModels: 3,
|
|
||||||
providers: [
|
|
||||||
{
|
|
||||||
name: 'test-new-provider',
|
|
||||||
isNewProvider: true,
|
|
||||||
config: { api: 'openai-responses', apiKey: 'NEW_KEY' },
|
|
||||||
models: [
|
|
||||||
{
|
|
||||||
modelId: 'm-new-1',
|
|
||||||
name: 'New Model 1',
|
|
||||||
config: {
|
|
||||||
api: 'openai-responses',
|
|
||||||
reasoning: true,
|
|
||||||
input: ['text'],
|
|
||||||
contextWindow: 128000,
|
|
||||||
maxTokens: 4096,
|
|
||||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
modelId: 'm-new-2',
|
|
||||||
name: 'New Model 2',
|
|
||||||
config: {
|
|
||||||
api: 'openai-responses',
|
|
||||||
reasoning: false,
|
|
||||||
input: ['text'],
|
|
||||||
contextWindow: 64000,
|
|
||||||
maxTokens: 2048,
|
|
||||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'test-existing-provider',
|
|
||||||
isNewProvider: false,
|
|
||||||
config: { api: 'anthropic-messages', apiKey: 'EXISTING_KEY' },
|
|
||||||
models: [
|
|
||||||
{
|
|
||||||
modelId: 'm-existing-add-1',
|
|
||||||
name: 'Existing Provider New Model 1',
|
|
||||||
config: {
|
|
||||||
api: 'anthropic-messages',
|
|
||||||
reasoning: false,
|
|
||||||
input: ['text'],
|
|
||||||
contextWindow: 200000,
|
|
||||||
maxTokens: 8192,
|
|
||||||
cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderDialog(props?: Partial<React.ComponentProps<typeof SyncProvidersDialog>>) {
|
|
||||||
const queryClient = new QueryClient({
|
|
||||||
defaultOptions: { queries: { retry: false } },
|
|
||||||
})
|
|
||||||
|
|
||||||
return render(
|
|
||||||
<QueryClientProvider client={queryClient}>
|
|
||||||
<SyncProvidersDialog
|
|
||||||
isOpen={true}
|
|
||||||
onClose={vi.fn()}
|
|
||||||
teamId="team-1"
|
|
||||||
syncData={mockSyncData}
|
|
||||||
onSuccess={vi.fn()}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
</QueryClientProvider>,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
it('renders the dialog with description, providers and models pre-selected by default', () => {
|
|
||||||
renderDialog()
|
|
||||||
|
|
||||||
// Title and description
|
|
||||||
expect(screen.getByRole('heading', { name: /sync providers & models/i })).toBeDefined()
|
|
||||||
expect(
|
|
||||||
screen.getAllByText(
|
|
||||||
/existing providers, custom endpoints, api keys, and model configurations will never be deleted or modified/i,
|
|
||||||
).length,
|
|
||||||
).toBeGreaterThan(0)
|
|
||||||
|
|
||||||
// Check provider names
|
|
||||||
expect(screen.getByText('test-new-provider')).toBeDefined()
|
|
||||||
expect(screen.getByText('test-existing-provider')).toBeDefined()
|
|
||||||
|
|
||||||
// Badges
|
|
||||||
expect(screen.getByText(/^new provider$/i)).toBeDefined()
|
|
||||||
expect(screen.getByText(/^existing provider$/i)).toBeDefined()
|
|
||||||
|
|
||||||
// Check that both new and existing providers have checkboxes
|
|
||||||
const newProviderCheckbox = document.getElementById('provider-check-test-new-provider')
|
|
||||||
expect(newProviderCheckbox).toBeDefined()
|
|
||||||
expect(newProviderCheckbox?.getAttribute('data-state')).toBe('checked')
|
|
||||||
|
|
||||||
const existingProviderCheckbox = document.getElementById(
|
|
||||||
'provider-check-test-existing-provider',
|
|
||||||
)
|
|
||||||
expect(existingProviderCheckbox).toBeDefined()
|
|
||||||
expect(existingProviderCheckbox?.getAttribute('data-state')).toBe('checked')
|
|
||||||
|
|
||||||
// Model checkboxes are checked by default
|
|
||||||
const mNew1Check = document.getElementById('model-check-test-new-provider-m-new-1')
|
|
||||||
expect(mNew1Check).toBeDefined()
|
|
||||||
expect(mNew1Check?.getAttribute('data-state')).toBe('checked')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('toggles all models for an existing provider when its checkbox is clicked', () => {
|
|
||||||
renderDialog()
|
|
||||||
|
|
||||||
const existingProviderCheckbox = document.getElementById(
|
|
||||||
'provider-check-test-existing-provider',
|
|
||||||
)!
|
|
||||||
const existingModelCheck = document.getElementById(
|
|
||||||
'model-check-test-existing-provider-m-existing-add-1',
|
|
||||||
)!
|
|
||||||
|
|
||||||
expect(existingModelCheck.getAttribute('data-state')).toBe('checked')
|
|
||||||
|
|
||||||
// Click to uncheck all
|
|
||||||
fireEvent.click(existingProviderCheckbox)
|
|
||||||
expect(existingModelCheck.getAttribute('data-state')).toBe('unchecked')
|
|
||||||
expect(existingProviderCheckbox.getAttribute('data-state')).toBe('unchecked')
|
|
||||||
|
|
||||||
// Click to check all
|
|
||||||
fireEvent.click(existingProviderCheckbox)
|
|
||||||
expect(existingModelCheck.getAttribute('data-state')).toBe('checked')
|
|
||||||
expect(existingProviderCheckbox.getAttribute('data-state')).toBe('checked')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('supports select all and deselect all buttons', () => {
|
|
||||||
renderDialog()
|
|
||||||
|
|
||||||
const deselectAllBtn = screen.getByRole('button', { name: /^deselect all$/i })
|
|
||||||
fireEvent.click(deselectAllBtn)
|
|
||||||
|
|
||||||
const mNew1Check = document.getElementById('model-check-test-new-provider-m-new-1')
|
|
||||||
expect(mNew1Check?.getAttribute('data-state')).toBe('unchecked')
|
|
||||||
|
|
||||||
const selectAllBtn = screen.getByRole('button', { name: /^select all$/i })
|
|
||||||
fireEvent.click(selectAllBtn)
|
|
||||||
expect(mNew1Check?.getAttribute('data-state')).toBe('checked')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('unchecks new provider when all its models are unchecked', () => {
|
|
||||||
renderDialog()
|
|
||||||
|
|
||||||
const mNew1Check = document.getElementById('model-check-test-new-provider-m-new-1')!
|
|
||||||
const mNew2Check = document.getElementById('model-check-test-new-provider-m-new-2')!
|
|
||||||
const newProviderCheckbox = document.getElementById('provider-check-test-new-provider')!
|
|
||||||
|
|
||||||
// Uncheck both models
|
|
||||||
fireEvent.click(mNew1Check)
|
|
||||||
expect(newProviderCheckbox.getAttribute('data-state')).toBe('indeterminate')
|
|
||||||
|
|
||||||
fireEvent.click(mNew2Check)
|
|
||||||
expect(newProviderCheckbox.getAttribute('data-state')).toBe('unchecked')
|
|
||||||
|
|
||||||
// Re-check one model -> provider should automatically check
|
|
||||||
fireEvent.click(mNew1Check)
|
|
||||||
expect(newProviderCheckbox.getAttribute('data-state')).not.toBe('unchecked')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('filters models when user types in search input', () => {
|
|
||||||
renderDialog()
|
|
||||||
|
|
||||||
const searchInput = screen.getByPlaceholderText(/filter new providers or models/i)
|
|
||||||
fireEvent.change(searchInput, { target: { value: 'm-existing-add-1' } })
|
|
||||||
|
|
||||||
// Only existing provider model should be visible
|
|
||||||
expect(screen.queryByText('m-new-1')).toBeNull()
|
|
||||||
expect(screen.getByText('Existing Provider New Model 1')).toBeDefined()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('supports expand all and collapse all buttons', () => {
|
|
||||||
renderDialog()
|
|
||||||
|
|
||||||
// Models should be visible initially (all expanded)
|
|
||||||
expect(document.getElementById('model-check-test-new-provider-m-new-1')).toBeDefined()
|
|
||||||
|
|
||||||
// Click Collapse All
|
|
||||||
const collapseAllBtn = screen.getByRole('button', { name: /^collapse all$/i })
|
|
||||||
fireEvent.click(collapseAllBtn)
|
|
||||||
|
|
||||||
// Child models should be collapsed (not in DOM)
|
|
||||||
expect(document.getElementById('model-check-test-new-provider-m-new-1')).toBeNull()
|
|
||||||
|
|
||||||
// Click Expand All
|
|
||||||
const expandAllBtn = screen.getByRole('button', { name: /^expand all$/i })
|
|
||||||
fireEvent.click(expandAllBtn)
|
|
||||||
|
|
||||||
// Child models should be visible again
|
|
||||||
expect(document.getElementById('model-check-test-new-provider-m-new-1')).toBeDefined()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('updates selection and expansion state when syncData prop changes while mounted', () => {
|
|
||||||
const { rerender } = renderDialog()
|
|
||||||
|
|
||||||
// Initially, test-new-provider is present
|
|
||||||
expect(screen.getByText('test-new-provider')).toBeDefined()
|
|
||||||
|
|
||||||
// Deselect all models to change internal state
|
|
||||||
const deselectAllBtn = screen.getByRole('button', { name: /^deselect all$/i })
|
|
||||||
fireEvent.click(deselectAllBtn)
|
|
||||||
const mNew1Check = document.getElementById('model-check-test-new-provider-m-new-1')
|
|
||||||
expect(mNew1Check?.getAttribute('data-state')).toBe('unchecked')
|
|
||||||
|
|
||||||
// Now supply new syncData prop with different providers and models
|
|
||||||
const updatedSyncData: SyncCheckResponse = {
|
|
||||||
totalNewProviders: 1,
|
|
||||||
totalNewModels: 1,
|
|
||||||
providers: [
|
|
||||||
{
|
|
||||||
name: 'updated-provider',
|
|
||||||
isNewProvider: true,
|
|
||||||
config: { api: 'openai-responses' },
|
|
||||||
models: [
|
|
||||||
{
|
|
||||||
modelId: 'm-updated-1',
|
|
||||||
name: 'Updated Model 1',
|
|
||||||
config: {
|
|
||||||
api: 'openai-responses',
|
|
||||||
reasoning: false,
|
|
||||||
input: ['text'],
|
|
||||||
contextWindow: 32000,
|
|
||||||
maxTokens: 1024,
|
|
||||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
const queryClient = new QueryClient({
|
|
||||||
defaultOptions: { queries: { retry: false } },
|
|
||||||
})
|
|
||||||
|
|
||||||
rerender(
|
|
||||||
<QueryClientProvider client={queryClient}>
|
|
||||||
<SyncProvidersDialog
|
|
||||||
isOpen={true}
|
|
||||||
onClose={vi.fn()}
|
|
||||||
teamId="team-1"
|
|
||||||
syncData={updatedSyncData}
|
|
||||||
onSuccess={vi.fn()}
|
|
||||||
/>
|
|
||||||
</QueryClientProvider>,
|
|
||||||
)
|
|
||||||
|
|
||||||
// New provider should be rendered, expanded by default, and model should be pre-selected
|
|
||||||
expect(screen.getByText('updated-provider')).toBeDefined()
|
|
||||||
const updatedModelCheck = document.getElementById('model-check-updated-provider-m-updated-1')
|
|
||||||
expect(updatedModelCheck).toBeDefined()
|
|
||||||
expect(updatedModelCheck?.getAttribute('data-state')).toBe('checked')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -1,474 +0,0 @@
|
|||||||
import { useState, useMemo, useEffect } from 'react'
|
|
||||||
import {
|
|
||||||
Dialog,
|
|
||||||
DialogContent,
|
|
||||||
DialogDescription,
|
|
||||||
DialogFooter,
|
|
||||||
DialogHeader,
|
|
||||||
DialogTitle,
|
|
||||||
} from '@/ui/components/ui/dialog'
|
|
||||||
import { Button } from '@/ui/components/ui/button'
|
|
||||||
import { Checkbox } from '@/ui/components/ui/checkbox'
|
|
||||||
import { Badge } from '@/ui/components/ui/badge'
|
|
||||||
import { Input } from '@/ui/components/ui/input'
|
|
||||||
import { ScrollArea } from '@/ui/components/ui/scroll-area'
|
|
||||||
import { ChevronDown, ChevronRight, Cpu, Loader2, Search, Sparkles } from 'lucide-react'
|
|
||||||
import { useMutation } from '@tanstack/react-query'
|
|
||||||
import { client } from '@/ui/api/client'
|
|
||||||
import { toast } from 'sonner'
|
|
||||||
import { m } from '@/ui/paraglide/messages.js'
|
|
||||||
import type { SyncCheckResponse, SyncApplyRequest } from '@shumai/dtos'
|
|
||||||
|
|
||||||
interface SyncProvidersDialogProps {
|
|
||||||
isOpen: boolean
|
|
||||||
onClose: () => void
|
|
||||||
teamId: string
|
|
||||||
syncData: SyncCheckResponse | null
|
|
||||||
onSuccess: () => void
|
|
||||||
}
|
|
||||||
|
|
||||||
export function SyncProvidersDialog({
|
|
||||||
isOpen,
|
|
||||||
onClose,
|
|
||||||
teamId,
|
|
||||||
syncData,
|
|
||||||
onSuccess,
|
|
||||||
}: SyncProvidersDialogProps) {
|
|
||||||
const [filterQuery, setFilterQuery] = useState('')
|
|
||||||
const [expandedProviders, setExpandedProviders] = useState<Set<string>>(() => {
|
|
||||||
return new Set(syncData?.providers.map((p) => p.name) || [])
|
|
||||||
})
|
|
||||||
|
|
||||||
// Pre-selected by default (opt-out)
|
|
||||||
const [selectedModels, setSelectedModels] = useState<Set<string>>(() => {
|
|
||||||
const set = new Set<string>()
|
|
||||||
syncData?.providers.forEach((p) => {
|
|
||||||
p.models.forEach((mItem) => {
|
|
||||||
set.add(`${p.name}:${mItem.modelId}`)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
return set
|
|
||||||
})
|
|
||||||
|
|
||||||
// Sync state if syncData changes
|
|
||||||
useEffect(() => {
|
|
||||||
if (syncData) {
|
|
||||||
setExpandedProviders(new Set(syncData.providers.map((p) => p.name)))
|
|
||||||
const modelSet = new Set<string>()
|
|
||||||
syncData.providers.forEach((p) => {
|
|
||||||
p.models.forEach((mItem) => {
|
|
||||||
modelSet.add(`${p.name}:${mItem.modelId}`)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
setSelectedModels(modelSet)
|
|
||||||
}
|
|
||||||
}, [syncData])
|
|
||||||
|
|
||||||
// Filtered tree data based on filterQuery
|
|
||||||
const filteredTree = useMemo(() => {
|
|
||||||
if (!syncData) return []
|
|
||||||
const q = filterQuery.trim().toLowerCase()
|
|
||||||
if (!q) return syncData.providers
|
|
||||||
|
|
||||||
return syncData.providers
|
|
||||||
.map((p) => {
|
|
||||||
const matchesProvider = p.name.toLowerCase().includes(q)
|
|
||||||
const matchingModels = p.models.filter(
|
|
||||||
(mItem) =>
|
|
||||||
matchesProvider ||
|
|
||||||
mItem.modelId.toLowerCase().includes(q) ||
|
|
||||||
mItem.name.toLowerCase().includes(q),
|
|
||||||
)
|
|
||||||
if (matchingModels.length > 0) {
|
|
||||||
return { ...p, models: matchingModels }
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
})
|
|
||||||
.filter((p): p is NonNullable<typeof p> => p !== null)
|
|
||||||
}, [syncData, filterQuery])
|
|
||||||
|
|
||||||
// Total selected models & providers
|
|
||||||
const totalSelectedModelsCount = selectedModels.size
|
|
||||||
const totalSelectedProvidersCount = useMemo(() => {
|
|
||||||
if (!syncData) return 0
|
|
||||||
let count = 0
|
|
||||||
for (const p of syncData.providers) {
|
|
||||||
const hasSelectedModel = p.models.some((mItem) =>
|
|
||||||
selectedModels.has(`${p.name}:${mItem.modelId}`),
|
|
||||||
)
|
|
||||||
if (hasSelectedModel) count++
|
|
||||||
}
|
|
||||||
return count
|
|
||||||
}, [syncData, selectedModels])
|
|
||||||
|
|
||||||
const toggleExpand = (providerName: string) => {
|
|
||||||
setExpandedProviders((prev) => {
|
|
||||||
const next = new Set(prev)
|
|
||||||
if (next.has(providerName)) {
|
|
||||||
next.delete(providerName)
|
|
||||||
} else {
|
|
||||||
next.add(providerName)
|
|
||||||
}
|
|
||||||
return next
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleExpandAll = () => {
|
|
||||||
if (!syncData) return
|
|
||||||
setExpandedProviders(new Set(syncData.providers.map((p) => p.name)))
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleCollapseAll = () => {
|
|
||||||
setExpandedProviders(new Set())
|
|
||||||
}
|
|
||||||
|
|
||||||
const toggleModel = (providerName: string, modelId: string) => {
|
|
||||||
const key = `${providerName}:${modelId}`
|
|
||||||
setSelectedModels((prevModels) => {
|
|
||||||
const nextModels = new Set(prevModels)
|
|
||||||
if (nextModels.has(key)) {
|
|
||||||
nextModels.delete(key)
|
|
||||||
} else {
|
|
||||||
nextModels.add(key)
|
|
||||||
}
|
|
||||||
return nextModels
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const toggleProvider = (providerName: string) => {
|
|
||||||
const providerData = syncData?.providers.find((p) => p.name === providerName)
|
|
||||||
if (!providerData || providerData.models.length === 0) return
|
|
||||||
|
|
||||||
const allModelsChecked = providerData.models.every((mItem) =>
|
|
||||||
selectedModels.has(`${providerName}:${mItem.modelId}`),
|
|
||||||
)
|
|
||||||
|
|
||||||
setSelectedModels((prev) => {
|
|
||||||
const next = new Set(prev)
|
|
||||||
providerData.models.forEach((mItem) => {
|
|
||||||
const key = `${providerName}:${mItem.modelId}`
|
|
||||||
if (allModelsChecked) {
|
|
||||||
next.delete(key)
|
|
||||||
} else {
|
|
||||||
next.add(key)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return next
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleSelectAll = () => {
|
|
||||||
if (!syncData) return
|
|
||||||
const modelSet = new Set<string>()
|
|
||||||
syncData.providers.forEach((p) => {
|
|
||||||
p.models.forEach((mItem) => {
|
|
||||||
modelSet.add(`${p.name}:${mItem.modelId}`)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
setSelectedModels(modelSet)
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleDeselectAll = () => {
|
|
||||||
setSelectedModels(new Set())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply mutation
|
|
||||||
const applyMutation = useMutation({
|
|
||||||
mutationFn: async (payload: SyncApplyRequest) => {
|
|
||||||
const res = await client.api.teams[':teamId'].providers['sync-apply'].$post({
|
|
||||||
param: { teamId },
|
|
||||||
json: payload,
|
|
||||||
})
|
|
||||||
if (!res.ok) {
|
|
||||||
const err = await res.json().catch(() => ({ message: 'Failed to apply sync' }))
|
|
||||||
throw new Error((err as { message?: string }).message || 'Failed to apply sync')
|
|
||||||
}
|
|
||||||
return await res.json()
|
|
||||||
},
|
|
||||||
onSuccess: (data) => {
|
|
||||||
toast.success(
|
|
||||||
m.sync_providers_success({
|
|
||||||
modelCount: data.addedModels,
|
|
||||||
providerCount: data.addedProviders,
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
onSuccess()
|
|
||||||
onClose()
|
|
||||||
},
|
|
||||||
onError: (error: Error) => {
|
|
||||||
toast.error(error.message)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const handleConfirm = async () => {
|
|
||||||
if (!syncData || totalSelectedModelsCount === 0) return
|
|
||||||
|
|
||||||
const providersToSync: SyncApplyRequest['providers'] = []
|
|
||||||
|
|
||||||
for (const p of syncData.providers) {
|
|
||||||
const selectedModelsForProvider = p.models.filter((mItem) =>
|
|
||||||
selectedModels.has(`${p.name}:${mItem.modelId}`),
|
|
||||||
)
|
|
||||||
|
|
||||||
if (selectedModelsForProvider.length > 0) {
|
|
||||||
providersToSync.push({
|
|
||||||
name: p.name,
|
|
||||||
isNewProvider: p.isNewProvider,
|
|
||||||
config: p.config,
|
|
||||||
models: selectedModelsForProvider,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (providersToSync.length === 0) return
|
|
||||||
|
|
||||||
await applyMutation.mutateAsync({
|
|
||||||
providers: providersToSync,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Dialog open={isOpen} onOpenChange={(open) => !open && onClose()}>
|
|
||||||
<DialogContent className="sm:max-w-3xl md:max-w-4xl w-full h-[85vh] max-h-[85vh] flex flex-col p-0 overflow-hidden gap-0">
|
|
||||||
<DialogHeader className="p-6 pb-4 shrink-0">
|
|
||||||
<DialogTitle className="flex items-center gap-2 text-xl font-semibold">
|
|
||||||
<Sparkles className="w-5 h-5 text-primary" />
|
|
||||||
{m.sync_providers_dialog_title()}
|
|
||||||
</DialogTitle>
|
|
||||||
<DialogDescription className="text-xs text-muted-foreground leading-relaxed mt-1.5">
|
|
||||||
{m.sync_providers_dialog_description()}
|
|
||||||
</DialogDescription>
|
|
||||||
</DialogHeader>
|
|
||||||
|
|
||||||
{/* Controls Toolbar */}
|
|
||||||
<div className="px-6 pb-3 shrink-0">
|
|
||||||
<div className="flex items-center justify-between gap-3">
|
|
||||||
<div className="relative flex-1">
|
|
||||||
<Search className="absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground" />
|
|
||||||
<Input
|
|
||||||
value={filterQuery}
|
|
||||||
onChange={(e) => setFilterQuery(e.target.value)}
|
|
||||||
placeholder={m.sync_providers_search_placeholder()}
|
|
||||||
className="pl-8 h-8 text-xs bg-background"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-1.5">
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
variant="outline"
|
|
||||||
size="sm"
|
|
||||||
onClick={handleExpandAll}
|
|
||||||
className="h-8 text-xs px-2.5"
|
|
||||||
>
|
|
||||||
{m.sync_providers_expand_all()}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
variant="outline"
|
|
||||||
size="sm"
|
|
||||||
onClick={handleCollapseAll}
|
|
||||||
className="h-8 text-xs px-2.5"
|
|
||||||
>
|
|
||||||
{m.sync_providers_collapse_all()}
|
|
||||||
</Button>
|
|
||||||
<div className="w-px h-4 bg-border mx-1" />
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
variant="outline"
|
|
||||||
size="sm"
|
|
||||||
onClick={handleSelectAll}
|
|
||||||
className="h-8 text-xs px-2.5"
|
|
||||||
>
|
|
||||||
{m.sync_providers_select_all()}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
variant="outline"
|
|
||||||
size="sm"
|
|
||||||
onClick={handleDeselectAll}
|
|
||||||
className="h-8 text-xs px-2.5"
|
|
||||||
>
|
|
||||||
{m.sync_providers_deselect_all()}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Tree List Container */}
|
|
||||||
<div className="flex-1 min-h-0 px-6 overflow-hidden">
|
|
||||||
<ScrollArea className="h-full border border-border/60 rounded-md bg-muted/20">
|
|
||||||
<div className="p-3 space-y-3">
|
|
||||||
{filteredTree.length === 0 ? (
|
|
||||||
<div className="py-8 text-center text-sm text-muted-foreground">
|
|
||||||
{m.no_matches_found()}
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
filteredTree.map((provider) => {
|
|
||||||
const isExpanded = expandedProviders.has(provider.name)
|
|
||||||
const isNew = provider.isNewProvider
|
|
||||||
|
|
||||||
// Determine provider check state
|
|
||||||
const checkedCount = provider.models.filter((mItem) =>
|
|
||||||
selectedModels.has(`${provider.name}:${mItem.modelId}`),
|
|
||||||
).length
|
|
||||||
const allChecked = checkedCount === provider.models.length
|
|
||||||
const someChecked = checkedCount > 0 && !allChecked
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={provider.name}
|
|
||||||
className="border border-border/50 rounded-lg bg-background overflow-hidden"
|
|
||||||
>
|
|
||||||
{/* Provider Header Row */}
|
|
||||||
<div className="flex items-center justify-between px-3 py-2 bg-card hover:bg-muted/40 transition-colors">
|
|
||||||
<div className="flex items-center gap-2.5">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={() => toggleExpand(provider.name)}
|
|
||||||
className="p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors"
|
|
||||||
>
|
|
||||||
{isExpanded ? (
|
|
||||||
<ChevronDown className="w-4 h-4" />
|
|
||||||
) : (
|
|
||||||
<ChevronRight className="w-4 h-4" />
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<Checkbox
|
|
||||||
checked={allChecked ? true : someChecked ? 'indeterminate' : false}
|
|
||||||
onCheckedChange={() => toggleProvider(provider.name)}
|
|
||||||
id={`provider-check-${provider.name}`}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<label
|
|
||||||
htmlFor={`provider-check-${provider.name}`}
|
|
||||||
className="font-medium text-sm text-foreground flex items-center gap-2 cursor-pointer select-none"
|
|
||||||
>
|
|
||||||
<Cpu className="w-4 h-4 text-muted-foreground" />
|
|
||||||
<span>{provider.name}</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
{isNew ? (
|
|
||||||
<Badge
|
|
||||||
variant="secondary"
|
|
||||||
className="text-[10px] px-1.5 py-0 bg-primary/10 text-primary border-primary/20"
|
|
||||||
>
|
|
||||||
{m.sync_providers_new_provider()}
|
|
||||||
</Badge>
|
|
||||||
) : (
|
|
||||||
<Badge
|
|
||||||
variant="outline"
|
|
||||||
className="text-[10px] px-1.5 py-0 text-muted-foreground"
|
|
||||||
>
|
|
||||||
{m.sync_providers_existing_provider()}
|
|
||||||
</Badge>
|
|
||||||
)}
|
|
||||||
<span className="text-xs text-muted-foreground">
|
|
||||||
{m.sync_providers_new_models_count({
|
|
||||||
count: provider.models.length,
|
|
||||||
})}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Model Children Rows */}
|
|
||||||
{isExpanded && (
|
|
||||||
<div className="border-t border-border/40 divide-y divide-border/30 bg-muted/10">
|
|
||||||
{provider.models.map((model) => {
|
|
||||||
const isModelChecked = selectedModels.has(
|
|
||||||
`${provider.name}:${model.modelId}`,
|
|
||||||
)
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={model.modelId}
|
|
||||||
className="flex items-center justify-between pl-9 pr-3 py-2 hover:bg-muted/30 transition-colors"
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-2.5 min-w-0">
|
|
||||||
<Checkbox
|
|
||||||
checked={isModelChecked}
|
|
||||||
onCheckedChange={() =>
|
|
||||||
toggleModel(provider.name, model.modelId)
|
|
||||||
}
|
|
||||||
id={`model-check-${provider.name}-${model.modelId}`}
|
|
||||||
/>
|
|
||||||
<label
|
|
||||||
htmlFor={`model-check-${provider.name}-${model.modelId}`}
|
|
||||||
className="text-xs font-medium text-foreground cursor-pointer select-none truncate"
|
|
||||||
>
|
|
||||||
{model.name || model.modelId}
|
|
||||||
<span className="ml-1.5 text-[11px] text-muted-foreground font-mono font-normal">
|
|
||||||
{model.modelId}
|
|
||||||
</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex items-center gap-1.5 shrink-0 ml-2">
|
|
||||||
{model.config.reasoning && (
|
|
||||||
<Badge
|
|
||||||
variant="outline"
|
|
||||||
className="text-[10px] px-1.5 py-0 font-normal border-amber-500/30 text-amber-600 dark:text-amber-400"
|
|
||||||
>
|
|
||||||
{m.sync_providers_reasoning()}
|
|
||||||
</Badge>
|
|
||||||
)}
|
|
||||||
<span className="text-[11px] text-muted-foreground font-mono">
|
|
||||||
{m.sync_providers_context_window({
|
|
||||||
count: Math.round(model.config.contextWindow / 1000),
|
|
||||||
})}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
})
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</ScrollArea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Selected Count & Footer */}
|
|
||||||
<DialogFooter className="p-6 pt-3 shrink-0 border-t border-border flex items-center justify-between sm:justify-between w-full">
|
|
||||||
<div className="text-xs text-muted-foreground">
|
|
||||||
{m.sync_providers_selected_count({
|
|
||||||
modelCount: totalSelectedModelsCount,
|
|
||||||
providerCount: totalSelectedProvidersCount,
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
variant="outline"
|
|
||||||
onClick={onClose}
|
|
||||||
disabled={applyMutation.isPending}
|
|
||||||
>
|
|
||||||
{m.cancel()}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
onClick={handleConfirm}
|
|
||||||
disabled={totalSelectedModelsCount === 0 || applyMutation.isPending}
|
|
||||||
className="gap-2"
|
|
||||||
>
|
|
||||||
{applyMutation.isPending ? (
|
|
||||||
<>
|
|
||||||
<Loader2 className="w-4 h-4 animate-spin" />
|
|
||||||
{m.sync_providers_adding()}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
m.sync_providers_add_selected({
|
|
||||||
count: totalSelectedModelsCount,
|
|
||||||
})
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</DialogFooter>
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -89,14 +89,16 @@ function ComboboxContent({
|
|||||||
align = 'start',
|
align = 'start',
|
||||||
alignOffset = 0,
|
alignOffset = 0,
|
||||||
anchor,
|
anchor,
|
||||||
|
container,
|
||||||
...props
|
...props
|
||||||
}: ComboboxPrimitive.Popup.Props &
|
}: ComboboxPrimitive.Popup.Props &
|
||||||
Pick<
|
Pick<
|
||||||
ComboboxPrimitive.Positioner.Props,
|
ComboboxPrimitive.Positioner.Props,
|
||||||
'side' | 'align' | 'sideOffset' | 'alignOffset' | 'anchor'
|
'side' | 'align' | 'sideOffset' | 'alignOffset' | 'anchor'
|
||||||
>) {
|
> &
|
||||||
|
Pick<ComboboxPrimitive.Portal.Props, 'container'>) {
|
||||||
return (
|
return (
|
||||||
<ComboboxPrimitive.Portal>
|
<ComboboxPrimitive.Portal container={container}>
|
||||||
<ComboboxPrimitive.Positioner
|
<ComboboxPrimitive.Positioner
|
||||||
side={side}
|
side={side}
|
||||||
sideOffset={sideOffset}
|
sideOffset={sideOffset}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { useQuery } from '@tanstack/react-query'
|
import { useServerFeatures } from './use-server-features'
|
||||||
import { client } from '@/ui/api/client'
|
|
||||||
|
|
||||||
export interface ArchiveConfig {
|
export interface ArchiveConfig {
|
||||||
archiveStorageEnabled: boolean
|
archiveStorageEnabled: boolean
|
||||||
@@ -7,21 +6,7 @@ export interface ArchiveConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function useArchiveConfig(): ArchiveConfig {
|
export function useArchiveConfig(): ArchiveConfig {
|
||||||
const { data, isLoading } = useQuery({
|
const { data, isLoading } = useServerFeatures()
|
||||||
queryKey: ['signup-info'],
|
|
||||||
queryFn: async () => {
|
|
||||||
const res = await client.api['signup-info'].$get()
|
|
||||||
if (!res.ok) {
|
|
||||||
return { initialized: true, demoMode: false, archiveStorageEnabled: false }
|
|
||||||
}
|
|
||||||
return (await res.json()) as {
|
|
||||||
initialized?: boolean
|
|
||||||
demoMode?: boolean
|
|
||||||
archiveStorageEnabled?: boolean
|
|
||||||
}
|
|
||||||
},
|
|
||||||
staleTime: 5 * 60 * 1000,
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
archiveStorageEnabled: Boolean(data?.archiveStorageEnabled),
|
archiveStorageEnabled: Boolean(data?.archiveStorageEnabled),
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { useQuery } from '@tanstack/react-query'
|
||||||
|
import { client } from '@/ui/api/client'
|
||||||
|
|
||||||
|
export function useServerFeatures() {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ['signup-info'],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await client.api['signup-info'].$get()
|
||||||
|
if (!res.ok) return null
|
||||||
|
return await res.json()
|
||||||
|
},
|
||||||
|
staleTime: 5 * 60 * 1000,
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -432,6 +432,7 @@
|
|||||||
"copy_image": "Image",
|
"copy_image": "Image",
|
||||||
"copy_name": "Name",
|
"copy_name": "Name",
|
||||||
"copy_app_link": "Link",
|
"copy_app_link": "Link",
|
||||||
|
"open_in_new_tab": "Open in new tab",
|
||||||
"copy_download_link": "Download link",
|
"copy_download_link": "Download link",
|
||||||
"copy_id": "ID",
|
"copy_id": "ID",
|
||||||
"copy_markdown_link": "Markdown link",
|
"copy_markdown_link": "Markdown link",
|
||||||
@@ -459,27 +460,27 @@
|
|||||||
"ai": "AI",
|
"ai": "AI",
|
||||||
"providers": "Providers",
|
"providers": "Providers",
|
||||||
"providers_description": "Configure AI providers and their models for this team.",
|
"providers_description": "Configure AI providers and their models for this team.",
|
||||||
"configured_ai_providers": "Configured AI Providers",
|
"provider_configured_badge": "Configured",
|
||||||
|
"provider_options": "Options for {name}",
|
||||||
|
"provider_refresh_models": "Refresh models",
|
||||||
|
"provider_refresh_action": "Refresh models for {name}",
|
||||||
|
"provider_refresh_loading": "Refreshing…",
|
||||||
|
"provider_refresh_legacy_kimi_connection": "The public Kimi catalog uses Chat Completions. You can still add models manually to this Anthropic Messages connection.",
|
||||||
|
"provider_refresh_azure_deployment_required": "Set an Azure endpoint and map deployed model IDs to refresh models.",
|
||||||
|
"provider_refresh_catalog_unavailable": "Pi does not publish a model catalog for this provider.",
|
||||||
|
"provider_refresh_unsupported_connection": "Refresh is unavailable for this endpoint or API.",
|
||||||
|
"provider_refresh_failed": "Could not refresh models. Try again.",
|
||||||
|
"provider_refresh_no_new_models": "No new models for {name}.",
|
||||||
|
"provider_refresh_dialog_title": "New models for {name}",
|
||||||
|
"provider_refresh_dialog_description": "Select the models you want to add.",
|
||||||
|
"provider_refresh_select_visible": "Select visible",
|
||||||
|
"provider_refresh_deselect_visible": "Deselect visible",
|
||||||
|
"provider_refresh_add_selected": "Add selected",
|
||||||
|
"provider_refresh_add_selection": "Add selected ({count})",
|
||||||
|
"provider_refresh_imported": "Added {count} models to {name}.",
|
||||||
|
"provider_refresh_import_failed": "Could not add the selected models. Try again.",
|
||||||
|
"provider_refresh_stale": "This preview has expired or the connection changed. Refresh models again.",
|
||||||
"add_provider": "Add Provider",
|
"add_provider": "Add Provider",
|
||||||
"sync_providers": "Sync Providers",
|
|
||||||
"sync_providers_checking": "Checking for updates...",
|
|
||||||
"sync_providers_dialog_title": "Sync Providers & Models",
|
|
||||||
"sync_providers_dialog_description": "Select the new providers and models you want to add. Existing providers, custom endpoints, API keys, and model configurations will never be deleted or modified.",
|
|
||||||
"sync_providers_up_to_date": "All providers and models are already up to date.",
|
|
||||||
"sync_providers_select_all": "Select All",
|
|
||||||
"sync_providers_deselect_all": "Deselect All",
|
|
||||||
"sync_providers_expand_all": "Expand All",
|
|
||||||
"sync_providers_collapse_all": "Collapse All",
|
|
||||||
"sync_providers_search_placeholder": "Filter new providers or models...",
|
|
||||||
"sync_providers_new_provider": "New Provider",
|
|
||||||
"sync_providers_existing_provider": "Existing Provider",
|
|
||||||
"sync_providers_new_models_count": "{count} new models",
|
|
||||||
"sync_providers_selected_count": "{modelCount} models selected across {providerCount} providers",
|
|
||||||
"sync_providers_reasoning": "reasoning",
|
|
||||||
"sync_providers_context_window": "{count}k ctx",
|
|
||||||
"sync_providers_add_selected": "Add Selected ({count})",
|
|
||||||
"sync_providers_adding": "Adding...",
|
|
||||||
"sync_providers_success": "Successfully added {modelCount} models across {providerCount} providers.",
|
|
||||||
"search_providers_placeholder": "Search providers...",
|
"search_providers_placeholder": "Search providers...",
|
||||||
"no_providers_found": "No providers found",
|
"no_providers_found": "No providers found",
|
||||||
"built_in": "Built-in",
|
"built_in": "Built-in",
|
||||||
@@ -1141,6 +1142,12 @@
|
|||||||
"reply": "Reply",
|
"reply": "Reply",
|
||||||
"agent_session_logs": "Agent Session Logs",
|
"agent_session_logs": "Agent Session Logs",
|
||||||
"agent_logs_description": "Step-by-step execution trace of the agent's background tasks and tool calls.",
|
"agent_logs_description": "Step-by-step execution trace of the agent's background tasks and tool calls.",
|
||||||
|
"session_usage": "Session usage",
|
||||||
|
"session_usage_unavailable": "Session usage unavailable",
|
||||||
|
"session_usage_estimated_cost": "est. cost",
|
||||||
|
"session_usage_breakdown": "Breakdown",
|
||||||
|
"session_usage_token_breakdown": "Token breakdown",
|
||||||
|
"session_usage_cost_explanation": "Cost is estimated using configured model prices.",
|
||||||
"role_user": "User",
|
"role_user": "User",
|
||||||
"role_agent": "Agent",
|
"role_agent": "Agent",
|
||||||
"tool_result": "Tool Result:",
|
"tool_result": "Tool Result:",
|
||||||
@@ -1803,5 +1810,19 @@
|
|||||||
"internal_comment_tooltip": "Internal comment — hidden from public share links",
|
"internal_comment_tooltip": "Internal comment — hidden from public share links",
|
||||||
"internal_reply_locked_tooltip": "Replies to internal comments are always internal",
|
"internal_reply_locked_tooltip": "Replies to internal comments are always internal",
|
||||||
"remove_timestamp": "Remove timestamp",
|
"remove_timestamp": "Remove timestamp",
|
||||||
"failed_to_update_comment": "Failed to update comment"
|
"failed_to_update_comment": "Failed to update comment",
|
||||||
|
"generate_transcripts": "Generate Transcripts",
|
||||||
|
"transcript_language_auto": "Auto",
|
||||||
|
"transcript_queued": "Transcript generation queued.",
|
||||||
|
"transcript_generating": "Generating transcript…",
|
||||||
|
"transcript_completed": "Transcript generated.",
|
||||||
|
"transcript_no_speech": "No speech detected.",
|
||||||
|
"transcript_no_audio": "This video has no audio track.",
|
||||||
|
"transcript_audio_too_large": "The audio exceeds the embedding server’s upload limit.",
|
||||||
|
"transcript_failed": "Transcript generation failed.",
|
||||||
|
"transcript_submit_failed": "Could not start transcript generation.",
|
||||||
|
"transcript_already_exists": "A transcript already exists for this language.",
|
||||||
|
"transcript_languages_unavailable": "Could not load transcription languages.",
|
||||||
|
"transcript_no_languages_found": "No matching languages.",
|
||||||
|
"transcript_status_unavailable": "Could not check transcript status."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -418,6 +418,7 @@
|
|||||||
"copy_image": "이미지",
|
"copy_image": "이미지",
|
||||||
"copy_name": "이름",
|
"copy_name": "이름",
|
||||||
"copy_app_link": "링크",
|
"copy_app_link": "링크",
|
||||||
|
"open_in_new_tab": "새 탭에서 열기",
|
||||||
"copy_download_link": "다운로드 링크",
|
"copy_download_link": "다운로드 링크",
|
||||||
"copy_id": "ID",
|
"copy_id": "ID",
|
||||||
"copy_markdown_link": "Markdown 링크",
|
"copy_markdown_link": "Markdown 링크",
|
||||||
@@ -444,27 +445,27 @@
|
|||||||
"ai": "AI",
|
"ai": "AI",
|
||||||
"providers": "프로바이더",
|
"providers": "프로바이더",
|
||||||
"providers_description": "이 팀의 AI 프로바이더와 모델을 설정합니다.",
|
"providers_description": "이 팀의 AI 프로바이더와 모델을 설정합니다.",
|
||||||
"configured_ai_providers": "설정된 AI 프로바이더",
|
"provider_configured_badge": "설정됨",
|
||||||
|
"provider_options": "{name} 옵션",
|
||||||
|
"provider_refresh_models": "모델 새로 고침",
|
||||||
|
"provider_refresh_action": "{name}의 모델 새로 고침",
|
||||||
|
"provider_refresh_loading": "새로 고치는 중…",
|
||||||
|
"provider_refresh_legacy_kimi_connection": "Kimi 공개 카탈로그는 Chat Completions를 사용합니다. 이 Anthropic Messages 연결에 모델을 직접 추가할 수 있습니다.",
|
||||||
|
"provider_refresh_azure_deployment_required": "모델을 새로 고치려면 Azure 엔드포인트를 설정하고 배포된 모델 ID를 매핑하세요.",
|
||||||
|
"provider_refresh_catalog_unavailable": "Pi에서 이 제공업체의 모델 카탈로그를 제공하지 않습니다.",
|
||||||
|
"provider_refresh_unsupported_connection": "이 엔드포인트 또는 API에서는 모델을 새로 고칠 수 없습니다.",
|
||||||
|
"provider_refresh_failed": "모델을 새로 고침할 수 없습니다. 다시 시도하세요.",
|
||||||
|
"provider_refresh_no_new_models": "{name}에 새 모델이 없습니다.",
|
||||||
|
"provider_refresh_dialog_title": "{name}의 새 모델",
|
||||||
|
"provider_refresh_dialog_description": "추가할 모델을 선택하세요.",
|
||||||
|
"provider_refresh_select_visible": "표시된 모델 선택",
|
||||||
|
"provider_refresh_deselect_visible": "표시된 모델 선택 해제",
|
||||||
|
"provider_refresh_add_selected": "선택한 모델 추가",
|
||||||
|
"provider_refresh_add_selection": "선택한 모델 추가({count}개)",
|
||||||
|
"provider_refresh_imported": "{name}에 모델 {count}개를 추가했습니다.",
|
||||||
|
"provider_refresh_import_failed": "선택한 모델을 추가할 수 없습니다. 다시 시도하세요.",
|
||||||
|
"provider_refresh_stale": "미리 보기가 만료되었거나 연결이 변경되었습니다. 모델을 다시 새로 고치세요.",
|
||||||
"add_provider": "프로바이더 추가",
|
"add_provider": "프로바이더 추가",
|
||||||
"sync_providers": "프로바이더 동기화",
|
|
||||||
"sync_providers_checking": "업데이트 확인 중...",
|
|
||||||
"sync_providers_dialog_title": "프로바이더 및 모델 동기화",
|
|
||||||
"sync_providers_dialog_description": "추가할 새 프로바이더와 모델을 선택하세요. 기존 프로바이더, 사용자 지정 엔드포인트, API 키, 모델 설정은 삭제되거나 변경되지 않습니다.",
|
|
||||||
"sync_providers_up_to_date": "모든 프로바이더와 모델이 최신 상태입니다.",
|
|
||||||
"sync_providers_select_all": "모두 선택",
|
|
||||||
"sync_providers_deselect_all": "모두 선택 해제",
|
|
||||||
"sync_providers_expand_all": "모두 펼치기",
|
|
||||||
"sync_providers_collapse_all": "모두 접기",
|
|
||||||
"sync_providers_search_placeholder": "새 프로바이더 또는 모델 필터...",
|
|
||||||
"sync_providers_new_provider": "새 프로바이더",
|
|
||||||
"sync_providers_existing_provider": "기존 프로바이더",
|
|
||||||
"sync_providers_new_models_count": "새 모델 {count}개",
|
|
||||||
"sync_providers_selected_count": "프로바이더 {providerCount}개에서 모델 {modelCount}개 선택됨",
|
|
||||||
"sync_providers_reasoning": "추론",
|
|
||||||
"sync_providers_context_window": "컨텍스트 {count}k",
|
|
||||||
"sync_providers_add_selected": "선택 항목 추가({count})",
|
|
||||||
"sync_providers_adding": "추가 중...",
|
|
||||||
"sync_providers_success": "프로바이더 {providerCount}개에 모델 {modelCount}개를 추가했습니다.",
|
|
||||||
"search_providers_placeholder": "프로바이더 검색...",
|
"search_providers_placeholder": "프로바이더 검색...",
|
||||||
"no_providers_found": "프로바이더를 찾을 수 없습니다",
|
"no_providers_found": "프로바이더를 찾을 수 없습니다",
|
||||||
"built_in": "기본 제공",
|
"built_in": "기본 제공",
|
||||||
@@ -1095,6 +1096,12 @@
|
|||||||
"reply": "답글",
|
"reply": "답글",
|
||||||
"agent_session_logs": "에이전트 세션 로그",
|
"agent_session_logs": "에이전트 세션 로그",
|
||||||
"agent_logs_description": "에이전트 백그라운드 작업과 도구 호출의 단계별 실행 기록입니다.",
|
"agent_logs_description": "에이전트 백그라운드 작업과 도구 호출의 단계별 실행 기록입니다.",
|
||||||
|
"session_usage": "세션 사용량",
|
||||||
|
"session_usage_unavailable": "세션 사용량을 확인할 수 없습니다",
|
||||||
|
"session_usage_estimated_cost": "예상 비용",
|
||||||
|
"session_usage_breakdown": "상세 내역",
|
||||||
|
"session_usage_token_breakdown": "토큰 사용량 상세 내역",
|
||||||
|
"session_usage_cost_explanation": "설정된 모델 요금을 기준으로 비용을 추정합니다.",
|
||||||
"role_user": "사용자",
|
"role_user": "사용자",
|
||||||
"role_agent": "에이전트",
|
"role_agent": "에이전트",
|
||||||
"tool_result": "도구 결과:",
|
"tool_result": "도구 결과:",
|
||||||
@@ -1733,5 +1740,19 @@
|
|||||||
"internal_comment_tooltip": "내부 댓글 — 공개 공유 링크에는 표시되지 않음",
|
"internal_comment_tooltip": "내부 댓글 — 공개 공유 링크에는 표시되지 않음",
|
||||||
"internal_reply_locked_tooltip": "내부 댓글에 대한 답글은 항상 내부 댓글로 작성됩니다",
|
"internal_reply_locked_tooltip": "내부 댓글에 대한 답글은 항상 내부 댓글로 작성됩니다",
|
||||||
"remove_timestamp": "타임스탬프 제거",
|
"remove_timestamp": "타임스탬프 제거",
|
||||||
"failed_to_update_comment": "댓글을 수정하지 못했습니다"
|
"failed_to_update_comment": "댓글을 수정하지 못했습니다",
|
||||||
|
"generate_transcripts": "전사 생성",
|
||||||
|
"transcript_language_auto": "자동 감지",
|
||||||
|
"transcript_queued": "전사 작업이 대기열에 추가되었습니다.",
|
||||||
|
"transcript_generating": "전사를 생성하는 중…",
|
||||||
|
"transcript_completed": "전사를 생성했습니다.",
|
||||||
|
"transcript_no_speech": "음성이 감지되지 않았습니다.",
|
||||||
|
"transcript_no_audio": "이 동영상에는 오디오 트랙이 없습니다.",
|
||||||
|
"transcript_audio_too_large": "오디오가 임베딩 서버의 업로드 한도를 초과합니다.",
|
||||||
|
"transcript_failed": "전사 생성에 실패했습니다.",
|
||||||
|
"transcript_submit_failed": "전사 생성을 시작할 수 없습니다.",
|
||||||
|
"transcript_already_exists": "이 언어의 전사가 이미 있습니다.",
|
||||||
|
"transcript_languages_unavailable": "전사 언어를 불러올 수 없습니다.",
|
||||||
|
"transcript_no_languages_found": "일치하는 언어가 없습니다.",
|
||||||
|
"transcript_status_unavailable": "전사 상태를 확인할 수 없습니다."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -432,6 +432,7 @@
|
|||||||
"copy_image": "图片",
|
"copy_image": "图片",
|
||||||
"copy_name": "名称",
|
"copy_name": "名称",
|
||||||
"copy_app_link": "链接",
|
"copy_app_link": "链接",
|
||||||
|
"open_in_new_tab": "在新标签页中打开",
|
||||||
"copy_download_link": "下载链接",
|
"copy_download_link": "下载链接",
|
||||||
"copy_id": "ID",
|
"copy_id": "ID",
|
||||||
"copy_markdown_link": "Markdown 链接",
|
"copy_markdown_link": "Markdown 链接",
|
||||||
@@ -459,27 +460,27 @@
|
|||||||
"ai": "AI",
|
"ai": "AI",
|
||||||
"providers": "提供商",
|
"providers": "提供商",
|
||||||
"providers_description": "为此团队配置 AI 提供商及其模型。",
|
"providers_description": "为此团队配置 AI 提供商及其模型。",
|
||||||
"configured_ai_providers": "已配置的 AI 提供商",
|
"provider_configured_badge": "已配置",
|
||||||
|
"provider_options": "{name} 的选项",
|
||||||
|
"provider_refresh_models": "刷新模型",
|
||||||
|
"provider_refresh_action": "刷新 {name} 的模型",
|
||||||
|
"provider_refresh_loading": "正在刷新…",
|
||||||
|
"provider_refresh_legacy_kimi_connection": "Kimi 的公开目录使用 Chat Completions。你仍然可以为此 Anthropic Messages 连接手动添加模型。",
|
||||||
|
"provider_refresh_azure_deployment_required": "设置 Azure 端点和已部署模型的 ID 映射后,即可刷新模型。",
|
||||||
|
"provider_refresh_catalog_unavailable": "Pi 未发布此提供商的模型目录。",
|
||||||
|
"provider_refresh_unsupported_connection": "此端点或 API 不支持刷新模型。",
|
||||||
|
"provider_refresh_failed": "无法刷新模型,请重试。",
|
||||||
|
"provider_refresh_no_new_models": "{name} 暂无新模型。",
|
||||||
|
"provider_refresh_dialog_title": "{name} 的新模型",
|
||||||
|
"provider_refresh_dialog_description": "请选择要添加的模型。",
|
||||||
|
"provider_refresh_select_visible": "选中当前结果",
|
||||||
|
"provider_refresh_deselect_visible": "取消选中当前结果",
|
||||||
|
"provider_refresh_add_selected": "添加所选模型",
|
||||||
|
"provider_refresh_add_selection": "添加所选模型({count} 个)",
|
||||||
|
"provider_refresh_imported": "已向 {name} 添加 {count} 个模型。",
|
||||||
|
"provider_refresh_import_failed": "无法添加所选模型,请重试。",
|
||||||
|
"provider_refresh_stale": "预览已过期或连接已更改,请重新刷新模型。",
|
||||||
"add_provider": "添加提供商",
|
"add_provider": "添加提供商",
|
||||||
"sync_providers": "同步提供商",
|
|
||||||
"sync_providers_checking": "正在检查更新...",
|
|
||||||
"sync_providers_dialog_title": "同步提供商与模型",
|
|
||||||
"sync_providers_dialog_description": "选择您希望添加的新提供商和模型。现有的提供商、自定义端点、API 密钥和模型配置绝不会被删除或修改。",
|
|
||||||
"sync_providers_up_to_date": "所有提供商和模型均已是最新状态。",
|
|
||||||
"sync_providers_select_all": "全选",
|
|
||||||
"sync_providers_deselect_all": "取消全选",
|
|
||||||
"sync_providers_expand_all": "全部展开",
|
|
||||||
"sync_providers_collapse_all": "全部折叠",
|
|
||||||
"sync_providers_search_placeholder": "筛选新提供商或模型...",
|
|
||||||
"sync_providers_new_provider": "新提供商",
|
|
||||||
"sync_providers_existing_provider": "现有提供商",
|
|
||||||
"sync_providers_new_models_count": "{count} 个新模型",
|
|
||||||
"sync_providers_selected_count": "已选 {modelCount} 个模型,分布在 {providerCount} 个提供商中",
|
|
||||||
"sync_providers_reasoning": "深度思考",
|
|
||||||
"sync_providers_context_window": "{count}k 上下文",
|
|
||||||
"sync_providers_add_selected": "添加所选 ({count})",
|
|
||||||
"sync_providers_adding": "正在添加...",
|
|
||||||
"sync_providers_success": "已成功添加 {providerCount} 个提供商中的 {modelCount} 个模型。",
|
|
||||||
"search_providers_placeholder": "搜索提供商...",
|
"search_providers_placeholder": "搜索提供商...",
|
||||||
"no_providers_found": "未找到提供商",
|
"no_providers_found": "未找到提供商",
|
||||||
"built_in": "内置",
|
"built_in": "内置",
|
||||||
@@ -1141,6 +1142,12 @@
|
|||||||
"reply": "回复",
|
"reply": "回复",
|
||||||
"agent_session_logs": "智能体会话日志",
|
"agent_session_logs": "智能体会话日志",
|
||||||
"agent_logs_description": "智能体后台任务和工具调用的逐步执行跟踪。",
|
"agent_logs_description": "智能体后台任务和工具调用的逐步执行跟踪。",
|
||||||
|
"session_usage": "会话用量",
|
||||||
|
"session_usage_unavailable": "暂无会话用量",
|
||||||
|
"session_usage_estimated_cost": "预估费用",
|
||||||
|
"session_usage_breakdown": "明细",
|
||||||
|
"session_usage_token_breakdown": "Token 用量明细",
|
||||||
|
"session_usage_cost_explanation": "费用根据配置的模型价格估算。",
|
||||||
"role_user": "用户",
|
"role_user": "用户",
|
||||||
"role_agent": "智能体",
|
"role_agent": "智能体",
|
||||||
"tool_result": "工具结果:",
|
"tool_result": "工具结果:",
|
||||||
@@ -1803,5 +1810,19 @@
|
|||||||
"internal_comment_tooltip": "内部评论 — 不会在公开分享链接中显示",
|
"internal_comment_tooltip": "内部评论 — 不会在公开分享链接中显示",
|
||||||
"internal_reply_locked_tooltip": "回复内部评论时只能发送内部评论",
|
"internal_reply_locked_tooltip": "回复内部评论时只能发送内部评论",
|
||||||
"remove_timestamp": "移除时间戳",
|
"remove_timestamp": "移除时间戳",
|
||||||
"failed_to_update_comment": "更新评论失败"
|
"failed_to_update_comment": "更新评论失败",
|
||||||
|
"generate_transcripts": "生成转录",
|
||||||
|
"transcript_language_auto": "自动检测",
|
||||||
|
"transcript_queued": "转录任务已加入队列。",
|
||||||
|
"transcript_generating": "正在生成转录…",
|
||||||
|
"transcript_completed": "转录已生成。",
|
||||||
|
"transcript_no_speech": "未检测到语音。",
|
||||||
|
"transcript_no_audio": "此视频没有音轨。",
|
||||||
|
"transcript_audio_too_large": "音频超出嵌入服务器的上传大小限制。",
|
||||||
|
"transcript_failed": "转录生成失败。",
|
||||||
|
"transcript_submit_failed": "无法启动转录生成。",
|
||||||
|
"transcript_already_exists": "此语言的转录已存在。",
|
||||||
|
"transcript_languages_unavailable": "无法加载转录语言。",
|
||||||
|
"transcript_no_languages_found": "没有匹配的语言。",
|
||||||
|
"transcript_status_unavailable": "无法获取转录状态。"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
"@dnd-kit/abstract": "0.5.0",
|
"@dnd-kit/abstract": "0.5.0",
|
||||||
"@dnd-kit/dom": "0.5.0",
|
"@dnd-kit/dom": "0.5.0",
|
||||||
"@dnd-kit/react": "0.5.0",
|
"@dnd-kit/react": "0.5.0",
|
||||||
"@earendil-works/pi-ai": "1.5.0",
|
"@earendil-works/pi-ai": "1.7.0",
|
||||||
"@earendil-works/pi-durable": "1.5.0",
|
"@earendil-works/pi-durable": "1.7.0",
|
||||||
"@ferrucc-io/emoji-picker": "0.1.2",
|
"@ferrucc-io/emoji-picker": "0.1.2",
|
||||||
"@hookform/resolvers": "5.9.1",
|
"@hookform/resolvers": "5.9.1",
|
||||||
"@lexical/code": "0.49.0",
|
"@lexical/code": "0.49.0",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { createLazyFileRoute } from '@tanstack/react-router'
|
import { createLazyFileRoute, Link } from '@tanstack/react-router'
|
||||||
import type { ProjectInfo } from '@shumai/dtos'
|
import type { ProjectInfo } from '@shumai/dtos'
|
||||||
import { usePermissions } from '@/ui/hooks/use-permissions'
|
import { usePermissions } from '@/ui/hooks/use-permissions'
|
||||||
import { client } from '@/ui/api/client'
|
import { client } from '@/ui/api/client'
|
||||||
@@ -30,7 +30,6 @@ import { formatDateAgo } from '@/ui/lib/time'
|
|||||||
import { cn } from '@/ui/lib/utils'
|
import { cn } from '@/ui/lib/utils'
|
||||||
import { useUserMetadataStore } from '@/ui/stores/user-metadata'
|
import { useUserMetadataStore } from '@/ui/stores/user-metadata'
|
||||||
import { keepPreviousData, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
import { keepPreviousData, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||||
import { useNavigate } from '@tanstack/react-router'
|
|
||||||
import type { InferRequestType, InferResponseType } from 'hono/client'
|
import type { InferRequestType, InferResponseType } from 'hono/client'
|
||||||
import { MoreHorizontal, PlusIcon } from 'lucide-react'
|
import { MoreHorizontal, PlusIcon } from 'lucide-react'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
@@ -39,11 +38,9 @@ import { toast } from 'sonner'
|
|||||||
function TeamPage() {
|
function TeamPage() {
|
||||||
const { teamId } = Route.useParams()
|
const { teamId } = Route.useParams()
|
||||||
const { canEdit, canAdmin } = usePermissions()
|
const { canEdit, canAdmin } = usePermissions()
|
||||||
const navigate = useNavigate()
|
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
// State for clicked project for animation
|
const [isCreateCardPressed, setIsCreateCardPressed] = useState(false)
|
||||||
const [clickedProjectId, setClickedProjectId] = useState<string | null>(null)
|
|
||||||
|
|
||||||
// State for Project Dialog
|
// State for Project Dialog
|
||||||
const [isProjectDialogOpen, setIsProjectDialogOpen] = useState(false)
|
const [isProjectDialogOpen, setIsProjectDialogOpen] = useState(false)
|
||||||
@@ -169,9 +166,9 @@ function TeamPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleCreateCardClick = () => {
|
const handleCreateCardClick = () => {
|
||||||
setClickedProjectId('create')
|
setIsCreateCardPressed(true)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setClickedProjectId(null)
|
setIsCreateCardPressed(false)
|
||||||
}, 100)
|
}, 100)
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -202,25 +199,6 @@ function TeamPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleCardClick = (projectId: string, e: React.MouseEvent) => {
|
|
||||||
if (e.detail > 1) return
|
|
||||||
|
|
||||||
setClickedProjectId(projectId)
|
|
||||||
|
|
||||||
// Restore scale after 100ms for "shrink and restore" effect
|
|
||||||
setTimeout(() => {
|
|
||||||
setClickedProjectId(null)
|
|
||||||
}, 100)
|
|
||||||
|
|
||||||
// Navigate after 200ms
|
|
||||||
setTimeout(() => {
|
|
||||||
navigate({
|
|
||||||
to: '/projects/$projectId',
|
|
||||||
params: { projectId },
|
|
||||||
})
|
|
||||||
}, 200)
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleInvite = async (role: 'editor' | 'reviewer') => {
|
const handleInvite = async (role: 'editor' | 'reviewer') => {
|
||||||
const res = await inviteMutation.mutateAsync({
|
const res = await inviteMutation.mutateAsync({
|
||||||
param: { teamId: teamId },
|
param: { teamId: teamId },
|
||||||
@@ -316,13 +294,14 @@ function TeamPage() {
|
|||||||
{projects?.data?.map((project: ProjectInfo) => (
|
{projects?.data?.map((project: ProjectInfo) => (
|
||||||
<div
|
<div
|
||||||
key={project.id}
|
key={project.id}
|
||||||
className={cn(
|
className="shadow-md relative border rounded-xl overflow-hidden transition-transform duration-100 ease-in-out has-[a:active]:scale-95"
|
||||||
'shadow-md relative border rounded-xl overflow-hidden cursor-pointer transition-transform duration-100 ease-in-out',
|
|
||||||
clickedProjectId === project.id ? 'scale-95' : 'scale-100',
|
|
||||||
)}
|
|
||||||
onClick={(e) => handleCardClick(project.id!, e)}
|
|
||||||
>
|
>
|
||||||
<div className="flex flex-col">
|
<Link
|
||||||
|
to="/projects/$projectId"
|
||||||
|
params={{ projectId: project.id! }}
|
||||||
|
aria-label={project.name}
|
||||||
|
className="flex flex-col focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring"
|
||||||
|
>
|
||||||
<div className="relative w-full h-full aspect-square flex items-center justify-center bg-zinc-400/20">
|
<div className="relative w-full h-full aspect-square flex items-center justify-center bg-zinc-400/20">
|
||||||
{project.coverImage ? (
|
{project.coverImage ? (
|
||||||
<img
|
<img
|
||||||
@@ -377,53 +356,52 @@ function TeamPage() {
|
|||||||
<div className="absolute bottom-0 left-0 w-full h-[65%] bg-linear-to-t from-black/35 to-black/0" />
|
<div className="absolute bottom-0 left-0 w-full h-[65%] bg-linear-to-t from-black/35 to-black/0" />
|
||||||
<p className="absolute left-1 bottom-2 text-white">{project.name}</p>
|
<p className="absolute left-1 bottom-2 text-white">{project.name}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="px-2 h-10 flex justify-between items-center">
|
<div className="pl-2 pr-10 h-10 flex items-center">
|
||||||
<p className="truncate pr-1 text-xs text-muted-foreground">
|
<p className="truncate text-xs text-muted-foreground">
|
||||||
{m.updated_ago()} {formatDateAgo((project.updatedAt as string) ?? '')}
|
{m.updated_ago()} {formatDateAgo((project.updatedAt as string) ?? '')}
|
||||||
</p>
|
</p>
|
||||||
<div onClick={(e) => e.stopPropagation()}>
|
|
||||||
<DropdownMenu modal={false}>
|
|
||||||
<DropdownMenuTrigger asChild>
|
|
||||||
<button className="hover:bg-muted outline-none flex px-1">
|
|
||||||
<MoreHorizontal className="w-5 h-5 text-muted-foreground" />
|
|
||||||
</button>
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent align="end">
|
|
||||||
{canEdit && (
|
|
||||||
<DropdownMenuItem
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation()
|
|
||||||
handleEditProjectClick(project)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{m.project_settings()}
|
|
||||||
</DropdownMenuItem>
|
|
||||||
)}
|
|
||||||
<DropdownMenuItem
|
|
||||||
className="flex items-center justify-between gap-4 cursor-pointer"
|
|
||||||
onSelect={(e) => {
|
|
||||||
e.preventDefault()
|
|
||||||
toggleProjectNotificationsMutation.mutate(project)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<span>{m.notification()}</span>
|
|
||||||
<Switch
|
|
||||||
checked={project.enableNotification ?? true}
|
|
||||||
className="pointer-events-none"
|
|
||||||
/>
|
|
||||||
</DropdownMenuItem>
|
|
||||||
{canAdmin && (
|
|
||||||
<DropdownMenuItem
|
|
||||||
className="text-destructive focus:text-destructive"
|
|
||||||
onClick={() => handleDeleteProjectClick(project)}
|
|
||||||
>
|
|
||||||
{m.delete()}
|
|
||||||
</DropdownMenuItem>
|
|
||||||
)}
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</Link>
|
||||||
|
<div className="absolute right-2 bottom-0 flex h-10 items-center">
|
||||||
|
<DropdownMenu modal={false}>
|
||||||
|
<DropdownMenuTrigger asChild>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
aria-label={m.more_options()}
|
||||||
|
className="hover:bg-muted flex px-1"
|
||||||
|
>
|
||||||
|
<MoreHorizontal className="w-5 h-5 text-muted-foreground" />
|
||||||
|
</button>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent align="end">
|
||||||
|
{canEdit && (
|
||||||
|
<DropdownMenuItem onClick={() => handleEditProjectClick(project)}>
|
||||||
|
{m.project_settings()}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
)}
|
||||||
|
<DropdownMenuItem
|
||||||
|
className="flex items-center justify-between gap-4 cursor-pointer"
|
||||||
|
onSelect={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
toggleProjectNotificationsMutation.mutate(project)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span>{m.notification()}</span>
|
||||||
|
<Switch
|
||||||
|
checked={project.enableNotification ?? true}
|
||||||
|
className="pointer-events-none"
|
||||||
|
/>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
{canAdmin && (
|
||||||
|
<DropdownMenuItem
|
||||||
|
className="text-destructive focus:text-destructive"
|
||||||
|
onClick={() => handleDeleteProjectClick(project)}
|
||||||
|
>
|
||||||
|
{m.delete()}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
)}
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
@@ -431,7 +409,7 @@ function TeamPage() {
|
|||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
'shadow-md relative border rounded-xl overflow-hidden cursor-pointer transition-transform duration-100 ease-in-out border-dashed hover:border-orange-600/50 group',
|
'shadow-md relative border rounded-xl overflow-hidden cursor-pointer transition-transform duration-100 ease-in-out border-dashed hover:border-orange-600/50 group',
|
||||||
clickedProjectId === 'create' ? 'scale-95' : 'scale-100',
|
isCreateCardPressed ? 'scale-95' : 'scale-100',
|
||||||
)}
|
)}
|
||||||
onClick={handleCreateCardClick}
|
onClick={handleCreateCardClick}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -533,7 +533,12 @@ export function TeamSettingsPage() {
|
|||||||
<div className="h-full bg-background font-sans selection:bg-primary/20 transition-colors duration-300">
|
<div className="h-full bg-background font-sans selection:bg-primary/20 transition-colors duration-300">
|
||||||
<div className="flex flex-col md:flex-row h-full">
|
<div className="flex flex-col md:flex-row h-full">
|
||||||
{/* Sidebar */}
|
{/* Sidebar */}
|
||||||
<div className="w-full h-full md:w-72 bg-sidebar border-b md:border-b-0 md:border-r border-sidebar-border z-10 md:left-16 overflow-y-auto transition-colors duration-300">
|
<div
|
||||||
|
className={cn(
|
||||||
|
'w-full h-full md:w-72 bg-sidebar border-b md:border-b-0 md:border-r border-sidebar-border z-10 md:left-16 overflow-y-auto transition-colors duration-300',
|
||||||
|
activeTab === 'providers' && 'max-h-[28dvh] shrink-0 md:max-h-none',
|
||||||
|
)}
|
||||||
|
>
|
||||||
<nav className="p-4 space-y-1 mt-4">
|
<nav className="p-4 space-y-1 mt-4">
|
||||||
{/* Personal Settings */}
|
{/* Personal Settings */}
|
||||||
<div className="mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider">
|
<div className="mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider">
|
||||||
@@ -801,8 +806,13 @@ export function TeamSettingsPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Main Content Area */}
|
{/* Main Content Area */}
|
||||||
<main className="flex-1 bg-background/50 h-full flex flex-col transition-colors duration-300 overflow-y-hidden">
|
<main className="flex-1 min-h-0 min-w-0 bg-background/50 h-full flex flex-col transition-colors duration-300 overflow-y-hidden">
|
||||||
<div className="flex-1 flex flex-col max-w-4xl w-full mx-auto p-6 md:p-10 overflow-hidden">
|
<div
|
||||||
|
className={cn(
|
||||||
|
'flex-1 flex flex-col max-w-4xl w-full mx-auto p-6 md:p-10 overflow-hidden',
|
||||||
|
activeTab === 'providers' && 'p-4 md:p-10',
|
||||||
|
)}
|
||||||
|
>
|
||||||
<div className="flex-none flex items-center justify-between mb-6">
|
<div className="flex-none flex items-center justify-between mb-6">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-2xl font-bold text-foreground">
|
<h2 className="text-2xl font-bold text-foreground">
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||||
|
import * as fs from 'node:fs'
|
||||||
|
import * as path from 'node:path'
|
||||||
|
import { ApplicationFailure } from '../workflow-utils'
|
||||||
|
|
||||||
|
export function getErrorDetails(err: unknown): { code?: string; message: string; name?: string } {
|
||||||
|
if (err && typeof err === 'object') {
|
||||||
|
const record = err as Record<string, unknown>
|
||||||
|
return {
|
||||||
|
code: typeof record.code === 'string' ? record.code : undefined,
|
||||||
|
message:
|
||||||
|
typeof record.message === 'string'
|
||||||
|
? record.message
|
||||||
|
: err instanceof Error
|
||||||
|
? err.message
|
||||||
|
: String(err),
|
||||||
|
name: typeof record.name === 'string' ? record.name : undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
message: String(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function ensureLocalMediaFile(assetKey: string, filePath: string): Promise<string> {
|
||||||
|
if (fs.existsSync(filePath)) {
|
||||||
|
return filePath
|
||||||
|
}
|
||||||
|
const dir = path.dirname(filePath)
|
||||||
|
if (!fs.existsSync(dir)) {
|
||||||
|
fs.mkdirSync(dir, { recursive: true })
|
||||||
|
}
|
||||||
|
const bucket = process.env.S3_BUCKET || 'shumai'
|
||||||
|
try {
|
||||||
|
await s3Service.downloadToFile(bucket, assetKey, filePath)
|
||||||
|
} catch (err) {
|
||||||
|
const { code, message, name } = getErrorDetails(err)
|
||||||
|
const lowerMsg = message.toLowerCase()
|
||||||
|
const lowerCode = (code || '').toLowerCase()
|
||||||
|
const lowerName = (name || '').toLowerCase()
|
||||||
|
if (
|
||||||
|
lowerCode === 'enoent' ||
|
||||||
|
lowerCode === 'nosuchkey' ||
|
||||||
|
lowerName === 'nosuchkey' ||
|
||||||
|
lowerMsg.includes('enoent') ||
|
||||||
|
lowerMsg.includes('nosuchkey')
|
||||||
|
) {
|
||||||
|
throw ApplicationFailure.create({
|
||||||
|
message: `Failed to download media to local file: ${message}`,
|
||||||
|
nonRetryable: true,
|
||||||
|
cause: err instanceof Error ? err : undefined,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
return filePath
|
||||||
|
}
|
||||||
@@ -57,6 +57,7 @@ export function getDbosDatabaseUrl(rawUrl?: string): string {
|
|||||||
export function getQueueForTaskType(type: string | null | undefined): string {
|
export function getQueueForTaskType(type: string | null | undefined): string {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case WorkflowTaskType.ai_embedding:
|
case WorkflowTaskType.ai_embedding:
|
||||||
|
case WorkflowTaskType.ai_transcription:
|
||||||
case WorkflowTaskType.ai_metadata_autofill:
|
case WorkflowTaskType.ai_metadata_autofill:
|
||||||
case WorkflowTaskType.chat:
|
case WorkflowTaskType.chat:
|
||||||
return TaskQueueAgent
|
return TaskQueueAgent
|
||||||
|
|||||||
@@ -2,4 +2,5 @@ export * from './dbos-executor'
|
|||||||
export * from './workflow-utils'
|
export * from './workflow-utils'
|
||||||
export * from './workflow'
|
export * from './workflow'
|
||||||
export * from './activities/task'
|
export * from './activities/task'
|
||||||
|
export * from './activities/media'
|
||||||
export * from './local-task-storage'
|
export * from './local-task-storage'
|
||||||
|
|||||||
Reference in New Issue
Block a user