Compare commits

...
31 Commits
Author SHA1 Message Date
yiling 6e9cf8dfb6 Release v0.4.1 2026-08-30 20:26:57 +08:00
Yiling-J d2620f6911 fix(webui): prevent empty folder flash during initial loading (#367) 2026-08-30 18:43:23 +08:00
Yiling-J 4537baa6a2 feat(webui): redesign comment attachment display into compact rows (#366)
* feat(webui): redesign comment attachment display into compact rows

* feat(webui): support pure frontend image extension matching and self-contained preview dialog

* fix(webui): size image preview dialog to min(image size, 80% screen size)

* fix(webui): prevent horizontal overflow of comment attachment rows in scroll areas

* fix(webui): centralize attachment image preview ownership and localize download title
2026-08-30 17:16:20 +08:00
yiling 810e0c4cf5 fix(agent): only include duration_seconds for time-based media (video/audio) 2026-08-30 15:51:23 +08:00
yiling 07cb648183 fix(agent): use total_frames for video and total_pages for pdf in asset context 2026-08-30 15:44:59 +08:00
yiling c6602c9f1c docs(readme): add docker pulls, release, and license badges 2026-08-30 15:32:27 +08:00
Yiling-J 86032539ed feat(agent): refactor message context into unified shumai_message (#365)
* feat(agent): refactor message context into unified shumai_message

* fix(agent): persist custom_message entry type in DatabaseSessionStorage and handle message mapping defensively

* fix(agent): pass clean prompt to harness and replace optimistic messages on shumai_message stream

* fix(agent): align asset context DTO contract, sync comment attachments, and fix session stats
2026-08-30 15:25:13 +08:00
Yiling-J b2ec012e10 feat(webui): add manage versions option to file card context menu (#364) 2026-08-29 19:19:49 +08:00
Yiling-J 7fd8623684 fix(asset,webui): disallow dropping version stacks onto files and version stacks (#363)
* fix(asset,webui): disallow dropping version stacks onto files and version stacks

* fix(webui): derive isSingleFile from total drag selection and remove unused hasVersionStacks
2026-08-29 16:09:36 +08:00
Yiling-J 083753a96d refactor(agent): remove executeAgentToolWorkflow and invoke core services directly (#362)
* refactor(agent): remove executeAgentToolWorkflow and invoke core services directly

* fix(core): ensure creation atomicity, strict assetType filtering, and id-desc listing
2026-08-29 15:19:08 +08:00
yiling 4b62c31f29 Release v0.4.0 2026-08-28 20:40:33 +08:00
Yiling-J 2208d4e0e0 fix(webui): align mobile comment cards and thread vertical indicator (#361) 2026-08-28 20:26:26 +08:00
Yiling-J df7f4c3c2d Update README_CN with project management details
Added information about project management and media handling in Shumai.
2026-08-28 20:25:46 +08:00
Yiling-J 12323e1416 Enhance README with project management and media details
Added information about project management features and media processing in Shumai.
2026-08-28 20:23:38 +08:00
yiling 2edc5e1071 fix(e2e): enable ryuk container reaper for app e2e tests 2026-08-28 16:22:29 +08:00
Yiling-J 2162ed9ebe fix(webui): fix breadcrumb file dropdown trigger stretching and alignment (#360) 2026-08-28 16:07:27 +08:00
Yiling-J 6acebb73ec feat(webui): add mobile friendly file detail and public share view (#359)
* feat(webui): add mobile friendly file detail and public share view

* fix(webui): address review feedback for mobile file detail and public share view

* fix(webui): use dynamic viewport and flex column layout for mobile file viewer

* fix(webui): support iOS WebKit video fullscreen and guard requestFullscreen

* fix(webui): compact page indicator and layout in mobile PDF control bar
2026-08-28 15:11:33 +08:00
EICCIO Advisors 7a1d6c0ab5 docs: add SECURITY.md with a private disclosure path (#357)
The project has no security policy, so a researcher with a finding today has
only a public issue or Discord, both of which disclose before a fix exists.

Routes reports to GitHub private vulnerability reporting. Names deployment
manifests as in scope, since the documented quickstart is what most operators
actually run. Adds operator guidance for the three things a self-hoster owns:
the session secret, not publishing the database port, and treating the agent
as a code-execution surface.

Response timelines are left for the maintainer to set.
2026-08-28 09:21:21 +08:00
Yiling-J d16e31c0e5 feat(webui): add simplified mobile-friendly layout for file and share lists (#356)
* feat(webui): add simplified mobile-friendly layout for file and share lists

* refactor(webui): switch mobile file list layout to 1-column grid

* feat(webui): show foldertree by default in child sidebar and add close button

* feat(webui): add collapsible section headers and fix folder card full-width on mobile

* feat(webui): improve mobile breadcrumb bar with middle truncation and dual ellipsis

* fix(webui): unify breadcrumb DOM structure across desktop and mobile

* fix(webui): remove unused breadcrumbs variable in BreadcrumbNav

* fix(webui): complete and confirm file uploads on mobile and handle errors properly

* fix(webui): remove active scale animation on mobile FAB to stabilize dropdown menu anchor

* refactor(webui): use PresignedUrl type from dtos for uploadFiles and eliminate any cast

* fix(webui): scope folder card max width to desktop with responsive md:max-w-[340px]
2026-08-27 20:44:08 +08:00
Yiling-J d9a8b6a191 feat(webui): truncate long file names with 100ms hover tooltip (#355) 2026-08-27 10:54:35 +08:00
yiling 5ec4cd7fcd docs: update documentation link in README and README_CN 2026-08-26 21:44:50 +08:00
Yiling-J a7925e3c79 fix(share): hide and soft-delete symlinks when target assets are trashed (#354) 2026-08-26 21:04:38 +08:00
Yiling-J 472b420620 fix(transcode): apply team hardware acceleration and source bitrate capping to watermark transcoding (#353) 2026-08-26 17:00:11 +08:00
Yiling-J 8f55ba1d37 feat(transcode): add hardware-accelerated video transcoding support (#352)
* feat(transcode): add hardware-accelerated video transcoding support

* feat(transcode): use encoder quality modes and source-capped maxrate for video transcode

* fix(transcode): scale max bitrate for downsampled preview framerates

* fix(transcode): propagate videoBitRate in getMediaInfoActivity and update auto description
2026-08-26 16:28:14 +08:00
yiling 7b1428bf51 Release v0.3.11 2026-08-25 22:05:47 +08:00
yiling d5b3b1868e fix(webui): reload video player and reset state when switching videos in viewer 2026-08-25 21:52:15 +08:00
yiling 49f3fc0be5 fix(webui): restore full width bottom bar spanning across carousel in file viewer 2026-08-25 21:27:20 +08:00
Yiling-J 59e641ccb3 fix(webui): prevent left carousel remounting and scroll jump on file selection (#351) 2026-08-25 21:01:51 +08:00
Yiling-J 1d9268b224 feat(project): add recent viewed files section to project folder tree (#348)
* feat(project): add recent viewed files section to project folder tree

* feat(webui): disable toolbar buttons and context menu in recents page

* test(core): optimize recents cap test execution time

* feat(webui): show hint text in recents page top toolbar

* feat(webui): rename recents section to Recently Viewed

* refactor(core): consolidate recents methods into AssetService

* fix(api): forward pagination parameters in folder children endpoint (#349)

* fix(project-recents): scope views and disable recents mutations

* fix(api): allow recent views in demo mode

* fix(api): limit demo recent view exception to post
2026-08-25 18:51:24 +08:00
Yiling-J 470a4bd6f7 feat(auth): add admin password reset CLI command and reset password web UI (#347)
* feat(auth): add admin password reset CLI command and reset password web UI

* fix(auth): invalidate previous reset tokens and use AsyncLocalStorage for link capture
2026-08-25 14:35:33 +08:00
yiling 8801d59b2e docs: symlink CLAUDE.md to AGENTS.md 2026-08-25 09:50:54 +08:00
253 changed files with 17088 additions and 3195 deletions
+1
View File
@@ -11,6 +11,7 @@ data/
*.db
*.diff
*.orig
code_quality.md
.agents
# Playwright
Symlink
+1
View File
@@ -0,0 +1 @@
AGENTS.md
+5
View File
@@ -80,6 +80,11 @@ USER root
COPY scripts/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Expose "bun index.js" as "shumai" CLI command (and alias "shuami")
RUN printf '#!/bin/sh\nexec bun /app/index.js "$@"\n' > /usr/local/bin/shumai \
&& chmod +x /usr/local/bin/shumai \
&& ln -s /usr/local/bin/shumai /usr/local/bin/shuami
ENTRYPOINT ["docker-entrypoint.sh"]
# Default command: run migrations and start API server
+13 -1
View File
@@ -9,7 +9,13 @@
</p>
<p align="center">
<a target="_blank" href="https://shumai.one/">Website</a> | <a target="_blank" href="https://docs.shumai.one/introduction">Docs</a> | <a target="_blank" href="https://staging.shumai.one">Demo</a> | <a target="_blank" href="https://discord.gg/sUzhujK6DD">Discord</a> | <a target="_blank" href="README_CN.md">中文</a>
<a href="https://hub.docker.com/r/shumaione/shumai"><img alt="Docker pulls" src="https://img.shields.io/docker/pulls/shumaione/shumai" /></a>
<a href="https://github.com/shumaiOne/shumai/releases"><img alt="GitHub latest release" src="https://img.shields.io/github/v/release/shumaiOne/shumai" /></a>
<a href="LICENSE"><img alt="License" src="https://img.shields.io/badge/license-MIT-blue" /></a>
</p>
<p align="center">
<a target="_blank" href="https://shumai.one/">Website</a> | <a target="_blank" href="https://docs.shumai.one/getting-started/overview">Docs</a> | <a target="_blank" href="https://staging.shumai.one">Demo</a> | <a target="_blank" href="https://discord.gg/sUzhujK6DD">Discord</a> | <a target="_blank" href="README_CN.md">中文</a>
</p>
![Shumai App Screenshot](docs/screenshot.webp)
@@ -45,6 +51,12 @@ Here is a short demo video showing what the Shumai agent can do:
https://github.com/user-attachments/assets/1186067a-72c0-41b9-836f-987438f2332a
Shumai also brings project management into the creative workflow. A built-in Kanban board helps teams organize tasks, track progress, and collaborate in one place.
The ultimate goal is an **agentic Kanban**, where agents and team members can work together on tasks. This is still a **work in progress**: you can already create tasks for AI agents, but agents cannot act on those tasks yet.
<img width="2880" height="2160" alt="localhost_3000_teams_01M0HQR3EEBS0B46K4FK39X2C8_kanban(1080p-2) (1)" src="https://github.com/user-attachments/assets/cd0648d0-c69a-4398-958b-8d15a33378b0" />
> [!NOTE]
+13 -1
View File
@@ -9,8 +9,13 @@
</p>
<p align="center">
<a target="_blank" href="https://shumai.one/">官方网站</a> | <a target="_blank" href="https://docs.shumai.one/introduction">文档</a> | <a target="_blank" href="https://staging.shumai.one">在线演示</a> | <a target="_blank" href="README.md">English</a>
<a href="https://hub.docker.com/r/shumaione/shumai"><img alt="Docker pulls" src="https://img.shields.io/docker/pulls/shumaione/shumai" /></a>
<a href="https://github.com/shumaiOne/shumai/releases"><img alt="GitHub latest release" src="https://img.shields.io/github/v/release/shumaiOne/shumai" /></a>
<a href="LICENSE"><img alt="License" src="https://img.shields.io/badge/license-MIT-blue" /></a>
</p>
<p align="center">
<a target="_blank" href="https://shumai.one/">官方网站</a> | <a target="_blank" href="https://docs.shumai.one/getting-started/overview">文档</a> | <a target="_blank" href="https://staging.shumai.one">在线演示</a> | <a target="_blank" href="README.md">English</a>
</p>
![Shumai 应用截图](docs/screenshot.webp)
@@ -44,6 +49,13 @@ Shumai 是一个开源的 Frame.io 替代方案,专为创意团队打造,让
https://github.com/user-attachments/assets/1186067a-72c0-41b9-836f-987438f2332a
Shumai 也将项目管理融入了创意工作流程。 内置的看板可以帮助团队整理任务以及跟踪进度。
最终目标是打造一个 Agentic看板,让 Agent 和团队成员能够围绕同一个目标协同工作。目前这一功能仍在开发中: 你已经可以在看板中为 Agent 创建任务,但 Agent 目前还无法自动执行这些任务。
<img width="2880" height="2160" alt="localhost_3000_teams_01M0HQR3EEBS0B46K4FK39X2C8_kanban(1080p-2) (1)" src="https://github.com/user-attachments/assets/29ff1db1-2d65-4e3c-b467-754b777b406f" />
> [!NOTE]
> **媒体处理与存储机制:** 上传媒体文件后,Shumai 始终会保留并存储原始文件。请注意,系统中显示的文件大小为原始文件的大小,不包含转码后生成的代理文件大小。无论图片还是视频,都会额外生成一张 300p 的 WebP 封面图,作为文件列表中的预览图。此外:
>
+58
View File
@@ -0,0 +1,58 @@
# Security Policy
## Reporting a Vulnerability
Please report security vulnerabilities **privately**. Do not open a public issue,
pull request or Discord message for a suspected vulnerability, as that discloses it
to everyone before a fix exists.
Use **[GitHub private vulnerability reporting](https://github.com/shumaiOne/shumai/security/advisories/new)**
(the "Report a vulnerability" button on the Security tab). If that is unavailable,
contact the maintainer directly rather than in a public channel.
Please include:
- What the issue is, and the impact you believe it has
- The version or commit you tested (`git rev-parse HEAD`, or the image digest)
- Steps to reproduce, ideally minimal
- Your deployment shape: storage backend, whether the agent feature is enabled,
and whether the instance is internet-reachable
## Supported Versions
Shumai is pre-1.0 and moves quickly. Security fixes are made against the **latest
release**. Users are encouraged to track releases rather than pin indefinitely.
## Scope
**In scope** — the application, its API, the shipped Docker images, and the
deployment manifests under `docker-compose/`.
Deployment manifests are explicitly in scope. A default that is unsafe when
followed as documented is a real finding, because the documented quickstart is what
most operators actually run.
**Out of scope**
- Vulnerabilities in third-party dependencies, unless Shumai's use of them is what
creates the exposure. Report those upstream.
- Findings that require an already-compromised host or database.
- Configurations that deviate from the documented deployment.
## Operator guidance
Shumai is self-hosted, so several controls belong to the operator rather than to the
project:
- **Set `BETTER_AUTH_SECRET` per deployment.** It signs sessions and, in local
storage mode, upload URLs. Never reuse a value from documentation or an example.
- **Do not expose the instance to the public internet without a reverse proxy**
terminating TLS and applying your own access policy.
- **Do not publish the database port.** Set a real database password.
- **Treat the agent feature as a code-execution surface.** If you enable it, run it
where a compromise is survivable, and review the sandbox network policy.
## Disclosure
Please allow a reasonable period for a fix before public disclosure. The maintainer
will acknowledge reports and keep reporters informed of progress.
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/agent-app",
"version": "0.3.10",
"version": "0.4.1",
"private": true,
"type": "module",
"bin": {
-1
View File
@@ -1,5 +1,4 @@
export * from '@shumai/agent/src/workflows/agent-autofill'
export * from '@shumai/agent/src/workflows/agent-chat'
export * from '@shumai/agent/src/workflows/agent-embedding'
export * from '@shumai/agent/src/workflows/agent-tool-call'
export * from '@shumai/agent/src/workflows/query-embedding-for-search'
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/cli",
"version": "0.3.10",
"version": "0.4.1",
"private": true,
"type": "module",
"bin": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/transcode-app",
"version": "0.3.10",
"version": "0.4.1",
"private": true,
"type": "module",
"bin": {
+3
View File
@@ -56,6 +56,8 @@ apps/web/e2e/
|---|---|
| Sign up as the first user and become the team owner | `tests/auth/signup.spec.ts` |
| Log in with existing credentials | `tests/auth/login.spec.ts` |
| Show error when accessing reset-password page without token | `tests/auth/reset-password.spec.ts` |
| Reset password with valid token and allow logging in with new password | `tests/auth/reset-password.spec.ts` |
### team
| Test | File |
@@ -91,6 +93,7 @@ apps/web/e2e/
| Owner saves a search result as a collection | `tests/project/save-search-collection.spec.ts` |
| Image share with watermark + download disabled: no download buttons on public list/detail pages, watermarked proxy served, download-url rejected | `tests/project/share-watermark-no-download.spec.ts` |
| Video share with watermark + download disabled: no download buttons on public list/detail pages, watermarked proxy served, download-url rejected | `tests/project/share-watermark-no-download.spec.ts` |
| Owner views a file and it appears in recents | `tests/project/recents.spec.ts` |
### file
| Test | File |
+6 -5
View File
@@ -7,15 +7,16 @@ interface CreateShareResponse {
}
/**
* Locates a file/folder card by its name. File names are rendered as
* `EditableText` inputs (not text nodes), so `getByText` does not match them.
* The returned locator points at the card wrapper div (right-clickable to open
* the card context menu).
* Locates a file/folder card by its name. Matches both read-only text nodes
* and active EditableText inputs. The returned locator points at the card
* wrapper div (right-clickable to open the card context menu).
*/
export function fileCard(page: Page, name: string): Locator {
return page
.locator('div.group')
.filter({ has: page.locator(`input[value="${name}"]`) })
.filter({
has: page.locator(`input[value="${name}"]`).or(page.getByText(name, { exact: true })),
})
.first()
}
-1
View File
@@ -7,7 +7,6 @@ import { fileURLToPath } from 'url'
const currentDir = path.dirname(fileURLToPath(import.meta.url))
async function start() {
process.env.TESTCONTAINERS_RYUK_DISABLED = 'true'
console.log('Starting E2E test database container...')
await globalTestSetup()
@@ -0,0 +1,63 @@
import { expect, test } from '../../fixtures'
import { apiSignup, E2E_PASSWORD, uniqueEmail } from '../../helpers/auth'
import { loginViaUi } from '../../helpers/ui'
test('should show error when accessing reset-password page without token', async ({ page }) => {
await page.goto('/reset-password')
await expect(page.getByText('Invalid or missing reset token.')).toBeVisible()
await expect(page.getByRole('button', { name: 'Go to Login' })).toBeVisible()
})
test('should reset password with valid token and allow logging in with new password', async ({
page,
request,
prisma,
}) => {
const email = uniqueEmail('reset-pw')
const oldPassword = E2E_PASSWORD
const newPassword = 'newSecretPassword123'
// 1. Seed user
await apiSignup(request, email, oldPassword)
// 2. Request password reset via API
const resetRes = await request.post('/api/auth/request-password-reset', {
data: {
email,
redirectTo: '/reset-password',
},
})
expect(resetRes.ok()).toBe(true)
// Retrieve the generated verification token from DB
const verification = await prisma.verification.findFirst({
where: {
identifier: { startsWith: 'reset-password:' },
},
orderBy: { createdAt: 'desc' },
})
expect(verification).not.toBeNull()
const token = verification!.identifier.replace('reset-password:', '')
// 3. Open reset password page with token
await page.goto(`/reset-password?token=${token}`)
// 4. Fill in new password and confirmation
await page.locator('input#password').fill(newPassword)
await page.locator('input#confirmPassword').fill(newPassword)
// 5. Submit form
await page.getByRole('button', { name: 'Reset Password' }).click()
// 6. Verify success state
await expect(page.getByText('Password reset successfully!')).toBeVisible()
// 7. Click Go to Login
await page.getByRole('button', { name: 'Go to Login' }).click()
await expect(page).toHaveURL('/login')
// 8. Log in with the new password
await loginViaUi(page, email, newPassword)
await expect(page).toHaveURL(/\/teams\/[^/]+/)
await expect(page.getByRole('heading', { name: 'Projects' })).toBeVisible()
})
@@ -0,0 +1,35 @@
import { expect, test } from '../../fixtures'
import { fileCard } from '../../helpers/files'
test('owner views a file and it appears in recents', async ({ file }) => {
const { page, projectId, fileName, fileId } = file
// Open the file details page to record view
await page.goto(`/projects/${projectId}/files/${fileId}`)
await expect(page.getByText(fileName).first()).toBeVisible()
// Navigate to Recents page via sidebar or direct URL
await page.goto(`/projects/${projectId}`)
await page.getByText('Recently Viewed').first().click()
await expect(page).toHaveURL(new RegExp(`/projects/${projectId}/recents`))
// The viewed file should be visible in recents
const card = fileCard(page, fileName)
await expect(card).toBeVisible()
// Toolbar should show hint text instead of action buttons
await expect(
page.getByText('This page displays the 100 most recent files you viewed in this project.'),
).toBeVisible()
await expect(page.getByRole('button', { name: 'Field' })).not.toBeVisible()
await expect(page.getByRole('button', { name: 'Search' })).not.toBeVisible()
await expect(page.getByText('AGENTS.md')).not.toBeVisible()
// Right-clicking the file should NOT show the context menu
await card.click({ button: 'right' })
await expect(page.getByRole('menuitem', { name: 'Delete' })).not.toBeVisible()
await expect(page.getByRole('menuitem', { name: 'Download' })).not.toBeVisible()
// The per-item overflow menu must also be unavailable on the read-only Recents page.
await expect(card.getByRole('button')).toHaveCount(0)
})
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/web-app",
"version": "0.3.10",
"version": "0.4.1",
"private": true,
"type": "module",
"dependencies": {
+25
View File
@@ -13,12 +13,37 @@ import { initTranscodeWorkflows } from '@shumai/transcode'
import { workflowService } from '@shumai/workflow-core'
import { handleDaemonCommands } from '@shumai/core/src/utils/daemon'
import { authService } from '@shumai/core/src/auth/auth'
if (process.argv.includes('--check')) {
console.log('✅ Web app evaluated successfully!')
process.exit(0)
}
const cliArgs = process.argv.slice(2)
const resetCmdIndex = cliArgs.findIndex(
(arg) => arg === 'reset-password' || arg === 'reset-passowrd',
)
if (resetCmdIndex !== -1) {
const email = cliArgs[resetCmdIndex + 1]
if (!email || email.startsWith('-')) {
console.error('Error: Please provide a valid email address.')
console.error('Usage: shumai reset-password <email>')
process.exit(1)
}
try {
const link = await authService.generatePasswordResetLink(email)
console.log(link)
process.exit(0)
} catch (err: unknown) {
const message = err instanceof Error ? err.message : 'Unknown error'
console.error(`Error: ${message}`)
process.exit(1)
}
}
async function run() {
// Initialize workflows and activities for local executor mode
initAgentWorkflows()
-49
View File
@@ -1,49 +0,0 @@
# Code Quality Review: Quota Usage Dashboard
## Context
The change moves quota usage monitoring from the settings rule-card dialog to an owner-only dashboard section, adds collapsible rule/record display, and adds an audited manual record reset operation.
## Review
### Correctness
- The reset service validates team ownership, scope mode, membership, role filters, and selected-member membership.
- Reset and first-use record creation are serialized with a quota-rule row lock.
- Reset starts a new window at the current time and clears consumption.
- API and service tests cover shared records, member records, invalid targets, cross-team access, request validation, and audit logging.
- The application E2E test covers the settings/dashboard flow and verifies the persisted reset.
### Readability and architecture
- Business logic remains in `QuotaService`; the API only validates, authorizes, invokes the service, and maps the audit action.
- The dashboard owns usage presentation, while quota formatting metadata is shared between dashboard and settings.
- The removed usage dialog and obsolete translation messages are not referenced after the refactor.
### Security
- The reset endpoint retains owner-level team authorization.
- Request input is validated with Zod.
- SQL uses Prisma tagged-template parameters and does not interpolate raw user input.
### Performance
- Usage records are queried only after a rule is expanded.
- Expanded rules refresh every ten seconds, matching the previous usage dialog behavior.
- Quota rules retain the existing bounded list endpoint and descending ID ordering.
## Verification
- `bun run lint` passed.
- `bun run format` passed.
- `bun run typecheck` passed.
- `bun run test` passed: 124 files, 1190 tests.
- Quota API/core tests passed: 2 files, 30 tests.
- Quota application E2E passed.
- WebUI harness E2E passed: 9 tests.
- Workflow E2E passed: 14 files, 58 tests.
- `git diff --check` passed.
## Verdict
Approve. No critical or required findings remain.
+5 -1
View File
@@ -52,7 +52,11 @@
},
{
"group": "Team Settings",
"pages": ["using-shumai/transcode-settings", "using-shumai/quotas-settings"]
"pages": [
"using-shumai/transcode-settings",
"using-shumai/quotas-settings",
"using-shumai/password-reset"
]
},
{
"group": "Configuration",
+60
View File
@@ -0,0 +1,60 @@
---
title: Password Reset
description: How administrators generate secure password reset links for team members.
---
Because Shumai does not require an external email delivery service (SMTP) to be configured for standard self-hosted deployments, password resets are initiated securely by an administrator using the Shumai CLI.
---
## Overview
When a user forgets their password, an administrator can generate a one-time password reset link directly from the command line.
- **Link Expiration**: The generated password reset link is valid for **1 hour** (`3600 seconds`).
- **One-Time Use**: Once used, the token is permanently invalidated.
- **Session Revocation**: When a user resets their password, all existing active sessions for that account are automatically revoked across all devices.
- **Latest Link Validity**: Generating a new reset link for a user immediately supersedes any previously generated pending links.
---
## Generating a Password Reset Link
### Running on Local Host / Server
Run the `reset-password` subcommand from your Shumai installation directory:
```bash
shumai reset-password <user-email>
```
_(Alternatively, `bun apps/web/src/index.ts reset-password <user-email>`)_
**Example Output:**
```text
http://localhost:3000/reset-password?token=bb3xg4uO3cwN0FQv4cgUK6Hh
```
### Running inside Docker
If Shumai is running inside a Docker container, execute the command using `docker exec`:
```bash
docker exec -it <container-name-or-id> shumai reset-password <user-email>
```
> [!TIP]
> Both `shumai` and the common alias `shuami` (e.g. `shuami reset-password <user-email>`) are supported.
> [!NOTE]
> For remote servers or production deployments, ensure `BETTER_AUTH_URL` is set in your environment (e.g., `BETTER_AUTH_URL=https://shumai.example.com`) so the CLI generates the reset link with your public domain instead of `localhost`.
---
## Member Reset Experience
1. The administrator sends the generated URL to the team member via their preferred secure communication channel.
2. The user opens the link in their browser.
3. The user inputs their **New Password** and **Confirm Password** (minimum 3 characters).
4. Upon clicking **Reset Password**, the password is securely updated, all previous active sessions are invalidated, and the user is redirected to `/login` to sign in.
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "shumai",
"version": "0.3.10",
"version": "0.4.1",
"private": true,
"type": "module",
"repository": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/agent",
"version": "0.3.10",
"version": "0.4.1",
"private": true,
"type": "module",
"main": "./src/index.ts",
+42 -562
View File
@@ -13,8 +13,8 @@ import {
getCommentActivity,
getProjectAutofillFieldsActivity,
updateAssetMetadataActivity,
getAssetPathHierarchyActivity,
getAssetPathContextActivity,
executeAgentToolActivity,
generateSessionNameActivity,
type GenerateSessionNameParams,
getUserTeamInfoActivity,
@@ -36,8 +36,6 @@ import {
type Asset,
} from '@shumai/db'
import { setupTestDbHooks } from '@shumai/db/test'
import { authzService } from '@shumai/core/src/authz/authz'
import { uploadService } from '@shumai/core/src/upload/upload'
vi.mock('../index', async () => {
const actual = await vi.importActual('../index')
@@ -567,8 +565,18 @@ describe('Agent Database Activities Integration', () => {
describe('initializeAgentSessionActivity', () => {
it('should initialize a session, create agent/user records if missing, and store existing comments context', async () => {
const attAsset = await prisma.asset.create({
data: {
name: 'attached-doc.pdf',
type: AssetType.file,
mediaType: 'application/pdf',
status: AssetStatus.uploaded,
projectId: project.id,
},
})
// Create first comment so it acts as context
await prisma.assetComment.create({
const firstComment = await prisma.assetComment.create({
data: {
assetId: asset.id,
message: 'Hello <@' + user.id + '> check this',
@@ -576,6 +584,13 @@ describe('Agent Database Activities Integration', () => {
},
})
await prisma.assetCommentAttachment.create({
data: {
commentId: firstComment.id,
assetId: attAsset.id,
},
})
await sleep(2)
// Create second comment that user responds with, triggering session initialization
const userComment = await prisma.assetComment.create({
@@ -614,9 +629,20 @@ describe('Agent Database Activities Integration', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- entry data is stored as Json in DB and needs casting to check properties
const parsedEntry = pathEntries[0] as any
expect(parsedEntry.message.content[0].text).toContain(
`[${user.name} (owner)]: Hello <@${user.name}> check this`,
)
expect(parsedEntry.type).toBe('custom_message')
expect(parsedEntry.customType).toBe('shumai_message')
expect(parsedEntry.content).toContain(`Hello <@${user.name}> check this`)
expect(parsedEntry.details.user.name).toBe(user.name)
expect(parsedEntry.details.user.role).toBe('owner')
expect(parsedEntry.details.attachedFiles).toEqual([
{
id: attAsset.id,
name: 'attached-doc.pdf',
type: 'file',
mediaType: undefined,
mimeType: 'application/pdf',
},
])
})
it('should distinguish Main Session (userCommentId: null) and Thread Session (userCommentId: rootId) during lazy sync', async () => {
@@ -730,7 +756,7 @@ describe('Agent Database Activities Integration', () => {
const msg3Entry = pathEntries.find((e) => e.id.includes(msg3.id))
expect(msg3Entry).toBeDefined()
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const text = (msg3Entry as any).message.content[0].text
const text = (msg3Entry as any).content ?? (msg3Entry as any).message?.content[0]?.text
expect(text).toContain(`[Thread ID: ${msg3.id}] [Replies: 1]`)
})
@@ -1343,10 +1369,14 @@ describe('Agent Database Activities Integration', () => {
})
const pathCtx = await getAssetPathContextActivity(targetAsset.id)
expect(pathCtx).toContain('Path: RootFolder/SubFolder/TargetImage.webp')
expect(pathCtx).toContain(`name: RootFolder, id: ${rootFolder.id}`)
expect(pathCtx).toContain(`name: SubFolder, id: ${subfolder.id}`)
expect(pathCtx).toContain(`name: TargetImage.webp, id: ${targetAsset.id}`)
expect(pathCtx).toBe('RootFolder/SubFolder/TargetImage.webp')
const hierarchy = await getAssetPathHierarchyActivity(targetAsset.id)
expect(hierarchy.path).toBe('RootFolder/SubFolder/TargetImage.webp')
expect(hierarchy.ancestors).toEqual([
{ id: rootFolder.id, name: 'RootFolder' },
{ id: subfolder.id, name: 'SubFolder' },
])
})
})
@@ -1378,556 +1408,6 @@ describe('Agent Database Activities Integration', () => {
})
})
describe('executeAgentToolActivity', () => {
beforeEach(() => {
vi.spyOn(authzService, 'hasPermission').mockResolvedValue()
vi.spyOn(uploadService, 'triggerPostUploadWorkflows').mockResolvedValue()
})
describe('list_assets', () => {
it('should list assets inside a folder with cursor pagination', async () => {
const folder = await prisma.asset.create({
data: {
name: 'WorkspaceFolder',
type: AssetType.folder,
status: AssetStatus.uploaded,
projectId: project.id,
},
})
await prisma.asset.create({
data: {
name: 'file1.txt',
type: AssetType.file,
status: AssetStatus.uploaded,
projectId: project.id,
parentId: folder.id,
},
})
await prisma.asset.create({
data: {
name: 'subfolder1',
type: AssetType.folder,
status: AssetStatus.uploaded,
projectId: project.id,
parentId: folder.id,
},
})
const res = await executeAgentToolActivity({
taskId: 'task-1',
toolName: 'list_assets',
args: { parent: folder.id, page: 1, pageSize: 1 },
userId: user.id,
})
expect(res.assets.length).toBe(1)
expect(res.pageInfo.cursor).toBeDefined()
})
it('should resolve version_stack name and size from top child version when container name is empty', async () => {
const folder = await prisma.asset.create({
data: {
name: 'WorkspaceFolder',
type: AssetType.folder,
status: AssetStatus.uploaded,
projectId: project.id,
},
})
const versionStack = await prisma.asset.create({
data: {
name: '',
type: AssetType.version_stack,
status: AssetStatus.uploaded,
projectId: project.id,
parentId: folder.id,
},
})
await prisma.asset.create({
data: {
name: 'banana_ghost.txt',
type: AssetType.file,
status: AssetStatus.uploaded,
projectId: project.id,
parentId: versionStack.id,
sizeByte: 622960,
sortIndex: '0|i00000:',
},
})
const res = await executeAgentToolActivity({
taskId: 'task-1',
toolName: 'list_assets',
args: { parent: folder.id, page: 1, pageSize: 10 },
userId: user.id,
})
const stackItem = res.assets.find(
(a: { id: string; name: string; size: number; type: string }) => a.id === versionStack.id,
)
expect(stackItem).toBeDefined()
expect(stackItem?.name).toBe('banana_ghost.txt')
expect(stackItem?.size).toBe(622960)
expect(stackItem?.type).toBe('version_stack')
})
})
describe('create_folder', () => {
it('should create folder and increment parent fileCount', async () => {
const folder = await prisma.asset.create({
data: {
name: 'WorkspaceFolder',
type: AssetType.folder,
status: AssetStatus.uploaded,
projectId: project.id,
fileCount: 0,
},
})
const res = await executeAgentToolActivity({
taskId: 'task-1',
toolName: 'create_folder',
args: { parent: folder.id, name: 'subfolder' },
userId: user.id,
})
expect(res.name).toBe('subfolder')
expect(res.type).toBe('folder')
const parentFolder = await prisma.asset.findUnique({ where: { id: folder.id } })
expect(parentFolder?.fileCount).toBe(1)
})
})
describe('create_file', () => {
it('should create file, increment parent fileCount, and update parent sizes', async () => {
const folder = await prisma.asset.create({
data: {
name: 'WorkspaceFolder',
type: AssetType.folder,
status: AssetStatus.uploaded,
projectId: project.id,
fileCount: 0,
sizeByte: 0,
},
})
const res = await executeAgentToolActivity({
taskId: 'task-1',
toolName: 'create_file',
args: {
parent: folder.id,
s3Key: 'uploads/testfile.txt',
name: 'testfile.txt',
size: 500,
contentType: 'text/plain',
},
userId: user.id,
})
expect(res.name).toBe('testfile.txt')
expect(res.size).toBe(500)
const parentFolder = await prisma.asset.findUnique({ where: { id: folder.id } })
expect(parentFolder?.fileCount).toBe(1)
expect(Number(parentFolder?.sizeByte)).toBe(500)
expect(uploadService.triggerPostUploadWorkflows).toHaveBeenCalled()
})
it('should persist metadata on the created file when metadata map is provided', async () => {
await prisma.metadataField.create({
data: {
key: 'prompt',
scope: 'PROJECT',
projectId: project.id,
teamId: team.id,
config: { name: 'Prompt', type: 'text', autofillSource: 'CREATION_CONTEXT' },
},
})
const folder = await prisma.asset.create({
data: {
name: 'WorkspaceFolder',
type: AssetType.folder,
status: AssetStatus.uploaded,
projectId: project.id,
fileCount: 0,
sizeByte: 0,
},
})
const res = await executeAgentToolActivity({
taskId: 'task-1',
toolName: 'create_file',
args: {
parent: folder.id,
s3Key: 'uploads/ctx.txt',
name: 'ctx.txt',
size: 100,
contentType: 'text/plain',
metadata: { prompt: 'Generated using gemini' },
},
userId: user.id,
})
const val = await prisma.assetMetadataValue.findFirst({
where: { assetId: res.id, fieldKey: 'prompt' },
})
expect(val?.stringValue).toBe('Generated using gemini')
})
it('should persist select and selectMulti metadata with dynamic newOption', async () => {
const selectField = await prisma.metadataField.create({
data: {
key: 'provider',
scope: 'PROJECT',
project: { connect: { id: project.id } },
config: {
name: 'Provider',
type: 'select',
autofillSource: 'CREATION_CONTEXT',
select: { options: [{ id: 'openai', displayName: 'OpenAI', color: '#f43f5e' }] },
},
},
})
const multiField = await prisma.metadataField.create({
data: {
key: 'tags',
scope: 'PROJECT',
project: { connect: { id: project.id } },
config: {
name: 'Tags',
type: 'selectMulti',
autofillSource: 'CREATION_CONTEXT',
selectMulti: { options: [{ id: 'tag1', displayName: 'Tag 1', color: '#3b82f6' }] },
},
},
})
const folder = await prisma.asset.create({
data: {
name: 'WorkspaceFolder',
type: AssetType.folder,
status: AssetStatus.uploaded,
projectId: project.id,
fileCount: 0,
sizeByte: 0,
},
})
const res = await executeAgentToolActivity({
taskId: 'task-1',
toolName: 'create_file',
args: {
parent: folder.id,
s3Key: 'uploads/new_opt.txt',
name: 'new_opt.txt',
size: 100,
contentType: 'text/plain',
metadata: {
provider: { newOption: { value: 'Kling' } },
tags: ['tag1', { newOption: { value: 'Tag 2' } }],
},
},
userId: user.id,
})
// Verify select field
const providerVal = await prisma.assetMetadataValue.findFirst({
where: { assetId: res.id, fieldKey: selectField.key },
})
expect(providerVal?.stringValue).toBe('kling')
// Verify select field config was updated with new option
const updatedSelectField = await prisma.metadataField.findUnique({
where: { key: selectField.key },
})
const selectOpts =
(updatedSelectField?.config as PrismaJson.FieldConfig)?.select?.options || []
expect(selectOpts.some((o) => o.displayName === 'Kling' && o.id === 'kling')).toBe(true)
// Verify selectMulti field
const tagsVal = await prisma.assetMetadataValue.findFirst({
where: { assetId: res.id, fieldKey: multiField.key },
})
expect(tagsVal?.jsonValue).toEqual(['tag1', 'tag-2'])
// Verify selectMulti field config was updated with new option
const updatedMultiField = await prisma.metadataField.findUnique({
where: { key: multiField.key },
})
const multiOpts =
(updatedMultiField?.config as PrismaJson.FieldConfig)?.selectMulti?.options || []
expect(multiOpts.some((o) => o.displayName === 'Tag 2' && o.id === 'tag-2')).toBe(true)
})
it('should reject metadata with keys that are not valid in this project', async () => {
const folder = await prisma.asset.create({
data: {
name: 'WorkspaceFolder',
type: AssetType.folder,
status: AssetStatus.uploaded,
projectId: project.id,
fileCount: 0,
sizeByte: 0,
},
})
await expect(
executeAgentToolActivity({
taskId: 'task-1',
toolName: 'create_file',
args: {
parent: folder.id,
s3Key: 'uploads/ctx.txt',
name: 'ctx.txt',
size: 100,
contentType: 'text/plain',
metadata: { prompt: 'ok', unknownKey: 'not allowed' },
},
userId: user.id,
}),
).rejects.toThrow(/not valid in this project/)
// No metadata value should have been written for the unknown key
const val = await prisma.assetMetadataValue.findFirst({
where: { fieldKey: 'unknownKey' },
})
expect(val).toBeNull()
})
})
describe('create_version', () => {
it('should create a version stack when parent is a regular file', async () => {
const folder = await prisma.asset.create({
data: {
name: 'WorkspaceFolder',
type: AssetType.folder,
status: AssetStatus.uploaded,
projectId: project.id,
fileCount: 1,
sizeByte: 200,
},
})
const fileAsset = await prisma.asset.create({
data: {
name: 'v1.txt',
type: AssetType.file,
status: AssetStatus.uploaded,
projectId: project.id,
parentId: folder.id,
sizeByte: 200,
},
})
const res = await executeAgentToolActivity({
taskId: 'task-1',
toolName: 'create_version',
args: {
parent: fileAsset.id,
s3Key: 'uploads/v2.txt',
name: 'v2.txt',
size: 300,
contentType: 'text/plain',
},
userId: user.id,
})
expect(res.name).toBe('v2.txt')
expect(res.size).toBe(300)
// Check version stack was created
const stack = await prisma.asset.findFirst({
where: { type: AssetType.version_stack, projectId: project.id },
include: { children: true },
})
expect(stack).not.toBeNull()
expect(stack?.children.length).toBe(2) // v1.txt and v2.txt should both be inside the stack
})
it('should add to version stack when parent is already inside a version stack', async () => {
const folder = await prisma.asset.create({
data: {
name: 'WorkspaceFolder',
type: AssetType.folder,
status: AssetStatus.uploaded,
projectId: project.id,
},
})
const stack = await prisma.asset.create({
data: {
name: 'VersionStack',
type: AssetType.version_stack,
status: AssetStatus.uploaded,
projectId: project.id,
parentId: folder.id,
fileCount: 1,
sizeByte: 100,
},
})
const existingFileVersion = await prisma.asset.create({
data: {
name: 'v1.txt',
type: AssetType.file,
status: AssetStatus.uploaded,
projectId: project.id,
parentId: stack.id,
sizeByte: 100,
},
})
const res = await executeAgentToolActivity({
taskId: 'task-1',
toolName: 'create_version',
args: {
parent: existingFileVersion.id,
s3Key: 'uploads/v2.txt',
name: 'v2.txt',
size: 250,
contentType: 'text/plain',
},
userId: user.id,
})
expect(res.name).toBe('v2.txt')
const updatedStack = await prisma.asset.findUnique({
where: { id: stack.id },
include: { children: true },
})
expect(updatedStack?.fileCount).toBe(2)
expect(Number(updatedStack?.sizeByte)).toBe(350)
})
it('should persist metadata on the created version when metadata map is provided', async () => {
await prisma.metadataField.create({
data: {
key: 'prompt',
scope: 'PROJECT',
projectId: project.id,
teamId: team.id,
config: { name: 'Prompt', type: 'text', autofillSource: 'CREATION_CONTEXT' },
},
})
const folder = await prisma.asset.create({
data: {
name: 'WorkspaceFolder',
type: AssetType.folder,
status: AssetStatus.uploaded,
projectId: project.id,
fileCount: 1,
sizeByte: 200,
},
})
const fileAsset = await prisma.asset.create({
data: {
name: 'v1.txt',
type: AssetType.file,
status: AssetStatus.uploaded,
projectId: project.id,
parentId: folder.id,
sizeByte: 200,
},
})
const res = await executeAgentToolActivity({
taskId: 'task-1',
toolName: 'create_version',
args: {
parent: fileAsset.id,
s3Key: 'uploads/v2.txt',
name: 'v2.txt',
size: 300,
contentType: 'text/plain',
metadata: { prompt: 'Generated using seedance' },
},
userId: user.id,
})
const val = await prisma.assetMetadataValue.findFirst({
where: { assetId: res.id, fieldKey: 'prompt' },
})
expect(val?.stringValue).toBe('Generated using seedance')
})
it('should persist select and selectMulti newOption metadata in create_version', async () => {
const selectField = await prisma.metadataField.create({
data: {
key: 'versionProvider',
scope: 'PROJECT',
project: { connect: { id: project.id } },
config: {
name: 'Version Provider',
type: 'select',
autofillSource: 'CREATION_CONTEXT',
select: { options: [{ id: 'openai', displayName: 'OpenAI', color: '#f43f5e' }] },
},
},
})
const folder = await prisma.asset.create({
data: {
name: 'WorkspaceFolder',
type: AssetType.folder,
status: AssetStatus.uploaded,
projectId: project.id,
fileCount: 1,
sizeByte: 200,
},
})
const fileAsset = await prisma.asset.create({
data: {
name: 'v1.txt',
type: AssetType.file,
status: AssetStatus.uploaded,
projectId: project.id,
parentId: folder.id,
sizeByte: 200,
},
})
const res = await executeAgentToolActivity({
taskId: 'task-1',
toolName: 'create_version',
args: {
parent: fileAsset.id,
s3Key: 'uploads/v2.txt',
name: 'v2.txt',
size: 300,
contentType: 'text/plain',
metadata: {
versionProvider: { newOption: { value: 'Midjourney' } },
},
},
userId: user.id,
})
const val = await prisma.assetMetadataValue.findFirst({
where: { assetId: res.id, fieldKey: selectField.key },
})
expect(val?.stringValue).toBe('midjourney')
const updatedField = await prisma.metadataField.findUnique({
where: { key: selectField.key },
})
const opts = (updatedField?.config as PrismaJson.FieldConfig)?.select?.options || []
expect(opts.some((o) => o.displayName === 'Midjourney' && o.id === 'midjourney')).toBe(true)
})
})
})
describe('generateSessionNameActivity', () => {
it('should generate and save session name for chat sessions', async () => {
await prisma.team.create({
+129 -561
View File
@@ -1,29 +1,15 @@
import {
type AgentMessage,
type AgentTool,
type SessionTreeEntry,
} from '@earendil-works/pi-agent-core'
import { type AgentMessage, type AgentTool } from '@earendil-works/pi-agent-core'
import { type ImageContent } from '@earendil-works/pi-ai'
import { assetService } from '@shumai/core/src/asset/asset'
import {
authzService,
Permission,
ResourceType,
resolveEffectiveRole,
} from '@shumai/core/src/authz/authz'
import { resolveEffectiveRole } from '@shumai/core/src/authz/authz'
import { logger } from '@shumai/core/src/logger'
import { mcpService } from '@shumai/core/src/mcp/mcp-service'
import { metadataService } from '@shumai/core/src/metadata/metadata'
import { encodeCursor, paginateQuery } from '@shumai/core/src/pagination'
import { s3Service } from '@shumai/core/src/s3/s3'
import { uploadService } from '@shumai/core/src/upload/upload'
import { VersionStackService } from '@shumai/core/src/versionStack/versionStack'
import { getAgentRequiredLevel, getRoleLevel } from '@shumai/core/src/agent/permissions'
import { AssetType, prisma, Prisma, type Skill } from '@shumai/db'
import { registerLocalCancelHandler, unregisterLocalCancelHandler } from '@shumai/workflow-core'
import { ApplicationFailure, Context } from '@temporalio/activity'
import { generateKeyBetween } from 'jittered-fractional-indexing'
import { ulid } from 'ulid'
import { DatabaseSessionStorage } from '../database-session-storage'
import {
createAgentSession,
@@ -34,7 +20,11 @@ import {
import { aiUsageService } from '@shumai/core/src/ai-usage/ai-usage'
import { quotaService, QuotaExceededError } from '@shumai/core/src/quota/quota-service'
import { UpdateAssetMetadataRequest } from '@shumai/dtos'
import {
UpdateAssetMetadataRequest,
type ShumaiMessageContext,
type ShumaiMediaPosition,
} from '@shumai/dtos'
export interface Usage {
inputTokens: number
@@ -90,7 +80,7 @@ async function executeAgentPrompt(params: {
agentId: string
prompt: string
images: string[]
agentsInstruction: string
messageContext?: ShumaiMessageContext
sessionId?: string
userId?: string
projectId?: string
@@ -125,15 +115,15 @@ shumai has its own cloud file system. If a user asks you to perform file system
If you need to create files in the local filesystem (for example, a temporary file for uploading), only the '.pi' folder in the current directory has write permissions. Do NOT attempt to create files in any other directories.
When creating a file or version, you may attach metadata (for example, the AI model or prompt used to generate the asset). The allowed field keys and value types are declared directly in the 'metadata' parameter of the 'create_file' and 'create_version' tools.`
When creating a file or version, you may attach metadata (for example, the AI model or prompt used to generate the asset). The allowed field keys and value types are declared directly in the 'metadata' parameter of the 'create_file' and 'create_version' tools.
# Message Context & Tools
User messages may contain a <context> block detailing the user, active asset location, playback position, and attachments. Use the asset IDs from <context> when invoking tools (e.g. 'analyze_image', 'screenshot', 'read_pdf_pages', 'download_asset', 'list_assets'). When an <annotation /> tag is present, it indicates the user has drawn visual markups on the asset at the specified position.`
if (agent.soul) {
systemPrompt = `${systemPrompt}\n\nAgent Personality and Core Instructions:\n${agent.soul}`
}
// Note: params.agentsInstruction is no longer appended to systemPrompt here.
// Instead, it is persisted as a custom message session entry in the conversation history below.
let targetAssetId = params.assetId
if (!targetAssetId) {
if (params.userCommentId) {
@@ -264,32 +254,9 @@ When creating a file or version, you may attach metadata (for example, the AI mo
}
try {
if (params.agentsInstruction && params.agentsInstruction.trim()) {
const storage = session.getStorage()
const parentId = await storage.getLeafId()
await storage.appendEntry({
id: ulid(),
type: 'custom_message',
parentId,
timestamp: new Date().toISOString(),
customType: 'context',
content: params.agentsInstruction.trim(),
} as unknown as SessionTreeEntry)
}
if (params.attachedAssets && params.attachedAssets.length > 0) {
const storage = session.getStorage()
const parentId = await storage.getLeafId()
await storage.appendEntry({
id: ulid(),
type: 'custom',
parentId,
timestamp: new Date().toISOString(),
customType: 'context_display_info',
data: {
assets: params.attachedAssets,
},
} as unknown as SessionTreeEntry)
const storage = session.getStorage()
if (storage instanceof DatabaseSessionStorage && params.messageContext) {
storage.currentMessageContext = params.messageContext
}
let totalInputTokens = 0
@@ -423,7 +390,7 @@ When creating a file or version, you may attach metadata (for example, the AI mo
const sessionEntries = await session.getEntries()
sessionEntries.forEach((entry) => {
if (entry.type === 'message') {
if (entry.type === 'message' && entry.message) {
const msg = entry.message
if (msg.role === 'toolResult') {
const logMsg = { ...msg, content: undefined }
@@ -460,7 +427,6 @@ When creating a file or version, you may attach metadata (for example, the AI mo
cost: totalCost,
}
const storage = session.getStorage()
let sessionId = ''
if (storage instanceof DatabaseSessionStorage) {
sessionId = storage.sessionId
@@ -488,11 +454,11 @@ export interface AgentChatParams {
projectId: string
folderId: string
assetId?: string
agentsInstruction?: string
sessionId: string
userId?: string
userCommentId?: string | null
context: AgentExecutionContext
messageContext?: ShumaiMessageContext
attachedAssets?: Array<{ id: string; name: string; type: string }>
}
@@ -522,40 +488,19 @@ export async function agentChatActivity(params: AgentChatParams) {
const cleanMessage = params.message.replace(/<@[A-Z0-9]+>/g, '').trim()
const sessionId = params.sessionId
let prompt = cleanMessage
if (params.userCommentId) {
let targetUserId = params.userId
if (!targetUserId) {
const comment = await prisma.assetComment.findUnique({
where: { id: params.userCommentId },
select: { creatorId: true },
})
targetUserId = comment?.creatorId || undefined
}
if (targetUserId) {
const userInfo = await getUserTeamInfoActivity({
userId: targetUserId,
teamId: params.teamId,
})
if (userInfo) {
prompt = `[${userInfo.name} (${userInfo.role})]: ${cleanMessage}`
}
}
}
return executeAgentPrompt({
taskId: params.taskId,
teamId: params.teamId,
agentId: params.agentId,
prompt,
prompt: cleanMessage,
images: params.imageUrls,
agentsInstruction: params.agentsInstruction || '',
sessionId,
userId: params.userId,
projectId: params.projectId,
assetId: params.assetId || params.folderId,
userCommentId: params.userCommentId,
context: params.context,
messageContext: params.messageContext,
attachedAssets: params.attachedAssets,
})
}
@@ -597,7 +542,6 @@ export async function autofillAiActivity(params: AutofillAiParams) {
agentId: agent.id,
prompt: fullPrompt,
images: params.images,
agentsInstruction: '',
sessionId: undefined,
userId: undefined,
projectId: params.projectId,
@@ -720,7 +664,10 @@ export async function initializeAgentSessionActivity(params: {
createdAt: { lte: rootComment.createdAt },
},
orderBy: { id: 'asc' },
include: { creator: true },
include: {
creator: true,
attachments: { include: { asset: true } },
},
})
// 2. Fetch thread replies up to userComment.createdAt excluding userComment itself
@@ -732,7 +679,10 @@ export async function initializeAgentSessionActivity(params: {
id: { not: userComment.id },
},
orderBy: { id: 'asc' },
include: { creator: true },
include: {
creator: true,
attachments: { include: { asset: true } },
},
})
: []
@@ -782,7 +732,13 @@ export async function initializeAgentSessionActivity(params: {
}
}
function formatCommentMessage(c: (typeof allCommentsToSync)[0]): string {
const assetRecord = await prisma.asset.findUnique({
where: { id: userComment.assetId },
select: { media: true },
})
const proxyType = (assetRecord?.media as PrismaJson.MediaInfo | null)?.proxyType
function buildCommentEntry(c: (typeof allCommentsToSync)[0]) {
const isAgent = c.creator?.type === 'agent' || c.sessionId !== null
let messageContent = c.message || ''
@@ -792,13 +748,82 @@ export async function initializeAgentSessionActivity(params: {
})
if (isAgent) {
const agentName = c.creator?.name || 'Ai Agent'
return `[Agent Message][${agentName}]: ${messageContent}`
} else if (c.creator?.name) {
const message: AgentMessage = {
role: 'assistant',
content: [{ type: 'text', text: messageContent }],
api: 'custom',
provider: 'shumai',
model: 'agent',
usage: {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
totalTokens: 0,
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
},
stopReason: 'stop',
timestamp: c.createdAt.getTime(),
}
return {
type: 'message' as const,
data: { message },
}
}
let userObj: ShumaiMessageContext['user'] = undefined
if (c.creator) {
const role = (c.creatorId ? userRoleMap.get(c.creatorId) : undefined) || 'user'
return `[${c.creator.name} (${role})]: ${messageContent}`
userObj = {
id: c.creator.id,
name: c.creator.name || 'Unknown',
role,
}
}
let position: ShumaiMediaPosition | undefined = undefined
if (c.second !== null && c.second !== undefined) {
if (proxyType === 'pdf') {
position = { type: 'page', page: Math.round(c.second) }
} else {
position = { type: 'time', seconds: c.second }
}
}
const annotation = !!(c.annotation && Array.isArray(c.annotation) && c.annotation.length > 0)
const attachedFiles: ShumaiMessageContext['attachedFiles'] = []
if (c.attachments && c.attachments.length > 0) {
for (const att of c.attachments) {
if (att.asset) {
const attProxyType = (att.asset.media as PrismaJson.MediaInfo | null)?.proxyType
attachedFiles.push({
id: att.asset.id,
name: att.asset.name,
type: att.asset.type,
mediaType: attProxyType as 'image' | 'video' | 'pdf' | 'audio' | 'other' | undefined,
mimeType: att.asset.mediaType || undefined,
})
}
}
}
const commentDetails: ShumaiMessageContext = {
...(userObj ? { user: userObj } : {}),
...(position ? { position } : {}),
...(annotation ? { annotation: true } : {}),
...(attachedFiles.length > 0 ? { attachedFiles } : {}),
}
return {
type: 'custom_message' as const,
data: {
customType: 'shumai_message',
content: messageContent,
display: true,
details: commentDetails,
},
}
return messageContent
}
// 3. Sync top-level comments into agent_session_entries (DAG spine)
@@ -810,21 +835,16 @@ export async function initializeAgentSessionActivity(params: {
})
if (!existingEntry) {
const messageContent = formatCommentMessage(c)
const message: AgentMessage = {
role: 'user',
content: [{ type: 'text', text: messageContent }],
timestamp: c.createdAt.getTime(),
}
const entryData = buildCommentEntry(c)
await prisma.agentSessionEntry.create({
data: {
id: c.id,
sessionId: mainSession.id,
assetId: userComment.assetId,
type: 'message',
type: entryData.type,
parentId: mainPrevId,
createdAt: c.createdAt,
data: { message },
data: entryData.data as PrismaJson.PiSessionEntryData,
},
})
}
@@ -850,21 +870,16 @@ export async function initializeAgentSessionActivity(params: {
})
if (!existingReplyEntry) {
const messageContent = formatCommentMessage(reply)
const message: AgentMessage = {
role: 'user',
content: [{ type: 'text', text: messageContent }],
timestamp: reply.createdAt.getTime(),
}
const entryData = buildCommentEntry(reply)
await prisma.agentSessionEntry.create({
data: {
id: reply.id,
sessionId: session.id,
assetId: userComment.assetId,
type: 'message',
type: entryData.type,
parentId: lastReplyParentId,
createdAt: reply.createdAt,
data: { message },
data: entryData.data as PrismaJson.PiSessionEntryData,
},
})
}
@@ -1203,7 +1218,11 @@ export async function getAssetActivity(assetId: string) {
export async function getCommentActivity(commentId: string) {
return prisma.assetComment.findUnique({
where: { id: commentId },
include: { attachments: { include: { asset: { include: { storageKey: true } } } } },
include: {
attachments: {
include: { asset: { include: { storageKey: true } } },
},
},
})
}
@@ -1219,7 +1238,9 @@ export async function updateAssetMetadataActivity(params: {
return metadataService.updateAssetMetadata(params.assetId, params.metadata)
}
export async function getAssetPathContextActivity(assetId: string): Promise<string> {
export async function getAssetPathHierarchyActivity(
assetId: string,
): Promise<{ path: string; ancestors: Array<{ id: string; name: string }> }> {
const parts: { name: string; id: string }[] = []
let currentId: string | null = assetId
@@ -1238,469 +1259,16 @@ export async function getAssetPathContextActivity(assetId: string): Promise<stri
currentId = assetNode.parentId
}
if (parts.length === 0) return ''
if (parts.length === 0) return { path: '', ancestors: [] }
const pathStr = parts.map((p) => p.name).join('/')
let contextStr = `Path: ${pathStr}\n\n`
for (const part of parts) {
contextStr += `name: ${part.name}, id: ${part.id}\n`
}
return contextStr
const path = parts.map((p) => p.name).join('/')
const ancestors = parts.slice(0, -1)
return { path, ancestors }
}
export interface ExecuteAgentToolParams {
taskId: string
toolName: string
// args are dynamic JSON arguments passed from the agent harness at runtime
// eslint-disable-next-line @typescript-eslint/no-explicit-any
args: any
userId?: string
}
/**
* Validates that every metadata key provided by the agent is a defined
* CREATION_CONTEXT field of the project. Unknown keys are rejected with a
* non-retryable failure so Temporal does not retry expected validation errors.
*/
async function validateCreationContextMetadata(
userId: string,
projectId: string,
metadata: Record<string, unknown> | undefined,
): Promise<void> {
if (!metadata || Object.keys(metadata).length === 0) return
const fields = await metadataService.listProjectFields(userId, projectId)
const allowedKeys = new Set(
fields
.filter((f) => f.field.config?.autofillSource === 'CREATION_CONTEXT')
.map((f) => f.field.key),
)
const invalidKeys = Object.keys(metadata).filter((key) => !allowedKeys.has(key))
if (invalidKeys.length > 0) {
throw ApplicationFailure.create({
message:
`metadata contains keys that are not valid in this project: ${invalidKeys.join(', ')}. ` +
"The valid metadata fields are fixed to the current conversation's project. " +
'If the target folder or file belongs to a different project, call the tool WITHOUT the metadata parameter.',
nonRetryable: true,
})
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Activity return type is a union of tool result shapes
export async function executeAgentToolActivity(params: ExecuteAgentToolParams): Promise<any> {
const { toolName, args, userId } = params
if (!userId) {
throw ApplicationFailure.create({
message: 'User ID is required for tool authz',
nonRetryable: true,
})
}
// 1. Fetch User
const user = await prisma.user.findUnique({ where: { id: userId } })
if (!user) {
throw ApplicationFailure.create({
message: `User not found: ${userId}`,
nonRetryable: true,
})
}
// 2. Perform Authz and Action based on toolName
switch (toolName) {
case 'list_assets': {
const parent = args.parent
if (!parent) {
throw ApplicationFailure.create({
message: 'parent parameter is required',
nonRetryable: true,
})
}
// Authz check
await authzService.hasPermission({
user,
permission: Permission.Read,
type: ResourceType.Asset,
id: parent,
})
const page = args.page || 1
const pageSize = args.pageSize || 20
const type = args.type || 'all'
// We need to list files and folders of parent dir
const where: Prisma.AssetWhereInput = {
parentId: parent,
isDeleted: false,
}
if (type === 'file') {
where.type = { in: ['file', 'version_stack'] }
} else if (type === 'folder') {
where.type = 'folder'
} else {
where.type = { in: ['file', 'folder', 'version_stack'] }
}
const limit = pageSize
const offset = (page - 1) * limit
const after = offset > 0 ? encodeCursor(offset) : undefined
const { data: assets, pageInfo } = await paginateQuery<
Prisma.AssetGetPayload<Record<string, never>>
>(
async (skip, take) => {
return prisma.asset.findMany({
where,
orderBy: { id: 'desc' }, // sort desc per ULID default in sorting guidelines!
skip,
take,
})
},
async () => prisma.asset.count({ where }),
{ first: limit, after },
)
const stackIds = assets.filter((a) => a.type === AssetType.version_stack).map((a) => a.id)
const latestVersionsMap = new Map<string, Prisma.AssetGetPayload<Record<string, never>>>()
if (stackIds.length > 0) {
const versions = await prisma.asset.findMany({
where: { parentId: { in: stackIds }, isDeleted: false },
orderBy: { sortIndex: 'asc' },
})
for (const v of versions) {
if (!latestVersionsMap.has(v.parentId!)) {
latestVersionsMap.set(v.parentId!, v)
}
}
}
// return asset id, asset name, asset type, asset size (sizeByte or size)
const results = assets.map((a) => {
const latestVersion = latestVersionsMap.get(a.id)
return {
id: a.id,
name: a.type === AssetType.version_stack ? (latestVersion?.name ?? a.name) : a.name,
type: a.type,
size:
a.type === AssetType.version_stack && latestVersion
? Number(latestVersion.sizeByte)
: Number(a.sizeByte),
}
})
return {
assets: results,
pageInfo,
}
}
case 'create_folder': {
const parent = args.parent
const name = args.name
if (!parent || !name) {
throw ApplicationFailure.create({
message: 'parent and name parameters are required',
nonRetryable: true,
})
}
// Authz check
await authzService.hasPermission({
user,
permission: Permission.Edit,
type: ResourceType.Asset,
id: parent,
})
const newFolder = await assetService.createAsset({
name,
parentId: parent,
type: 'folder',
creatorId: userId,
})
return {
id: newFolder.id,
name: newFolder.name,
type: newFolder.type,
size: Number(newFolder.sizeByte),
}
}
case 'create_file': {
const parent = args.parent
const s3Key = args.s3Key as string
const name = args.name as string
const fileSize = args.size as number
const mimeType = args.contentType as string
const metadata =
typeof args.metadata === 'object' && args.metadata !== null
? (args.metadata as Record<string, unknown>)
: undefined
if (!parent || !s3Key || !name || fileSize === undefined || !mimeType) {
throw ApplicationFailure.create({
message: 'parent, s3Key, name, size, and contentType parameters are required',
nonRetryable: true,
})
}
// Authz check
await authzService.hasPermission({
user,
permission: Permission.Edit,
type: ResourceType.Asset,
id: parent,
})
// Fetch parent folder to resolve projectId and teamId
const parentAsset = await prisma.asset.findUnique({
where: { id: parent },
include: { project: true },
})
if (!parentAsset) {
throw ApplicationFailure.create({
message: `Parent folder not found with ID: ${parent}`,
nonRetryable: true,
})
}
if (!parentAsset.projectId || !parentAsset.project?.teamId) {
throw ApplicationFailure.create({
message: `Parent folder ${parent} has no project or team associated`,
nonRetryable: true,
})
}
// Validate that any provided metadata keys are defined CREATION_CONTEXT fields
await validateCreationContextMetadata(userId, parentAsset.projectId, metadata)
// Create asset via assetService
const newFile = await assetService.createAsset({
name,
type: 'file',
parentId: parent,
key: s3Key,
sizeByte: fileSize,
contentType: mimeType,
creatorId: userId,
})
// Increment update ancestor size
await prisma.$transaction(async (tx) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await assetService.updateAncestorsSize(tx as any, parent, fileSize)
// Persist creation context metadata provided by the agent
if (metadata) {
const metadataUpdates = Object.entries(metadata)
.filter(([, value]) => value !== null)
.map(([key, value]) => ({ key, value }))
if (metadataUpdates.length > 0) {
await metadataService.updateAssetMetadataInTx(tx, newFile.id, metadataUpdates)
}
}
// Trigger post-upload transcode and AI workflows
await uploadService.triggerPostUploadWorkflows(
tx,
newFile.id,
parentAsset.project!.teamId,
parentAsset.projectId!,
)
})
return {
id: newFile.id,
name: newFile.name,
type: newFile.type,
size: Number(newFile.sizeByte),
}
}
case 'create_version': {
const parent = args.parent // parent file id
const s3Key = args.s3Key as string
const name = args.name as string
const fileSize = args.size as number
const mimeType = args.contentType as string
const metadata =
typeof args.metadata === 'object' && args.metadata !== null
? (args.metadata as Record<string, unknown>)
: undefined
if (!parent || !s3Key || !name || fileSize === undefined || !mimeType) {
throw ApplicationFailure.create({
message: 'parent, s3Key, name, size, and contentType parameters are required',
nonRetryable: true,
})
}
// Fetch parent file and cast to any due to Prisma type resolution limits
/* prettier-ignore */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const parentFile = (await prisma.asset.findUnique({ where: { id: parent }, include: { parent: true, project: true } })) as any
if (!parentFile) {
throw ApplicationFailure.create({
message: `Parent file not found with ID: ${parent}`,
nonRetryable: true,
})
}
if (!parentFile.projectId || !parentFile.project?.teamId) {
throw ApplicationFailure.create({
message: `Parent file ${parent} has no project or team associated`,
nonRetryable: true,
})
}
// Validate that any provided metadata keys are defined CREATION_CONTEXT fields
await validateCreationContextMetadata(userId, parentFile.projectId, metadata)
// Authz check: verify Edit permission on the parent file (resource ID is parent file id)
await authzService.hasPermission({
user,
permission: Permission.Edit,
type: ResourceType.Asset,
id: parent,
})
// If already in a version stack
if (parentFile.parentId && parentFile.parent?.type === AssetType.version_stack) {
const stackId = parentFile.parentId
// Create the new file asset
const newFile = await assetService.createAsset({
name,
type: 'file',
parentId: stackId,
key: s3Key,
sizeByte: fileSize,
contentType: mimeType,
creatorId: userId,
})
// Generate sort index for new version inside the stack (newest gets the lowest sortIndex)
const firstChild = await prisma.asset.findFirst({
where: {
parentId: stackId,
NOT: { id: newFile.id },
},
orderBy: { sortIndex: 'asc' },
})
const newSortIndex = generateKeyBetween(null, firstChild?.sortIndex || null)
await prisma.$transaction(async (tx) => {
// Assign sort index
await tx.asset.update({
where: { id: newFile.id },
data: { sortIndex: newSortIndex },
})
// Persist creation context metadata provided by the agent
if (metadata) {
const metadataUpdates = Object.entries(metadata)
.filter(([, value]) => value !== null)
.map(([key, value]) => ({ key, value }))
if (metadataUpdates.length > 0) {
await metadataService.updateAssetMetadataInTx(tx, newFile.id, metadataUpdates)
}
}
// Increment stack's size (fileCount is incremented by createAsset already)
const updatedStack = await tx.asset.update({
where: { id: stackId },
data: {
sizeByte: { increment: fileSize },
},
})
// Update ancestors' size of stack's parent
if (updatedStack.parentId) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await assetService.updateAncestorsSize(tx as any, updatedStack.parentId, fileSize)
}
// Trigger post-upload transcode and AI workflows
await uploadService.triggerPostUploadWorkflows(
tx,
newFile.id,
parentFile.project.teamId,
parentFile.projectId,
)
})
return {
id: newFile.id,
name: newFile.name,
type: newFile.type,
size: Number(newFile.sizeByte),
}
} else {
// Parent is a regular file. We must create a new version stack.
const folderParentId = parentFile.parentId
if (!folderParentId) {
throw ApplicationFailure.create({
message: `Parent file ${parent} has no parent folder`,
nonRetryable: true,
})
}
// Create the new file asset under parent folder first (so that createVersionStack can run on them,
// which enforces both files must have same parent initially)
const newFile = await assetService.createAsset({
name,
type: 'file',
parentId: folderParentId,
key: s3Key,
sizeByte: fileSize,
contentType: mimeType,
creatorId: userId,
})
await prisma.$transaction(async (tx) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const txVersionStackService = new VersionStackService(tx as any)
await txVersionStackService.createVersionStack({
fileIds: [newFile.id, parentFile.id],
projectId: parentFile.projectId!,
creatorId: userId,
})
// Persist creation context metadata provided by the agent
if (metadata) {
const metadataUpdates = Object.entries(metadata)
.filter(([, value]) => value !== null)
.map(([key, value]) => ({ key, value }))
if (metadataUpdates.length > 0) {
await metadataService.updateAssetMetadataInTx(tx, newFile.id, metadataUpdates)
}
}
// Update ancestors' size (add size of the new file version)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await assetService.updateAncestorsSize(tx as any, folderParentId!, fileSize)
// Trigger post-upload transcode and AI workflows
await uploadService.triggerPostUploadWorkflows(
tx,
newFile.id,
parentFile.project.teamId,
parentFile.projectId!,
)
})
return {
id: newFile.id,
name: newFile.name,
type: newFile.type,
size: Number(newFile.sizeByte),
}
}
}
default:
throw ApplicationFailure.create({
message: `Unsupported tool name: ${toolName}`,
nonRetryable: true,
})
}
export async function getAssetPathContextActivity(assetId: string): Promise<string> {
const { path } = await getAssetPathHierarchyActivity(assetId)
return path
}
export interface GenerateSessionNameParams {
@@ -0,0 +1,315 @@
import { describe, it, expect } from 'vitest'
import { escapeXmlAttr, serializeContextToXml } from './serialize-context'
import type { ShumaiMessageContext } from '@shumai/dtos'
describe('serializeContextToXml', () => {
describe('escapeXmlAttr', () => {
it('escapes &, <, >, ", and \' characters correctly', () => {
expect(escapeXmlAttr('Alice & Bob <Admin> "v1" \'test\'')).toBe(
'Alice &amp; Bob &lt;Admin&gt; &quot;v1&quot; &apos;test&apos;',
)
})
it('handles clean strings without modification', () => {
expect(escapeXmlAttr('normal-string_123.mp4')).toBe('normal-string_123.mp4')
})
})
describe('Tag Serialization', () => {
it('returns empty string for null, undefined, or empty context', () => {
expect(serializeContextToXml(null)).toBe('')
expect(serializeContextToXml(undefined)).toBe('')
expect(serializeContextToXml({})).toBe('')
})
it('serializes minimal context with only user', () => {
const context: ShumaiMessageContext = {
user: { id: 'usr_1', name: 'Alice', role: 'editor' },
}
expect(serializeContextToXml(context)).toBe(
'<context>\n <user id="usr_1" name="Alice" role="editor" />\n</context>',
)
})
it('serializes minimal context with only currentAsset (without ancestors)', () => {
const context: ShumaiMessageContext = {
currentAsset: {
id: 'ast_1',
name: 'clip.mp4',
type: 'file',
mediaType: 'video',
path: 'clip.mp4',
},
}
expect(serializeContextToXml(context)).toBe(
'<context>\n <current_asset id="ast_1" name="clip.mp4" type="file" media_type="video" path="clip.mp4" />\n</context>',
)
})
it('serializes full video context with duration, timestamp, annotation, attached files, and referenced assets', () => {
const context: ShumaiMessageContext = {
user: { id: 'usr_01', name: 'Alice Chen', role: 'editor' },
currentAsset: {
id: 'ast_01JC04_CURRENT',
name: 'product_launch_v2.mp4',
type: 'file',
mediaType: 'video',
parentId: 'ast_01JC03_PARENT',
path: 'Marketing/2026_Launch/Footage/product_launch_v2.mp4',
durationSeconds: 85.4,
ancestors: [
{ id: 'ast_01JC01_ROOT', name: 'Marketing' },
{ id: 'ast_01JC02_SUB', name: '2026_Launch' },
{ id: 'ast_01JC03_PARENT', name: 'Footage' },
],
},
position: { type: 'time', seconds: 14.25 },
annotation: true,
attachedFiles: [
{
id: 'ast_01JC05_ATT1',
name: 'brand_guidelines_2026.pdf',
type: 'file',
mediaType: 'pdf',
path: 'Brand/brand_guidelines_2026.pdf',
},
],
referencedAssets: [
{
id: 'ast_01JC07_REF2',
name: 'Color_LUTs',
type: 'folder',
path: 'Assets/Color_LUTs',
},
{
id: 'ast_01JC06_REF1',
name: 'logo_white.png',
type: 'file',
mediaType: 'image',
path: 'Brand/Logos/logo_white.png',
},
],
}
const expected = `<context>
<user id="usr_01" name="Alice Chen" role="editor" />
<current_asset id="ast_01JC04_CURRENT" name="product_launch_v2.mp4" type="file" media_type="video" parent_id="ast_01JC03_PARENT" path="Marketing/2026_Launch/Footage/product_launch_v2.mp4" duration_seconds="85.40">
<ancestors>
<folder id="ast_01JC01_ROOT" name="Marketing" />
<folder id="ast_01JC02_SUB" name="2026_Launch" />
<folder id="ast_01JC03_PARENT" name="Footage" />
</ancestors>
</current_asset>
<position type="time" seconds="14.25" />
<annotation />
<attached_files>
<file id="ast_01JC05_ATT1" name="brand_guidelines_2026.pdf" type="file" media_type="pdf" path="Brand/brand_guidelines_2026.pdf" />
</attached_files>
<referenced_assets>
<asset id="ast_01JC06_REF1" name="logo_white.png" type="file" media_type="image" path="Brand/Logos/logo_white.png" />
<folder id="ast_01JC07_REF2" name="Color_LUTs" path="Assets/Color_LUTs" />
</referenced_assets>
</context>`
expect(serializeContextToXml(context)).toBe(expected)
})
it('serializes PDF document context with total_pages and position.type === "page"', () => {
const context: ShumaiMessageContext = {
currentAsset: {
id: 'pdf_1',
name: 'report.pdf',
type: 'file',
mediaType: 'pdf',
totalPages: 12,
},
position: { type: 'page', page: 3 },
}
const expected = `<context>
<current_asset id="pdf_1" name="report.pdf" type="file" media_type="pdf" total_pages="12" />
<position type="page" page="3" />
</context>`
expect(serializeContextToXml(context)).toBe(expected)
})
it('serializes Video context with total_frames and duration_seconds', () => {
const context: ShumaiMessageContext = {
currentAsset: {
id: 'vid_1',
name: 'clip.mp4',
type: 'file',
mediaType: 'video',
mimeType: 'video/mp4',
durationSeconds: 9,
totalFrames: 268,
},
}
const expected = `<context>
<current_asset id="vid_1" name="clip.mp4" type="file" media_type="video" mime_type="video/mp4" duration_seconds="9.00" total_frames="268" />
</context>`
expect(serializeContextToXml(context)).toBe(expected)
})
it('serializes navigation context with navigated="true" and ancestors hierarchy', () => {
const context: ShumaiMessageContext = {
currentAsset: {
id: 'f_sub',
name: 'Subfolder',
type: 'folder',
navigated: true,
ancestors: [{ id: 'f_root', name: 'Root' }],
},
}
const expected = `<context>
<current_asset id="f_sub" name="Subfolder" type="folder" navigated="true">
<ancestors>
<folder id="f_root" name="Root" />
</ancestors>
</current_asset>
</context>`
expect(serializeContextToXml(context)).toBe(expected)
})
it('serializes mime_type alongside media_type for current asset and attached files', () => {
const context: ShumaiMessageContext = {
currentAsset: {
id: 'img_1',
name: 'photo.png',
type: 'file',
mediaType: 'image',
mimeType: 'image/png',
},
attachedFiles: [
{
id: 'doc_1',
name: 'spec.pdf',
type: 'file',
mediaType: 'pdf',
mimeType: 'application/pdf',
},
],
}
const expected = `<context>
<current_asset id="img_1" name="photo.png" type="file" media_type="image" mime_type="image/png" />
<attached_files>
<file id="doc_1" name="spec.pdf" type="file" media_type="pdf" mime_type="application/pdf" />
</attached_files>
</context>`
expect(serializeContextToXml(context)).toBe(expected)
})
})
describe('XML Escaping & Security', () => {
it('escapes user names, asset names, and paths with special characters', () => {
const context: ShumaiMessageContext = {
user: {
id: 'u_1',
name: 'Alice & Bob <Admin>',
role: 'reviewer "lead"',
},
currentAsset: {
id: 'ast_1',
name: 'Final <Cut> "v2" & Test.mp4',
type: 'file',
path: 'Folder A > Folder B & C/clip.mp4',
ancestors: [{ id: 'anc_1', name: 'Folder B & C' }],
},
attachedFiles: [
{
id: 'att_1',
name: "Don't <Touch> & Go.pdf",
type: 'file',
path: "Path 'A' & 'B'/doc.pdf",
},
],
}
const xml = serializeContextToXml(context)
expect(xml).toContain('name="Alice &amp; Bob &lt;Admin&gt;"')
expect(xml).toContain('role="reviewer &quot;lead&quot;"')
expect(xml).toContain('name="Final &lt;Cut&gt; &quot;v2&quot; &amp; Test.mp4"')
expect(xml).toContain('path="Folder A &gt; Folder B &amp; C/clip.mp4"')
expect(xml).toContain('name="Folder B &amp; C"')
expect(xml).toContain('name="Don&apos;t &lt;Touch&gt; &amp; Go.pdf"')
expect(xml).toContain('path="Path &apos;A&apos; &amp; &apos;B&apos;/doc.pdf"')
// Verify no unescaped dangerous characters exist inside attribute quotes
const attrMatch = xml.match(/\w+="([^"]*)"/g)
expect(attrMatch).not.toBeNull()
})
})
describe('Order Stability & Prompt Caching Invariants', () => {
it('produces identical XML regardless of object key order', () => {
const contextA: ShumaiMessageContext = {
user: { role: 'editor', name: 'Alice', id: 'u_1' },
currentAsset: {
name: 'video.mp4',
type: 'file',
id: 'ast_1',
mediaType: 'video',
},
position: { seconds: 12.345, type: 'time' },
}
const contextB: ShumaiMessageContext = {
position: { type: 'time', seconds: 12.345 },
currentAsset: {
id: 'ast_1',
mediaType: 'video',
type: 'file',
name: 'video.mp4',
},
user: { id: 'u_1', name: 'Alice', role: 'editor' },
}
expect(serializeContextToXml(contextA)).toBe(serializeContextToXml(contextB))
})
it('sorts attachedFiles and referencedAssets by id ascending', () => {
const context: ShumaiMessageContext = {
attachedFiles: [
{ id: 'z_file', name: 'Z', type: 'file' },
{ id: 'a_file', name: 'A', type: 'file' },
{ id: 'm_file', name: 'M', type: 'file' },
],
referencedAssets: [
{ id: 'z_asset', name: 'Z', type: 'file' },
{ id: 'a_asset', name: 'A', type: 'folder' },
{ id: 'm_asset', name: 'M', type: 'file' },
],
}
const xml = serializeContextToXml(context)
const fileOrder = [...xml.matchAll(/<file id="([^"]+)"/g)].map((m) => m[1])
const refOrder = [...xml.matchAll(/<(?:asset|folder) id="([^"]+)"/g)].map((m) => m[1])
expect(fileOrder).toEqual(['a_file', 'm_file', 'z_file'])
expect(refOrder).toEqual(['a_asset', 'm_asset', 'z_asset'])
})
it('normalizes float formatting with fixed .toFixed(2)', () => {
const context1: ShumaiMessageContext = {
currentAsset: { id: '1', name: 'a', type: 'file', durationSeconds: 14 },
position: { type: 'time', seconds: 5.5 },
}
const context2: ShumaiMessageContext = {
currentAsset: { id: '1', name: 'a', type: 'file', durationSeconds: 14.0001 },
position: { type: 'time', seconds: 5.50002 },
}
expect(serializeContextToXml(context1)).toContain('duration_seconds="14.00"')
expect(serializeContextToXml(context1)).toContain('seconds="5.50"')
expect(serializeContextToXml(context2)).toContain('duration_seconds="14.00"')
expect(serializeContextToXml(context2)).toContain('seconds="5.50"')
})
})
})
@@ -0,0 +1 @@
export { escapeXmlAttr, serializeContextToXml } from '@shumai/dtos'
@@ -662,5 +662,85 @@ describe('DatabaseSessionStorage', () => {
expect(stats.totalTokens).toBe(170)
expect(stats.costTotal).toBeCloseTo(0.032)
})
it('should save user message turn as custom_message (shumai_message) in DB when currentMessageContext is set', async () => {
const { agent, user } = await setupTestData()
const storage = await DatabaseSessionStorage.create({ agentId: agent.id, userId: user.id })
storage.currentMessageContext = {
user: { id: user.id, name: user.name, role: 'owner' },
currentAsset: { id: 'asset-123', name: 'video.mp4', type: 'file' },
}
const userEntry: SessionTreeEntry = {
type: 'message',
id: 'msg-user-1',
parentId: null,
timestamp: new Date().toISOString(),
message: {
role: 'user',
content: 'Hello, help me analyze this video',
timestamp: Date.now(),
},
}
await storage.appendEntry(userEntry)
// 1. Verify DB record type is 'custom_message', not 'message'
const record = await prisma.agentSessionEntry.findUnique({
where: { id: 'msg-user-1' },
})
expect(record).toBeDefined()
expect(record?.type).toBe('custom_message')
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const data = record?.data as any
expect(data.customType).toBe('shumai_message')
expect(data.content).toBe('Hello, help me analyze this video')
expect(data.details?.user?.id).toBe(user.id)
expect(data.details?.currentAsset?.id).toBe('asset-123')
// 2. Verify getEntries() and getPathToRoot() do not throw and return proper custom_message
const entries = await storage.getEntries()
expect(entries).toHaveLength(1)
expect(entries[0].type).toBe('custom_message')
const pathEntries = await storage.getPathToRoot('msg-user-1')
expect(pathEntries).toHaveLength(1)
expect(pathEntries[0].type).toBe('custom_message')
const stats = await storage.getSessionStats()
expect(stats.messageCount).toBe(1)
})
it('should safely handle legacy records where type was message but data was shumai_message', async () => {
const { agent } = await setupTestData()
const storage = await DatabaseSessionStorage.create({ agentId: agent.id })
await prisma.agentSessionEntry.create({
data: {
id: 'legacy-corrupted-entry',
sessionId: storage.sessionId,
type: 'message',
data: {
customType: 'shumai_message',
content: 'Legacy prompt',
display: true,
details: { user: { id: 'u1', name: 'User 1' } },
},
},
})
// Must not throw in getEntries(), getPathToRoot(), or getSessionStats()
const entries = await storage.getEntries()
expect(entries).toHaveLength(1)
expect(entries[0].type).toBe('custom_message')
const path = await storage.getPathToRoot('legacy-corrupted-entry')
expect(path).toHaveLength(1)
expect(path[0].type).toBe('custom_message')
const stats = await storage.getSessionStats()
expect(stats.messageCount).toBe(1)
})
})
})
+75 -22
View File
@@ -72,6 +72,7 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
}
nextEntryId?: string | null
currentMessageContext?: PrismaJson.ShumaiMessageContext
async createEntryId(): Promise<string> {
if (this.nextEntryId) {
@@ -90,9 +91,13 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
data: unknown
}): SessionTreeEntry {
const payload = (record.data as Record<string, unknown>) || {}
let type = (record.type || 'message') as SessionTreeEntry['type']
if (type === 'message' && payload.customType === 'shumai_message') {
type = 'custom_message'
}
return {
id: record.id,
type: (record.type || 'message') as SessionTreeEntry['type'],
type,
parentId: record.parentId,
timestamp: record.createdAt.toISOString(),
...payload,
@@ -100,10 +105,41 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
}
async appendEntry(entry: SessionTreeEntry): Promise<void> {
const strippedEntry = structuredClone(entry)
let entryToProcess = entry
if (
entryToProcess.type === 'message' &&
entryToProcess.message &&
entryToProcess.message.role === 'user' &&
this.currentMessageContext
) {
let contentText = ''
if (typeof entryToProcess.message.content === 'string') {
contentText = entryToProcess.message.content
} else if (Array.isArray(entryToProcess.message.content)) {
contentText = entryToProcess.message.content
.map((c) =>
typeof c === 'object' && c && 'text' in c && typeof c.text === 'string' ? c.text : '',
)
.join('')
}
entryToProcess = {
type: 'custom_message',
id: entryToProcess.id,
parentId: entryToProcess.parentId,
timestamp: entryToProcess.timestamp,
customType: 'shumai_message',
content: contentText,
display: true,
details: this.currentMessageContext,
} as unknown as SessionTreeEntry
this.currentMessageContext = undefined
}
const strippedEntry = structuredClone(entryToProcess)
// Strip image data and skill content before saving to DB
if (strippedEntry.type === 'message') {
if (strippedEntry.type === 'message' && strippedEntry.message) {
const msg = strippedEntry.message
if (msg.role === 'toolResult') {
const details = msg.details as { sourceKeys?: string[]; skillId?: string } | undefined
@@ -139,7 +175,10 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
}
}
const targetLeafId = entry.type === 'leaf' ? entry.targetId : entry.id
const targetLeafId =
strippedEntry.type === 'leaf'
? (strippedEntry as unknown as { targetId?: string }).targetId || strippedEntry.id
: strippedEntry.id
// Extract base fields and store type-specific properties in data payload
const payload = { ...strippedEntry } as Record<string, unknown>
@@ -155,17 +194,18 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
await prisma.$transaction([
prisma.agentSessionEntry.upsert({
where: { id: entry.id },
where: { id: strippedEntry.id },
create: {
id: entry.id,
id: strippedEntry.id,
sessionId: this.sessionId,
assetId: session?.assetId || null,
type: entry.type,
parentId: entry.parentId || null,
createdAt: entry.timestamp ? new Date(entry.timestamp) : new Date(),
type: strippedEntry.type,
parentId: strippedEntry.parentId || null,
createdAt: strippedEntry.timestamp ? new Date(strippedEntry.timestamp) : new Date(),
data: payload as PrismaJson.PiSessionEntryData,
},
update: {
type: strippedEntry.type,
data: payload as PrismaJson.PiSessionEntryData,
},
}),
@@ -236,7 +276,9 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
let costTotal = 0
for (const entry of entries) {
if (entry.type === 'message') {
if (entry.type === 'custom_message' && entry.customType === 'shumai_message') {
messageCount++
} else if (entry.type === 'message' && entry.message) {
const msg = entry.message
if (msg.role === 'user' || msg.role === 'assistant') {
messageCount++
@@ -348,18 +390,29 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
for (let i = 0; i < pathEntries.length; i++) {
const entry = pathEntries[i]
const count = threadReplyCountMap.get(entry.id)
if (count !== undefined && count > 0 && entry.type === 'message') {
const cloned = structuredClone(entry)
const msg = cloned.message as unknown as {
content?: Array<{ type: string; text: string }>
}
if (Array.isArray(msg.content) && msg.content[0] && msg.content[0].type === 'text') {
const threadTag = `[Thread ID: ${entry.id}] [Replies: ${count}]`
if (!msg.content[0].text.includes(`[Thread ID: ${entry.id}]`)) {
msg.content[0].text = `${threadTag} ${msg.content[0].text}`
if (count !== undefined && count > 0) {
if (entry.type === 'message' && entry.message) {
const cloned = structuredClone(entry)
const msg = cloned.message as unknown as {
content?: Array<{ type: string; text: string }>
}
if (Array.isArray(msg.content) && msg.content[0] && msg.content[0].type === 'text') {
const threadTag = `[Thread ID: ${entry.id}] [Replies: ${count}]`
if (!msg.content[0].text.includes(`[Thread ID: ${entry.id}]`)) {
msg.content[0].text = `${threadTag} ${msg.content[0].text}`
}
}
pathEntries[i] = cloned
} else if (entry.type === 'custom_message') {
const cloned = structuredClone(entry)
const threadTag = `[Thread ID: ${entry.id}] [Replies: ${count}]`
if (typeof cloned.content === 'string') {
if (!cloned.content.includes(`[Thread ID: ${entry.id}]`)) {
cloned.content = `${threadTag} ${cloned.content}`
}
}
pathEntries[i] = cloned
}
pathEntries[i] = cloned
}
}
}
@@ -382,7 +435,7 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
}
private async reinjectImageDataAsync(entry: SessionTreeEntry) {
if (entry.type === 'message') {
if (entry.type === 'message' && entry.message) {
const msg = entry.message as AgentMessage
if (msg.role === 'toolResult') {
const details = msg.details as { sourceKeys?: string[] } | undefined
@@ -407,7 +460,7 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
}
private async reinjectSkillContentAsync(entry: SessionTreeEntry) {
if (entry.type === 'message') {
if (entry.type === 'message' && entry.message) {
const msg = entry.message as AgentMessage
if (msg.role === 'toolResult' && msg.toolName === 'read_skill') {
const details = msg.details as { skillId?: string } | undefined
+27 -3
View File
@@ -30,6 +30,8 @@ import { createReadSkillTool } from './tools/read-skill'
import { createReadThreadTool } from './tools/read-thread'
import { createSandboxedBashTool } from './tools/sandboxed-bash'
import { createScreenshotTool } from './tools/screenshot'
import { serializeContextToXml } from './context/serialize-context'
import type { ShumaiMessageContext } from '@shumai/dtos'
export interface DbModelInfo {
modelId: string
@@ -292,6 +294,7 @@ export async function createAgentSession(params: CreateAgentSessionParams) {
for (const entry of entries) {
if (
entry.type === 'message' &&
entry.message &&
entry.message.role === 'toolResult' &&
entry.message.toolName === 'read_skill' &&
!entry.message.isError
@@ -445,6 +448,29 @@ export async function createAgentSession(params: CreateAgentSessionParams) {
tools: enabledTools,
})
harness.on('context', async ({ messages }) => {
return {
messages: messages.map((msg) => {
if (
msg.role === 'custom' &&
msg.customType === 'shumai_message' &&
msg.details &&
typeof msg.details === 'object'
) {
const context = msg.details as ShumaiMessageContext
const xml = serializeContextToXml(context)
const text = typeof msg.content === 'string' ? msg.content : ''
const fullContent = xml ? `${text}\n\n${xml}`.trim() : text
return {
...msg,
content: fullContent,
}
}
return msg
}),
}
})
return { session, harness }
}
@@ -613,7 +639,6 @@ import * as aiActivities from './activities/ai'
import { agentAutofillMedia } from './workflows/agent-autofill'
import { agentChat } from './workflows/agent-chat'
import { agentEmbeddingMedia } from './workflows/agent-embedding'
import { agentToolCall } from './workflows/agent-tool-call'
import { queryEmbeddingForSearch } from './workflows/query-embedding-for-search'
export function initAgentWorkflows() {
@@ -621,7 +646,6 @@ export function initAgentWorkflows() {
registerWorkflow(WorkflowTaskType.query_embedding_for_search, queryEmbeddingForSearch)
registerWorkflow(WorkflowTaskType.ai_metadata_autofill, agentAutofillMedia)
registerWorkflow(WorkflowTaskType.chat, agentChat)
registerWorkflow(WorkflowTaskType.agent_tool_call, agentToolCall)
registerActivities(agentActivities)
registerActivities(aiActivities)
@@ -640,8 +664,8 @@ export {
type GenerateTextEmbeddingParams,
} from './activities/ai'
export * from './database-session-storage'
export * from './context/serialize-context'
export * from './workflows/agent-autofill'
export * from './workflows/agent-chat'
export * from './workflows/agent-embedding'
export * from './workflows/agent-tool-call'
export * from './workflows/query-embedding-for-search'
@@ -3,7 +3,8 @@ import { validateToolArguments } from '@earendil-works/pi-ai'
import { createCreateFileTool } from './tools/create-file'
import { fieldsToTypeBoxSchema } from './index'
import { s3Service } from '@shumai/core/src/s3/s3'
import { executeAgentToolWorkflow } from './tools/utils'
import { assetService } from '@shumai/core/src/asset/asset'
import { authzService } from '@shumai/core/src/authz/authz'
vi.mock('@shumai/core/src/s3/s3', () => ({
s3Service: {
@@ -12,8 +13,20 @@ vi.mock('@shumai/core/src/s3/s3', () => ({
},
}))
vi.mock('./tools/utils', () => ({
executeAgentToolWorkflow: vi.fn().mockResolvedValue({ id: 'file-1', name: 'test', type: 'file' }),
vi.mock('@shumai/core/src/authz/authz', () => ({
authzService: {
hasPermission: vi.fn().mockResolvedValue(undefined),
},
Permission: { Edit: 'edit', Read: 'read' },
ResourceType: { Asset: 'asset' },
}))
vi.mock('@shumai/core/src/asset/asset', () => ({
assetService: {
createFile: vi
.fn()
.mockResolvedValue({ id: 'file-1', name: 'test', type: 'file', sizeByte: 100 }),
},
}))
/**
@@ -63,9 +76,10 @@ describe('reproduce null coercion in harness tool validation', () => {
// execute must accept the valid call (data-only) without throwing
const result = await tool.execute('call-1', validated as never)
expect(result.details).toEqual({ id: 'file-1', name: 'test', type: 'file' })
expect(result.details).toEqual({ id: 'file-1', name: 'test', type: 'file', size: 100 })
expect(s3Service.putObject).toHaveBeenCalledTimes(1)
expect(executeAgentToolWorkflow).toHaveBeenCalledTimes(1)
expect(authzService.hasPermission).toHaveBeenCalledTimes(1)
expect(assetService.createFile).toHaveBeenCalledTimes(1)
})
it('keeps null metadata values (the "unknown" sentinel) through validation', () => {
+56 -46
View File
@@ -2,7 +2,8 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
import { createCreateFileTool } from './create-file'
import { fieldsToTypeBoxSchema } from '../index'
import { s3Service } from '@shumai/core/src/s3/s3'
import { executeAgentToolWorkflow } from './utils'
import { assetService } from '@shumai/core/src/asset/asset'
import { authzService } from '@shumai/core/src/authz/authz'
import { Value } from 'typebox/value'
import * as fs from 'fs'
import * as os from 'os'
@@ -15,8 +16,20 @@ vi.mock('@shumai/core/src/s3/s3', () => ({
},
}))
vi.mock('./utils', () => ({
executeAgentToolWorkflow: vi.fn().mockResolvedValue({ id: 'file-1', name: 'test', type: 'file' }),
vi.mock('@shumai/core/src/authz/authz', () => ({
authzService: {
hasPermission: vi.fn().mockResolvedValue(undefined),
},
Permission: { Edit: 'edit', Read: 'read' },
ResourceType: { Asset: 'asset' },
}))
vi.mock('@shumai/core/src/asset/asset', () => ({
assetService: {
createFile: vi
.fn()
.mockResolvedValue({ id: 'file-1', name: 'test', type: 'file', sizeByte: 100 }),
},
}))
describe('createCreateFileTool', () => {
@@ -56,23 +69,27 @@ describe('createCreateFileTool', () => {
expect(s3Key).toMatch(/^files\/.+\.md$/)
expect(uploadArgs[2]).toBe('text/markdown')
expect(executeAgentToolWorkflow).toHaveBeenCalledWith({
toolName: 'create_file',
args: {
parent: 'folder-1',
s3Key,
name: 'create-file-test.md',
size: Buffer.byteLength('# Hello from disk', 'utf-8'),
contentType: 'text/markdown',
},
userId: 'user-1',
assetId: 'folder-1',
expect(authzService.hasPermission).toHaveBeenCalledWith({
user: { id: 'user-1' },
permission: 'edit',
type: 'asset',
id: 'folder-1',
})
expect(result.details).toEqual({ id: 'file-1', name: 'test', type: 'file' })
expect(assetService.createFile).toHaveBeenCalledWith({
parentId: 'folder-1',
name: 'create-file-test.md',
key: s3Key,
sizeByte: Buffer.byteLength('# Hello from disk', 'utf-8'),
contentType: 'text/markdown',
creatorId: 'user-1',
metadata: undefined,
})
expect(result.details).toEqual({ id: 'file-1', name: 'test', type: 'file', size: 100 })
})
it('should forward the metadata to the agent tool workflow when provided', async () => {
it('should forward the metadata to assetService.createFile when provided', async () => {
const filePath = createTempFile('# Hello from disk', 'create-file-metadata.md')
const metadataSchema = fieldsToTypeBoxSchema([
{ id: 'prompt', config: { name: 'Prompt', type: 'text' } },
@@ -86,9 +103,9 @@ describe('createCreateFileTool', () => {
metadata: { prompt: 'Generated using gemini' },
})
expect(executeAgentToolWorkflow).toHaveBeenCalledWith(
expect(assetService.createFile).toHaveBeenCalledWith(
expect.objectContaining({
args: expect.objectContaining({ metadata: { prompt: 'Generated using gemini' } }),
metadata: { prompt: 'Generated using gemini' },
}),
)
})
@@ -125,19 +142,17 @@ describe('createCreateFileTool', () => {
},
})
expect(executeAgentToolWorkflow).toHaveBeenCalledWith(
expect(assetService.createFile).toHaveBeenCalledWith(
expect.objectContaining({
args: expect.objectContaining({
metadata: {
provider: { newOption: { value: 'Kling' } },
tags: ['tag1', { newOption: { value: 'Tag 2' } }],
},
}),
metadata: {
provider: { newOption: { value: 'Kling' } },
tags: ['tag1', { newOption: { value: 'Tag 2' } }],
},
}),
)
})
it('should not include metadata in args when metadata is null', async () => {
it('should not include metadata when metadata is null', async () => {
const filePath = createTempFile('# Hello from disk', 'create-file-no-metadata.md')
const metadataSchema = fieldsToTypeBoxSchema([
{ id: 'prompt', config: { name: 'Prompt', type: 'text' } },
@@ -151,8 +166,8 @@ describe('createCreateFileTool', () => {
metadata: null,
})
const callArgs = vi.mocked(executeAgentToolWorkflow).mock.calls[0][0].args
expect(callArgs).not.toHaveProperty('metadata')
const callArgs = vi.mocked(assetService.createFile).mock.calls[0][0]
expect(callArgs.metadata).toBeUndefined()
})
it('should throw when the local file does not exist', async () => {
@@ -161,7 +176,7 @@ describe('createCreateFileTool', () => {
tool.execute('call-1', { parent: 'folder-1', path: '/nonexistent/file.md', data: null }),
).rejects.toThrow('Local file not found at path: /nonexistent/file.md')
expect(s3Service.uploadFileToKey).not.toHaveBeenCalled()
expect(executeAgentToolWorkflow).not.toHaveBeenCalled()
expect(assetService.createFile).not.toHaveBeenCalled()
})
it('should create a file directly from name and content', async () => {
@@ -184,20 +199,17 @@ describe('createCreateFileTool', () => {
expect(size).toBe(Buffer.byteLength('# Notes\n\nHello', 'utf-8'))
expect(contentType).toBe('text/markdown')
expect(executeAgentToolWorkflow).toHaveBeenCalledWith({
toolName: 'create_file',
args: {
parent: 'folder-1',
s3Key,
name: 'notes.md',
size: Buffer.byteLength('# Notes\n\nHello', 'utf-8'),
contentType: 'text/markdown',
},
userId: 'user-1',
assetId: 'folder-1',
expect(assetService.createFile).toHaveBeenCalledWith({
parentId: 'folder-1',
name: 'notes.md',
key: s3Key,
sizeByte: Buffer.byteLength('# Notes\n\nHello', 'utf-8'),
contentType: 'text/markdown',
creatorId: 'user-1',
metadata: undefined,
})
expect(result.details).toEqual({ id: 'file-1', name: 'test', type: 'file' })
expect(result.details).toEqual({ id: 'file-1', name: 'test', type: 'file', size: 100 })
})
it('should default unknown extensions to text/plain when creating from content', async () => {
@@ -235,10 +247,8 @@ describe('createCreateFileTool', () => {
]
expect(s3Key).toContain('my_notes.md')
expect(executeAgentToolWorkflow).toHaveBeenCalledWith(
expect.objectContaining({
args: expect.objectContaining({ name: 'my_notes.md' }),
}),
expect(assetService.createFile).toHaveBeenCalledWith(
expect.objectContaining({ name: 'my_notes.md' }),
)
})
@@ -260,7 +270,7 @@ describe('createCreateFileTool', () => {
).rejects.toThrow('Provide exactly one of "path" (a local file) or "data" (name and content).')
expect(s3Service.uploadFileToKey).not.toHaveBeenCalled()
expect(s3Service.putObject).not.toHaveBeenCalled()
expect(executeAgentToolWorkflow).not.toHaveBeenCalled()
expect(assetService.createFile).not.toHaveBeenCalled()
})
it('should expose a strict, all-required (nullable) metadata schema when fields are provided', () => {
+26 -13
View File
@@ -1,12 +1,14 @@
import { type AgentTool } from '@earendil-works/pi-agent-core'
import { assetService } from '@shumai/core/src/asset/asset'
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
import { s3Service } from '@shumai/core/src/s3/s3'
import { getFileMimeType, readFileMimeType } from '@shumai/core/src/utils/file-mime'
import { sanitizeFilename } from '@shumai/core/src/utils/filename'
import { type User } from '@shumai/db'
import { Type, type TSchema } from 'typebox'
import * as fs from 'fs'
import * as path from 'path'
import { ulid } from 'ulid'
import { executeAgentToolWorkflow } from './utils'
interface CreateFileToolParams {
parent: string
@@ -105,19 +107,30 @@ export function createCreateFileTool(userId: string, metadataSchema?: TSchema):
await s3Service.putObject(process.env.S3_BUCKET || 'shumai', s3Key, content, size, mimeType)
}
const result = await executeAgentToolWorkflow({
toolName: 'create_file',
args: {
parent: p.parent,
s3Key,
name,
size,
contentType: mimeType,
...(p.metadata ? { metadata: p.metadata } : {}),
},
userId,
assetId: p.parent,
await authzService.hasPermission({
user: { id: userId } as User,
permission: Permission.Edit,
type: ResourceType.Asset,
id: p.parent,
})
const asset = await assetService.createFile({
parentId: p.parent,
name,
key: s3Key,
sizeByte: size,
contentType: mimeType,
creatorId: userId,
metadata: p.metadata ?? undefined,
})
const result = {
id: asset.id,
name: asset.name,
type: asset.type,
size: Number(asset.sizeByte),
}
return {
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
details: result,
@@ -0,0 +1,55 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { createCreateFolderTool } from './create-folder'
import { assetService } from '@shumai/core/src/asset/asset'
import { authzService } from '@shumai/core/src/authz/authz'
vi.mock('@shumai/core/src/authz/authz', () => ({
authzService: {
hasPermission: vi.fn().mockResolvedValue(undefined),
},
Permission: { Edit: 'edit', Read: 'read' },
ResourceType: { Asset: 'asset' },
}))
vi.mock('@shumai/core/src/asset/asset', () => ({
assetService: {
createAsset: vi.fn().mockResolvedValue({
id: 'folder-1',
name: 'New Folder',
type: 'folder',
sizeByte: 0,
}),
},
}))
describe('createCreateFolderTool', () => {
beforeEach(() => {
vi.clearAllMocks()
})
it('checks edit permission and calls assetService.createAsset with folder type', async () => {
const tool = createCreateFolderTool('user-1')
const result = await tool.execute('call-1', { parent: 'root-folder', name: 'New Folder' })
expect(authzService.hasPermission).toHaveBeenCalledWith({
user: { id: 'user-1' },
permission: 'edit',
type: 'asset',
id: 'root-folder',
})
expect(assetService.createAsset).toHaveBeenCalledWith({
name: 'New Folder',
parentId: 'root-folder',
type: 'folder',
creatorId: 'user-1',
})
expect(result.details).toEqual({
id: 'folder-1',
name: 'New Folder',
type: 'folder',
size: 0,
})
})
})
+23 -6
View File
@@ -1,6 +1,8 @@
import { Type } from 'typebox'
import { type AgentTool } from '@earendil-works/pi-agent-core'
import { executeAgentToolWorkflow } from './utils'
import { assetService } from '@shumai/core/src/asset/asset'
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
import { type User } from '@shumai/db'
const createFolderSchema = Type.Object({
parent: Type.String({
@@ -19,12 +21,27 @@ export function createCreateFolderTool(userId: string): AgentTool<typeof createF
description: 'Create a new folder in a specified parent folder.',
parameters: createFolderSchema,
execute: async (_toolCallId, params) => {
const result = await executeAgentToolWorkflow({
toolName: 'create_folder',
args: params,
userId,
assetId: params.parent,
await authzService.hasPermission({
user: { id: userId } as User,
permission: Permission.Edit,
type: ResourceType.Asset,
id: params.parent,
})
const newFolder = await assetService.createAsset({
name: params.name,
parentId: params.parent,
type: 'folder',
creatorId: userId,
})
const result = {
id: newFolder.id,
name: newFolder.name,
type: newFolder.type,
size: Number(newFolder.sizeByte),
}
return {
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
details: result,
+45 -30
View File
@@ -2,7 +2,8 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
import { createCreateVersionTool } from './create-version'
import { fieldsToTypeBoxSchema } from '../index'
import { s3Service } from '@shumai/core/src/s3/s3'
import { executeAgentToolWorkflow } from './utils'
import { assetService } from '@shumai/core/src/asset/asset'
import { authzService } from '@shumai/core/src/authz/authz'
import { Value } from 'typebox/value'
import * as fs from 'fs'
import * as os from 'os'
@@ -14,8 +15,20 @@ vi.mock('@shumai/core/src/s3/s3', () => ({
},
}))
vi.mock('./utils', () => ({
executeAgentToolWorkflow: vi.fn().mockResolvedValue({ id: 'file-1', name: 'v2', type: 'file' }),
vi.mock('@shumai/core/src/authz/authz', () => ({
authzService: {
hasPermission: vi.fn().mockResolvedValue(undefined),
},
Permission: { Edit: 'edit', Read: 'read' },
ResourceType: { Asset: 'asset' },
}))
vi.mock('@shumai/core/src/asset/asset', () => ({
assetService: {
createVersion: vi
.fn()
.mockResolvedValue({ id: 'file-1', name: 'v2', type: 'file', sizeByte: 100 }),
},
}))
describe('createCreateVersionTool', () => {
@@ -41,7 +54,7 @@ describe('createCreateVersionTool', () => {
return filePath
}
it('should upload a local file and create a version via the agent tool workflow', async () => {
it('should upload a local file and create a version via assetService.createVersion', async () => {
const filePath = createTempFile('# Hello from disk', 'create-version-test.md')
const tool = createCreateVersionTool('user-1')
@@ -53,23 +66,27 @@ describe('createCreateVersionTool', () => {
expect(s3Key).toMatch(/^files\/.+\.md$/)
expect(uploadArgs[2]).toBe('text/markdown')
expect(executeAgentToolWorkflow).toHaveBeenCalledWith({
toolName: 'create_version',
args: {
parent: 'file-1',
s3Key,
name: 'create-version-test.md',
size: Buffer.byteLength('# Hello from disk', 'utf-8'),
contentType: 'text/markdown',
},
userId: 'user-1',
assetId: 'file-1',
expect(authzService.hasPermission).toHaveBeenCalledWith({
user: { id: 'user-1' },
permission: 'edit',
type: 'asset',
id: 'file-1',
})
expect(result.details).toEqual({ id: 'file-1', name: 'v2', type: 'file' })
expect(assetService.createVersion).toHaveBeenCalledWith({
parentId: 'file-1',
name: 'create-version-test.md',
key: s3Key,
sizeByte: Buffer.byteLength('# Hello from disk', 'utf-8'),
contentType: 'text/markdown',
creatorId: 'user-1',
metadata: undefined,
})
expect(result.details).toEqual({ id: 'file-1', name: 'v2', type: 'file', size: 100 })
})
it('should forward the metadata to the agent tool workflow when provided', async () => {
it('should forward the metadata to assetService.createVersion when provided', async () => {
const filePath = createTempFile('# Hello from disk', 'create-version-metadata.md')
const metadataSchema = fieldsToTypeBoxSchema([
{ id: 'prompt', config: { name: 'Prompt', type: 'text' } },
@@ -82,9 +99,9 @@ describe('createCreateVersionTool', () => {
metadata: { prompt: 'Generated using gemini' },
})
expect(executeAgentToolWorkflow).toHaveBeenCalledWith(
expect(assetService.createVersion).toHaveBeenCalledWith(
expect.objectContaining({
args: expect.objectContaining({ metadata: { prompt: 'Generated using gemini' } }),
metadata: { prompt: 'Generated using gemini' },
}),
)
})
@@ -120,19 +137,17 @@ describe('createCreateVersionTool', () => {
},
})
expect(executeAgentToolWorkflow).toHaveBeenCalledWith(
expect(assetService.createVersion).toHaveBeenCalledWith(
expect.objectContaining({
args: expect.objectContaining({
metadata: {
provider: { newOption: { value: 'Kling' } },
tags: ['tag1', { newOption: { value: 'Tag 2' } }],
},
}),
metadata: {
provider: { newOption: { value: 'Kling' } },
tags: ['tag1', { newOption: { value: 'Tag 2' } }],
},
}),
)
})
it('should not include metadata in args when metadata is null', async () => {
it('should not include metadata when metadata is null', async () => {
const filePath = createTempFile('# Hello from disk', 'create-version-no-metadata.md')
const metadataSchema = fieldsToTypeBoxSchema([
{ id: 'prompt', config: { name: 'Prompt', type: 'text' } },
@@ -141,8 +156,8 @@ describe('createCreateVersionTool', () => {
const tool = createCreateVersionTool('user-1', metadataSchema)
await tool.execute('call-1', { parent: 'file-1', path: filePath, metadata: null })
const callArgs = vi.mocked(executeAgentToolWorkflow).mock.calls[0][0].args
expect(callArgs).not.toHaveProperty('metadata')
const callArgs = vi.mocked(assetService.createVersion).mock.calls[0][0]
expect(callArgs.metadata).toBeUndefined()
})
it('should throw when the local file does not exist', async () => {
@@ -151,7 +166,7 @@ describe('createCreateVersionTool', () => {
tool.execute('call-1', { parent: 'file-1', path: '/nonexistent/file.md' }),
).rejects.toThrow('Local file not found at path: /nonexistent/file.md')
expect(s3Service.uploadFileToKey).not.toHaveBeenCalled()
expect(executeAgentToolWorkflow).not.toHaveBeenCalled()
expect(assetService.createVersion).not.toHaveBeenCalled()
})
it('should expose a strict, all-required (nullable) metadata schema when fields are provided', () => {
+32 -18
View File
@@ -1,12 +1,14 @@
import { Type, type TSchema } from 'typebox'
import { type AgentTool } from '@earendil-works/pi-agent-core'
import { executeAgentToolWorkflow } from './utils'
import * as fs from 'fs'
import * as path from 'path'
import { assetService } from '@shumai/core/src/asset/asset'
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
import { s3Service } from '@shumai/core/src/s3/s3'
import { readFileMimeType } from '@shumai/core/src/utils/file-mime'
import { ulid } from 'ulid'
import { sanitizeFilename } from '@shumai/core/src/utils/filename'
import { type User } from '@shumai/db'
import { Type, type TSchema } from 'typebox'
import * as fs from 'fs'
import * as path from 'path'
import { ulid } from 'ulid'
interface CreateVersionToolParams {
parent: string
@@ -48,24 +50,36 @@ export function createCreateVersionTool(userId: string, metadataSchema?: TSchema
const fileSize = fs.statSync(absolutePath).size
const mimeType = readFileMimeType(absolutePath)
const name = path.basename(absolutePath)
// Generate compliant S3 key matching normal file upload format
const s3Key = `files/${ulid()}/${sanitizeFilename(path.basename(absolutePath))}`
const s3Key = `files/${ulid()}/${sanitizeFilename(name)}`
await s3Service.uploadFileToKey(absolutePath, s3Key, mimeType)
const result = await executeAgentToolWorkflow({
toolName: 'create_version',
args: {
parent: p.parent,
s3Key,
name: path.basename(absolutePath),
size: fileSize,
contentType: mimeType,
...(p.metadata ? { metadata: p.metadata } : {}),
},
userId,
assetId: p.parent,
await authzService.hasPermission({
user: { id: userId } as User,
permission: Permission.Edit,
type: ResourceType.Asset,
id: p.parent,
})
const asset = await assetService.createVersion({
parentId: p.parent,
name,
key: s3Key,
sizeByte: fileSize,
contentType: mimeType,
creatorId: userId,
metadata: p.metadata ?? undefined,
})
const result = {
id: asset.id,
name: asset.name,
type: asset.type,
size: Number(asset.sizeByte),
}
return {
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
details: result,
@@ -0,0 +1,78 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { createListAssetsTool } from './list-assets'
import { assetService } from '@shumai/core/src/asset/asset'
import { authzService } from '@shumai/core/src/authz/authz'
vi.mock('@shumai/core/src/authz/authz', () => ({
authzService: {
hasPermission: vi.fn().mockResolvedValue(undefined),
},
Permission: { Edit: 'edit', Read: 'read' },
ResourceType: { Asset: 'asset' },
}))
vi.mock('@shumai/core/src/asset/asset', () => ({
assetService: {
listChildren: vi.fn().mockResolvedValue({
data: [
{ id: '01M2FILE2', name: 'file2.txt', type: 'file', sizeByte: 200 },
{ id: '01M1FILE1', name: 'file1.txt', type: 'file', sizeByte: 100 },
],
pageInfo: { hasNextPage: false, hasPreviousPage: false, cursor: 'abc' },
}),
},
}))
describe('createListAssetsTool', () => {
beforeEach(() => {
vi.clearAllMocks()
})
it('checks read permissions and invokes assetService.listChildren with default all and id desc ordering', async () => {
const tool = createListAssetsTool('user-1')
const result = await tool.execute('call-1', { parent: 'folder-1' })
expect(authzService.hasPermission).toHaveBeenCalledWith({
user: { id: 'user-1' },
permission: 'read',
type: 'asset',
id: 'folder-1',
})
expect(assetService.listChildren).toHaveBeenCalledWith({
assetId: 'folder-1',
assetType: 'all',
sort: 'createdAt',
order: 'desc',
first: 20,
after: undefined,
})
expect(result.details).toEqual({
assets: [
{ id: '01M2FILE2', name: 'file2.txt', type: 'file', size: 200 },
{ id: '01M1FILE1', name: 'file1.txt', type: 'file', size: 100 },
],
pageInfo: { hasNextPage: false, hasPreviousPage: false, cursor: 'abc' },
})
})
it('passes explicit pagination and type filter options to assetService.listChildren', async () => {
const tool = createListAssetsTool('user-1')
await tool.execute('call-1', {
parent: 'folder-1',
page: 2,
pageSize: 10,
type: 'folder',
})
expect(assetService.listChildren).toHaveBeenCalledWith({
assetId: 'folder-1',
assetType: 'folder',
sort: 'createdAt',
order: 'desc',
first: 10,
after: expect.any(String),
})
})
})
+38 -10
View File
@@ -1,6 +1,9 @@
import { Type } from 'typebox'
import { type AgentTool } from '@earendil-works/pi-agent-core'
import { executeAgentToolWorkflow } from './utils'
import { assetService } from '@shumai/core/src/asset/asset'
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
import { encodeCursor } from '@shumai/core/src/pagination'
import { type User } from '@shumai/db'
const listAssetsSchema = Type.Object({
parent: Type.String({
@@ -19,9 +22,8 @@ const listAssetsSchema = Type.Object({
}),
),
type: Type.Optional(
Type.String({
Type.Union([Type.Literal('file'), Type.Literal('folder'), Type.Literal('all')], {
description: "Filter assets by type: 'file', 'folder', or 'all'. Default is 'all'.",
enum: ['file', 'folder', 'all'],
default: 'all',
}),
),
@@ -34,15 +36,41 @@ export function createListAssetsTool(userId: string): AgentTool<typeof listAsset
description: 'List the assets (files and folders) inside a parent folder with pagination.',
parameters: listAssetsSchema,
execute: async (_toolCallId, params) => {
const result = await executeAgentToolWorkflow({
toolName: 'list_assets',
args: params,
userId,
assetId: params.parent,
await authzService.hasPermission({
user: { id: userId } as User,
permission: Permission.Read,
type: ResourceType.Asset,
id: params.parent,
})
const page = params.page || 1
const pageSize = params.pageSize || 20
const type = params.type || 'all'
const result = await assetService.listChildren({
assetId: params.parent,
assetType: type,
sort: 'createdAt',
order: 'desc',
first: pageSize,
after: page > 1 ? encodeCursor((page - 1) * pageSize) : undefined,
})
const assets = result.data.map((a) => ({
id: a.id,
name: a.name,
type: a.type,
size: Number(a.sizeByte),
}))
const output = {
assets,
pageInfo: result.pageInfo,
}
return {
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
details: result,
content: [{ type: 'text', text: JSON.stringify(output, null, 2) }],
details: output,
}
},
}
-35
View File
@@ -1,35 +0,0 @@
import { prisma } from '@shumai/db'
import { workflowService } from '@shumai/workflow-core'
import { WorkflowTaskType, WorkflowTaskStatus } from '@shumai/db'
export async function executeAgentToolWorkflow(params: {
toolName: string
args: Record<string, unknown>
userId: string
assetId: string
}): Promise<unknown> {
const task = await prisma.workflowTask.create({
data: {
type: WorkflowTaskType.agent_tool_call,
status: WorkflowTaskStatus.pending,
assetId: params.assetId,
payload: {
projectId: 'none',
agentToolCall: {
toolName: params.toolName,
args: params.args,
userId: params.userId,
},
},
},
})
const completedTask = await workflowService.executeWait(task)
if (completedTask.status === WorkflowTaskStatus.failed) {
const output = completedTask.output as Record<string, unknown> | null
const errorMsg = (output?.error as string) || 'Workflow task failed'
throw new Error(errorMsg)
}
return completedTask.output
}
@@ -1,171 +0,0 @@
import { describe, it, expect } from 'vitest'
import { AgentChatPromptBuilder } from './agent-chat-prompt-builder'
describe('AgentChatPromptBuilder', () => {
it('should build prompt with baseline configurations', () => {
const builder = new AgentChatPromptBuilder('a1')
const result = builder.build()
expect(result).toContain('The user is discussing an asset with ID: a1.')
})
it('should build prompt with path context', () => {
const builder = new AgentChatPromptBuilder('a1').withPathContext('folder/sub/file.png')
const result = builder.build()
expect(result).toContain('Asset Path Context:\nfolder/sub/file.png')
})
it('should build prompt with image asset details', () => {
const builder = new AgentChatPromptBuilder('a1').withAssetDetails(
'test.png',
'image/png',
undefined,
undefined,
'image',
)
const result = builder.build()
expect(result).toContain('File Name: test.png')
expect(result).toContain('File Type: image')
expect(result).toContain("call the 'analyze_image' tool")
expect(result).not.toContain("call the 'screenshot' tool")
})
it('should build prompt with video asset details and duration', () => {
const builder = new AgentChatPromptBuilder('a1').withAssetDetails(
'movie.mp4',
'video/mp4',
12.34,
undefined,
'video',
)
const result = builder.build()
expect(result).toContain('File Name: movie.mp4')
expect(result).toContain('File Type: video')
expect(result).toContain('Video Length: 12.34 seconds')
expect(result).toContain("call the 'screenshot' tool")
expect(result).not.toContain("call the 'analyze_image' tool")
})
it('should build prompt with PDF asset details and total pages', () => {
const builder = new AgentChatPromptBuilder('a1').withAssetDetails(
'doc.pdf',
'application/pdf',
undefined,
15,
'pdf',
)
const result = builder.build()
expect(result).toContain('File Name: doc.pdf')
expect(result).toContain('File Type: pdf')
expect(result).toContain('Total Pages: 15')
expect(result).toContain("call the 'read_pdf_pages' tool")
expect(result).toContain('Maximum 20 pages allowed per call.')
expect(result).not.toContain("call the 'screenshot' tool")
expect(result).not.toContain("call the 'analyze_image' tool")
})
it('should build prompt with comment page for PDF asset', () => {
const builder = new AgentChatPromptBuilder('a1')
.withAssetDetails('doc.pdf', 'application/pdf', undefined, 10, 'pdf')
.withCommentTimestamp(3)
const result = builder.build()
expect(result).toContain('Comment Page: 3')
})
it('should build prompt for PDF continuation mode with comment page', () => {
const builder = new AgentChatPromptBuilder('a1')
.withContinuation(true)
.withAssetDetails('doc.pdf', 'application/pdf', undefined, 10, 'pdf')
.withCommentTimestamp(4)
const result = builder.build()
expect(result).toContain('Comment Page: 4')
expect(result).not.toContain('Comment Timestamp:')
})
it('should build prompt with comment timestamp', () => {
const builder = new AgentChatPromptBuilder('a1').withCommentTimestamp(5.5)
const result = builder.build()
expect(result).toContain('Comment Timestamp: 5.50 seconds')
})
it('should build prompt with all fields combined', () => {
const builder = new AgentChatPromptBuilder('a1')
.withPathContext('src/main.ts')
.withAssetDetails('movie.mp4', 'video/mp4', 12.34, undefined, 'video')
.withCommentTimestamp(8.2)
const result = builder.build()
expect(result).toContain('The user is discussing an asset with ID: a1.')
expect(result).toContain('File Name: movie.mp4')
expect(result).toContain('File Type: video')
expect(result).toContain('Video Length: 12.34 seconds')
expect(result).toContain('Comment Timestamp: 8.20 seconds')
expect(result).toContain('Asset Path Context:\nsrc/main.ts')
expect(result).toContain("call the 'screenshot' tool")
})
it('should build prompt with attached files and referenced assets', () => {
const builder = new AgentChatPromptBuilder('a1')
.withAttachedFiles(['- file1.txt', '- file2.png'])
.withReferencedAssets(['- folder1', '- file3.mp4'])
const result = builder.build()
expect(result).toContain('[Context: Attached Files & Referenced Assets]')
expect(result).toContain('Attached Files:\n- file1.txt\n- file2.png')
expect(result).toContain('Referenced Workspace Assets:\n- folder1\n- file3.mp4')
})
it('should build prompt for continuation mode returning only turn-specific modifications', () => {
const builder = new AgentChatPromptBuilder('a1')
.withContinuation(true)
.withAssetDetails('movie.mp4', 'video/mp4', 12.34)
.withPathContext('src/main.ts')
.withCommentTimestamp(8.2)
.withAttachedFiles(['- file1.txt'])
.withReferencedAssets(['- folder1'])
const result = builder.build()
expect(result).not.toContain('The user is discussing an asset with ID:')
expect(result).not.toContain('File Name: movie.mp4')
expect(result).not.toContain('Asset Path Context:')
expect(result).toContain('Comment Timestamp: 8.20 seconds')
expect(result).toContain('[Context: New Attached Files & Referenced Assets]')
expect(result).toContain('Attached Files:\n- file1.txt')
expect(result).toContain('Referenced Workspace Assets:\n- folder1')
})
it('should include location change context block in continuation mode when asset has changed', () => {
const builder = new AgentChatPromptBuilder('a2')
.withContinuation(true)
.withAssetChanged(true)
.withAssetDetails('new-folder', 'folder', undefined, undefined, 'folder')
.withPathContext('projects/my-proj/new-folder')
const result = builder.build()
expect(result).toContain('[Context: User Navigated to a New Location]')
expect(result).toContain('New Location Asset ID: a2')
expect(result).toContain('File Name: new-folder')
expect(result).toContain('Asset Path Context:\nprojects/my-proj/new-folder')
})
it('should build prompt with user info when provided and not continuation', () => {
const builder = new AgentChatPromptBuilder('a1').withUserInfo('Alice', 'owner')
const result = builder.build()
expect(result).toContain('User Info:\nName: Alice\nRole: owner')
})
it('should build prompt with download_asset tool instruction', () => {
const builder = new AgentChatPromptBuilder('a1')
const result = builder.build()
expect(result).toContain("call the 'download_asset' tool with assetId.")
})
})
@@ -1,185 +0,0 @@
export function getSimpleMediaType(proxyType?: string | null): 'image' | 'video' | 'pdf' | 'other' {
if (proxyType === 'image') return 'image'
if (proxyType === 'video') return 'video'
if (proxyType === 'pdf') return 'pdf'
return 'other'
}
export class AgentChatPromptBuilder {
private assetId: string
private assetName?: string
private mediaType?: string
private proxyType?: string
private videoDuration?: number
private totalPages?: number
private commentTimestamp?: number
private pathContext?: string
private attachedFiles: string[] = []
private referencedAssets: string[] = []
private userInfo?: { name: string; role: string }
private isContinuation = false
private hasAssetChanged = false
constructor(assetId: string) {
this.assetId = assetId
}
withUserInfo(name?: string, role?: string): this {
if (name) {
this.userInfo = { name, role: role || 'user' }
}
return this
}
withContinuation(isContinuation: boolean): this {
this.isContinuation = isContinuation
return this
}
withAssetChanged(hasAssetChanged?: boolean): this {
this.hasAssetChanged = !!hasAssetChanged
return this
}
withAttachedFiles(files?: string[]): this {
if (files) {
this.attachedFiles = files
}
return this
}
withReferencedAssets(assets?: string[]): this {
if (assets) {
this.referencedAssets = assets
}
return this
}
withPathContext(pathContext?: string): this {
this.pathContext = pathContext
return this
}
withAssetDetails(
name: string,
mediaType: string | null,
duration?: number,
totalPages?: number,
proxyType?: string | null,
): this {
this.assetName = name
this.mediaType = mediaType || undefined
this.proxyType = proxyType || undefined
this.videoDuration = duration
this.totalPages = totalPages
return this
}
withCommentTimestamp(second?: number | null): this {
if (second !== undefined && second !== null) {
this.commentTimestamp = second
}
return this
}
build(): string {
const effectiveType = this.proxyType
if (this.isContinuation) {
let instruction = ''
if (this.hasAssetChanged) {
instruction += `[Context: User Navigated to a New Location]\nNew Location Asset ID: ${this.assetId}`
if (this.assetName) {
instruction += `\nFile Name: ${this.assetName}`
}
if (effectiveType) {
const type = getSimpleMediaType(effectiveType)
instruction += `\nFile Type: ${type}`
if (type === 'video' && this.videoDuration !== undefined) {
instruction += `\nVideo Length: ${this.videoDuration.toFixed(2)} seconds`
} else if (type === 'pdf' && this.totalPages !== undefined) {
instruction += `\nTotal Pages: ${this.totalPages}`
}
}
if (this.pathContext) {
instruction += `\n\nAsset Path Context:\n${this.pathContext}`
}
}
if (this.commentTimestamp !== undefined) {
const type = getSimpleMediaType(effectiveType)
if (instruction) instruction += '\n\n'
if (type === 'pdf') {
instruction += `Comment Page: ${Math.round(this.commentTimestamp)}`
} else {
instruction += `Comment Timestamp: ${this.commentTimestamp.toFixed(2)} seconds`
}
}
if (this.attachedFiles.length > 0 || this.referencedAssets.length > 0) {
if (instruction) instruction += '\n\n'
instruction += `[Context: New Attached Files & Referenced Assets]`
if (this.attachedFiles.length > 0) {
instruction += `\nAttached Files:\n${this.attachedFiles.join('\n')}`
}
if (this.referencedAssets.length > 0) {
instruction += `\nReferenced Workspace Assets:\n${this.referencedAssets.join('\n')}`
}
}
return instruction.trim()
}
let instruction = `The user is discussing an asset with ID: ${this.assetId}.`
if (this.assetName) {
instruction += `\nFile Name: ${this.assetName}`
}
if (effectiveType) {
const type = getSimpleMediaType(effectiveType)
instruction += `\nFile Type: ${type}`
if (type === 'video' && this.videoDuration !== undefined) {
instruction += `\nVideo Length: ${this.videoDuration.toFixed(2)} seconds`
} else if (type === 'pdf' && this.totalPages !== undefined) {
instruction += `\nTotal Pages: ${this.totalPages}`
}
}
if (this.commentTimestamp !== undefined) {
const type = getSimpleMediaType(effectiveType)
if (type === 'pdf') {
instruction += `\nComment Page: ${Math.round(this.commentTimestamp)}`
} else {
instruction += `\nComment Timestamp: ${this.commentTimestamp.toFixed(2)} seconds`
}
}
if (this.pathContext) {
instruction += `\n\nAsset Path Context:\n${this.pathContext}`
}
if (this.attachedFiles.length > 0 || this.referencedAssets.length > 0) {
instruction += `\n\n[Context: Attached Files & Referenced Assets]`
if (this.attachedFiles.length > 0) {
instruction += `\nAttached Files:\n${this.attachedFiles.join('\n')}`
}
if (this.referencedAssets.length > 0) {
instruction += `\nReferenced Workspace Assets:\n${this.referencedAssets.join('\n')}`
}
}
if (effectiveType) {
const type = getSimpleMediaType(effectiveType)
if (type === 'image') {
instruction += `\n\nIf you need to view the image data, call the 'analyze_image' tool with assetId "${this.assetId}".`
} else if (type === 'video') {
instruction += `\n\nIf you need to view visual frames or take screenshots of the video, call the 'screenshot' tool. You must specify the 'start' (seconds), 'end' (seconds), and 'count' (number of screenshots) parameters.`
} else if (type === 'pdf') {
instruction += `\n\nIf you need to view pages of the PDF document, call the 'read_pdf_pages' tool. You must specify the 'start' (page number) and 'end' (page number) parameters. Maximum 20 pages allowed per call.`
}
}
instruction += `\n\nIf you need a local file on disk to run bash commands or scripts (e.g. processing or combining assets), call the 'download_asset' tool with assetId.`
if (this.userInfo) {
instruction += `\n\nUser Info:\nName: ${this.userInfo.name}\nRole: ${this.userInfo.role}`
}
return instruction
}
}
+233 -59
View File
@@ -3,7 +3,6 @@ import { agentChat } from './agent-chat'
import { prisma } from '@shumai/db'
import { setupTestDbHooks } from '@shumai/db/test'
import * as workflowUtils from '@shumai/workflow-core'
import { AgentChatPromptBuilder } from './agent-chat-prompt-builder'
vi.mock('@shumai/workflow-core', async () => {
const actual = await vi.importActual('@shumai/workflow-core')
@@ -43,6 +42,9 @@ describe('Agent Chat Workflow', () => {
updateCommentActivity: Object.assign(vi.fn(), { _activityName: 'updateCommentActivity' }),
updateTaskUsageActivity: Object.assign(vi.fn(), { _activityName: 'updateTaskUsageActivity' }),
deleteCommentActivity: Object.assign(vi.fn(), { _activityName: 'deleteCommentActivity' }),
getAssetPathHierarchyActivity: Object.assign(vi.fn(), {
_activityName: 'getAssetPathHierarchyActivity',
}),
getAssetPathContextActivity: Object.assign(vi.fn(), {
_activityName: 'getAssetPathContextActivity',
}),
@@ -70,13 +72,21 @@ describe('Agent Chat Workflow', () => {
})
mockActivities.getCommentActivity.mockResolvedValue({
id: 'c1',
creatorId: 'user-c1',
message: 'hello agent',
replyToId: null,
attachments: [],
})
mockActivities.initializeAgentSessionActivity.mockResolvedValue('session-123')
mockActivities.getAgentChatContextActivity.mockResolvedValue({ agent: { id: 'b1' } })
mockActivities.getAssetPathContextActivity.mockResolvedValue('Path: folder/subfolder/file.png')
mockActivities.getAssetPathHierarchyActivity.mockResolvedValue({
path: 'folder/subfolder/test-file.png',
ancestors: [
{ id: 'f1', name: 'folder' },
{ id: 'f2', name: 'subfolder' },
],
})
mockActivities.getAssetPathContextActivity.mockResolvedValue('folder/subfolder/test-file.png')
mockActivities.agentChatActivity.mockResolvedValue({
text: 'Hello user, how can I help you?',
sessionId: 'session-123',
@@ -119,7 +129,6 @@ describe('Agent Chat Workflow', () => {
expect(mockActivities.getCommentActivity).toHaveBeenCalledWith('c1')
// Verify agent context fetched with the project context forwarded
// (required for project-aware role enforcement in the activity)
expect(mockActivities.getAgentChatContextActivity).toHaveBeenCalledWith({
teamId: 't1',
agentId: 'b1',
@@ -144,22 +153,31 @@ describe('Agent Chat Workflow', () => {
userId: undefined,
})
// Verify agent instruction composition
const expectedInstruction1 = new AgentChatPromptBuilder('a1')
.withPathContext('Path: folder/subfolder/file.png')
.withAssetDetails('test-file.png', 'image/png', undefined, undefined, 'image')
.withCommentTimestamp(null)
.build()
// Verify agent chat called with structured messageContext
expect(mockActivities.agentChatActivity).toHaveBeenCalledWith(
expect.objectContaining({
teamId: 't1',
agentId: 'b1',
message: 'hello agent',
agentsInstruction: expectedInstruction1,
sessionId: 'session-123',
folderId: 'parent-folder-id',
assetId: 'a1',
messageContext: expect.objectContaining({
user: { id: 'user-c1', name: 'Test User', role: 'owner' },
currentAsset: expect.objectContaining({
id: 'a1',
name: 'test-file.png',
type: 'file',
mediaType: 'image',
mimeType: 'image/png',
parentId: 'parent-folder-id',
path: 'folder/subfolder/test-file.png',
ancestors: [
{ id: 'f1', name: 'folder' },
{ id: 'f2', name: 'subfolder' },
],
}),
}),
}),
)
@@ -211,17 +229,13 @@ describe('Agent Chat Workflow', () => {
await agentChat(task)
expect(mockActivities.initializeAgentSessionActivity).not.toHaveBeenCalled()
const expectedInstruction2 = new AgentChatPromptBuilder('a1')
.withContinuation(true)
.withPathContext('Path: folder/subfolder/file.png')
.withAssetDetails('test-file.png', 'image/png', undefined)
.withCommentTimestamp(null)
.build()
expect(mockActivities.agentChatActivity).toHaveBeenCalledWith(
expect.objectContaining({
sessionId: 'existing-session-456',
agentsInstruction: expectedInstruction2,
messageContext: expect.objectContaining({
currentAsset: expect.objectContaining({ id: 'a1', name: 'test-file.png' }),
}),
}),
)
@@ -273,16 +287,9 @@ describe('Agent Chat Workflow', () => {
await agentChat(task)
const expectedInstruction4 = new AgentChatPromptBuilder('a1')
.withPathContext('Path: folder/subfolder/file.png')
.withAssetDetails('test-file.png', 'image/png', undefined, undefined, 'image')
.withCommentTimestamp(null)
.build()
expect(mockActivities.agentChatActivity).toHaveBeenCalledWith(
expect.objectContaining({
imageUrls: ['attachments/image1.png', 'attachments/image2.jpg'],
agentsInstruction: expectedInstruction4,
}),
)
})
@@ -315,15 +322,13 @@ describe('Agent Chat Workflow', () => {
await agentChat(task)
const expectedInstruction5 = new AgentChatPromptBuilder('a1')
.withPathContext('Path: folder/subfolder/file.png')
.withAssetDetails('test-asset', 'video/mp4', 10)
.withCommentTimestamp(null)
.build()
expect(mockActivities.agentChatActivity).toHaveBeenCalledWith(
expect.objectContaining({
agentsInstruction: expectedInstruction5,
messageContext: expect.objectContaining({
currentAsset: expect.objectContaining({
durationSeconds: 10,
}),
}),
}),
)
})
@@ -391,6 +396,7 @@ describe('Agent Chat Workflow', () => {
name: 'attachment.png',
type: 'file',
mediaType: 'image/png',
media: { proxyType: 'image' },
projectId: 'p1',
}
}
@@ -400,6 +406,7 @@ describe('Agent Chat Workflow', () => {
name: 'ref-folder',
type: 'folder',
mediaType: null,
media: null,
projectId: 'p1',
}
}
@@ -408,6 +415,7 @@ describe('Agent Chat Workflow', () => {
name: 'test-file.png',
type: 'file',
mediaType: 'image/png',
media: { proxyType: 'image' },
projectId: 'p1',
project: { teamId: 't1' },
}
@@ -443,20 +451,7 @@ describe('Agent Chat Workflow', () => {
expect(mockActivities.createCommentActivity).not.toHaveBeenCalled()
expect(mockActivities.updateCommentActivity).not.toHaveBeenCalled()
// Verify prompt builder is populated and workflow runs agentChatActivity with context instruction
const expectedInstruction = new AgentChatPromptBuilder('a1')
.withContinuation(true)
.withPathContext('folder/subfolder/file.png')
.withAssetDetails('test-file.png', 'image/png', undefined)
.withCommentTimestamp(undefined)
.withAttachedFiles([
'- Name: attachment.png (ID: file-attachment-1, Type: file, Media Type: image/png, Project ID: p1, Path: attachment.png)',
])
.withReferencedAssets([
'- Name: ref-folder (ID: referenced-asset-1, Type: folder, Media Type: unknown, Project ID: p1, Path: ref-folder)',
])
.build()
// Verify messageContext is populated with attachedFiles and referencedAssets
expect(mockActivities.agentChatActivity).toHaveBeenCalledWith(
expect.objectContaining({
teamId: 't1',
@@ -465,15 +460,32 @@ describe('Agent Chat Workflow', () => {
imageUrls: [],
projectId: 'p1',
folderId: '',
agentsInstruction: expectedInstruction,
sessionId: 'session-direct-123',
userId: undefined,
userCommentId: undefined,
context: { agent: { id: 'b1' } },
attachedAssets: [
{ id: 'file-attachment-1', name: 'attachment.png', type: 'file' },
{ id: 'referenced-asset-1', name: 'ref-folder', type: 'folder' },
],
messageContext: expect.objectContaining({
attachedFiles: [
{
id: 'file-attachment-1',
name: 'attachment.png',
type: 'file',
mediaType: 'image',
mimeType: 'image/png',
path: 'attachment.png',
},
],
referencedAssets: [
{
id: 'referenced-asset-1',
name: 'ref-folder',
type: 'folder',
mediaType: undefined,
mimeType: undefined,
path: 'ref-folder',
},
],
}),
}),
)
})
@@ -512,19 +524,18 @@ describe('Agent Chat Workflow', () => {
await agentChat(task)
const expectedInstruction = new AgentChatPromptBuilder('v2-latest')
.withContinuation(true)
.withPathContext('Path: folder/subfolder/file.png')
.withAssetDetails('latest-video.mp4', 'video/mp4', 42, undefined, 'video')
.build()
expect(mockActivities.agentChatActivity).toHaveBeenCalledWith(
expect.objectContaining({
teamId: 't1',
agentId: 'b1',
message: 'Explain this version stack video',
agentsInstruction: expectedInstruction,
sessionId: 'session-vs-123',
messageContext: expect.objectContaining({
currentAsset: expect.objectContaining({
id: 'v2-latest',
durationSeconds: 42,
}),
}),
}),
)
})
@@ -557,7 +568,170 @@ describe('Agent Chat Workflow', () => {
expect(mockActivities.agentChatActivity).toHaveBeenCalledWith(
expect.objectContaining({
agentsInstruction: expect.stringContaining('User Info:\nName: Test User\nRole: owner'),
messageContext: expect.objectContaining({
user: { id: 'user-alice', name: 'Test User', role: 'owner' },
}),
}),
)
})
it('should populate comment attachments into structured messageContext.attachedFiles', async () => {
mockActivities.getCommentActivity.mockResolvedValue({
id: 'c1',
creatorId: 'user-c1',
message: 'check these attachments',
replyToId: null,
attachments: [
{
asset: {
id: 'att-doc-1',
name: 'brief.pdf',
type: 'file',
mediaType: 'application/pdf',
media: { proxyType: 'pdf' },
storageKey: { key: 'brief.pdf' },
},
},
{
asset: {
id: 'att-img-1',
name: 'mockup.png',
type: 'file',
mediaType: 'image/png',
media: { proxyType: 'image' },
storageKey: { key: 'mockup.png' },
},
},
],
})
mockActivities.getAssetPathContextActivity.mockImplementation(async (id: string) => {
if (id === 'att-doc-1') return 'Docs/brief.pdf'
if (id === 'att-img-1') return 'Designs/mockup.png'
return 'folder/subfolder/file.png'
})
const task = await prisma.workflowTask.create({
data: {
type: 'chat',
status: 'pending',
assetId: 'a1',
payload: {
projectId: 'p1',
agent: { userCommentId: 'c1', agentId: 'b1' },
},
},
})
await agentChat(task)
expect(mockActivities.agentChatActivity).toHaveBeenCalledWith(
expect.objectContaining({
imageUrls: ['mockup.png'],
messageContext: expect.objectContaining({
attachedFiles: [
{
id: 'att-doc-1',
name: 'brief.pdf',
type: 'file',
mediaType: 'pdf',
mimeType: 'application/pdf',
path: 'Docs/brief.pdf',
},
{
id: 'att-img-1',
name: 'mockup.png',
type: 'file',
mediaType: 'image',
mimeType: 'image/png',
path: 'Designs/mockup.png',
},
],
}),
}),
)
})
it('should set totalFrames for video assets and totalPages for pdf assets in currentAsset context', async () => {
mockActivities.getAssetActivity.mockImplementation(async (id: string) => {
if (id === 'video-asset-1') {
return {
id: 'video-asset-1',
project: { teamId: 't1' },
type: 'file',
name: 'clip.mp4',
mediaType: 'video/mp4',
media: { proxyType: 'video', duration: 9, frames: 268 },
parentId: 'f1',
}
}
if (id === 'pdf-asset-1') {
return {
id: 'pdf-asset-1',
project: { teamId: 't1' },
type: 'file',
name: 'doc.pdf',
mediaType: 'application/pdf',
media: { proxyType: 'pdf', frames: 15, duration: 0 },
parentId: 'f1',
}
}
return null
})
// Test Video asset
const videoTask = await prisma.workflowTask.create({
data: {
type: 'chat',
status: 'pending',
assetId: 'video-asset-1',
payload: {
projectId: 'p1',
agent: { prompt: 'Analyze video', agentId: 'b1', sessionId: 'session-video-1' },
},
},
})
await agentChat(videoTask)
expect(mockActivities.agentChatActivity).toHaveBeenCalledWith(
expect.objectContaining({
messageContext: expect.objectContaining({
currentAsset: expect.objectContaining({
id: 'video-asset-1',
mediaType: 'video',
durationSeconds: 9,
totalFrames: 268,
totalPages: undefined,
}),
}),
}),
)
// Test PDF asset
const pdfTask = await prisma.workflowTask.create({
data: {
type: 'chat',
status: 'pending',
assetId: 'pdf-asset-1',
payload: {
projectId: 'p1',
agent: { prompt: 'Analyze pdf', agentId: 'b1', sessionId: 'session-pdf-1' },
},
},
})
await agentChat(pdfTask)
expect(mockActivities.agentChatActivity).toHaveBeenCalledWith(
expect.objectContaining({
messageContext: expect.objectContaining({
currentAsset: expect.objectContaining({
id: 'pdf-asset-1',
mediaType: 'pdf',
totalPages: 15,
totalFrames: undefined,
durationSeconds: undefined,
}),
}),
}),
)
})
+135 -32
View File
@@ -1,7 +1,13 @@
import { ApplicationFailure } from '@temporalio/workflow'
import type { WorkflowTask } from '@shumai/db'
import { executeActivity, getActivities, TaskQueueAgent } from '@shumai/workflow-core'
import { AgentChatPromptBuilder } from './agent-chat-prompt-builder'
import type {
ShumaiMessageContext,
ShumaiAssetContext,
ShumaiAttachedFileContext,
ShumaiMediaPosition,
} from '@shumai/dtos'
import { getProxyType } from '@shumai/core/src/utils/mime'
export async function agentChat(task: WorkflowTask): Promise<void> {
const {
@@ -15,6 +21,7 @@ export async function agentChat(task: WorkflowTask): Promise<void> {
updateTaskUsageActivity,
getAgentWorkerQueueActivity,
initializeAgentSessionActivity,
getAssetPathHierarchyActivity,
getAssetPathContextActivity,
generateSessionNameActivity,
getUserTeamInfoActivity,
@@ -47,19 +54,30 @@ export async function agentChat(task: WorkflowTask): Promise<void> {
// 1. Get User Comment
const userCommentId = payload.agent?.userCommentId
let userComment: Awaited<ReturnType<typeof getCommentActivity>> | null = null
let prompt = ''
let attachmentImageUrls: string[] = []
let commentTimestamp: number | undefined
let commentAnnotation = false
let commentCreatorId: string | undefined
if (userCommentId) {
const userComment = await executeActivity(agentWorkerQueue, getCommentActivity, userCommentId)
userComment = await executeActivity(agentWorkerQueue, getCommentActivity, userCommentId)
if (!userComment) {
throw ApplicationFailure.create({ message: 'User comment not found', nonRetryable: true })
}
prompt = userComment.message || ''
commentCreatorId = userComment.creatorId || undefined
if (userComment.second !== null && userComment.second !== undefined) {
commentTimestamp = userComment.second
}
if (
userComment.annotation &&
Array.isArray(userComment.annotation) &&
userComment.annotation.length > 0
) {
commentAnnotation = true
}
// 2. Create Placeholder Comment
const placeholder = await executeActivity(agentWorkerQueue, createCommentActivity, {
@@ -71,7 +89,7 @@ export async function agentChat(task: WorkflowTask): Promise<void> {
})
placeholderCommentId = placeholder.id
// 5. Prepare Images (Attachments only)
// Prepare Images (Attachments only)
if (userComment.attachments) {
for (const att of userComment.attachments) {
const attProxyType = (att.asset?.media as PrismaJson.MediaInfo | null)?.proxyType
@@ -118,43 +136,104 @@ export async function agentChat(task: WorkflowTask): Promise<void> {
projectId: payload.projectId,
})
const pathContext = await executeActivity(
const pathHierarchy = await executeActivity(
agentWorkerQueue,
getAssetPathContextActivity,
getAssetPathHierarchyActivity,
task.assetId,
)
const assetPath = pathHierarchy?.path || ''
const ancestors = pathHierarchy?.ancestors || []
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const mediaInfo = asset.media as any
const duration = mediaInfo?.duration
const totalPages = mediaInfo?.frames || mediaInfo?.metadata?.totalFrames
const proxyType =
(asset.media as PrismaJson.MediaInfo | null)?.proxyType ||
getProxyType(asset.mediaType, asset.name) ||
undefined
const duration =
(proxyType === 'video' || proxyType === 'audio') && typeof mediaInfo?.duration === 'number'
? mediaInfo.duration
: undefined
const totalPages =
proxyType === 'pdf' ? mediaInfo?.frames || mediaInfo?.metadata?.totalFrames : undefined
const totalFrames =
proxyType === 'video' ? mediaInfo?.frames || mediaInfo?.metadata?.totalFrames : undefined
// Resolve Attached Files Details
const attachedFileDetailsList: string[] = []
const attachedFiles: ShumaiAttachedFileContext[] = []
const attachedAssets: Array<{ id: string; name: string; type: string }> = []
if (payload.agent?.attachedFiles) {
if (userCommentId && userComment?.attachments) {
for (const att of userComment.attachments) {
if (att.asset) {
const filePath = await executeActivity(
agentWorkerQueue,
getAssetPathContextActivity,
att.asset.id,
)
const attProxyType =
(att.asset.media as PrismaJson.MediaInfo | null)?.proxyType ||
getProxyType(att.asset.mediaType, att.asset.name) ||
undefined
attachedFiles.push({
id: att.asset.id,
name: att.asset.name,
type: att.asset.type,
mediaType: attProxyType as ShumaiAttachedFileContext['mediaType'],
mimeType: att.asset.mediaType || undefined,
path: filePath || undefined,
})
attachedAssets.push({ id: att.asset.id, name: att.asset.name, type: att.asset.type })
}
}
} else if (payload.agent?.attachedFiles) {
for (const fileId of payload.agent.attachedFiles) {
const file = await executeActivity(agentWorkerQueue, getAssetActivity, fileId)
if (file) {
const path = await executeActivity(agentWorkerQueue, getAssetPathContextActivity, fileId)
attachedFileDetailsList.push(
`- Name: ${file.name} (ID: ${file.id}, Type: ${file.type}, Media Type: ${file.mediaType || 'unknown'}, Project ID: ${file.projectId || 'unknown'}, Path: ${path})`,
const filePath = await executeActivity(
agentWorkerQueue,
getAssetPathContextActivity,
fileId,
)
const fileProxyType =
(file.media as PrismaJson.MediaInfo | null)?.proxyType ||
getProxyType(file.mediaType, file.name) ||
undefined
attachedFiles.push({
id: file.id,
name: file.name,
type: file.type,
mediaType: fileProxyType as ShumaiAttachedFileContext['mediaType'],
mimeType: file.mediaType || undefined,
path: filePath || undefined,
})
attachedAssets.push({ id: file.id, name: file.name, type: file.type })
}
}
}
// Resolve Referenced Workspace Assets Details
const referencedAssetDetailsList: string[] = []
const referencedAssets: ShumaiAttachedFileContext[] = []
if (payload.agent?.assetIds) {
for (const assetId of payload.agent.assetIds) {
const referencedAsset = await executeActivity(agentWorkerQueue, getAssetActivity, assetId)
if (referencedAsset) {
const path = await executeActivity(agentWorkerQueue, getAssetPathContextActivity, assetId)
referencedAssetDetailsList.push(
`- Name: ${referencedAsset.name} (ID: ${referencedAsset.id}, Type: ${referencedAsset.type}, Media Type: ${referencedAsset.mediaType || 'unknown'}, Project ID: ${referencedAsset.projectId || 'unknown'}, Path: ${path})`,
const filePath = await executeActivity(
agentWorkerQueue,
getAssetPathContextActivity,
assetId,
)
const refProxyType =
(referencedAsset.media as PrismaJson.MediaInfo | null)?.proxyType ||
getProxyType(referencedAsset.mediaType, referencedAsset.name) ||
undefined
referencedAssets.push({
id: referencedAsset.id,
name: referencedAsset.name,
type: referencedAsset.type,
mediaType: refProxyType as ShumaiAttachedFileContext['mediaType'],
mimeType: referencedAsset.mediaType || undefined,
path: filePath || undefined,
})
attachedAssets.push({
id: referencedAsset.id,
name: referencedAsset.name,
@@ -164,29 +243,53 @@ export async function agentChat(task: WorkflowTask): Promise<void> {
}
}
// Resolve User Info
const targetUserId = userCommentId ? commentCreatorId : payload.agent?.userId
let userInfo: { name: string; role: string } | null = null
if (!userCommentId && isNewChat && payload.agent?.userId) {
if (targetUserId) {
userInfo = await executeActivity(agentWorkerQueue, getUserTeamInfoActivity, {
userId: payload.agent.userId,
userId: targetUserId,
teamId,
})
}
const proxyType = (asset.media as PrismaJson.MediaInfo | null)?.proxyType
const promptBuilder = new AgentChatPromptBuilder(asset.id)
.withContinuation(!isNewChat)
.withAssetChanged(payload.agent?.hasAssetChanged)
.withPathContext(pathContext)
.withAssetDetails(asset.name, asset.mediaType, duration, totalPages, proxyType)
.withCommentTimestamp(commentTimestamp)
.withAttachedFiles(attachedFileDetailsList)
.withReferencedAssets(referencedAssetDetailsList)
if (userInfo) {
promptBuilder.withUserInfo(userInfo.name, userInfo.role)
// Build position
let mediaPosition: ShumaiMediaPosition | undefined
if (commentTimestamp !== undefined && commentTimestamp !== null) {
if (proxyType === 'pdf') {
mediaPosition = { type: 'page', page: Math.round(commentTimestamp) }
} else {
mediaPosition = { type: 'time', seconds: commentTimestamp }
}
}
const instruction = promptBuilder.build()
// Build Current Asset Context
const currentAssetContext: ShumaiAssetContext = {
id: asset.id,
name: asset.name,
type: asset.type,
mediaType: proxyType as ShumaiAssetContext['mediaType'],
mimeType: asset.mediaType || undefined,
parentId: asset.parentId || undefined,
path: assetPath || undefined,
durationSeconds: duration !== undefined ? duration : undefined,
totalFrames: totalFrames !== undefined ? totalFrames : undefined,
totalPages: totalPages !== undefined ? totalPages : undefined,
navigated: payload.agent?.hasAssetChanged === true ? true : undefined,
ancestors: ancestors.length > 0 ? ancestors : undefined,
}
// Build structured ShumaiMessageContext
const messageContext: ShumaiMessageContext = {
...(userInfo
? { user: { id: targetUserId!, name: userInfo.name, role: userInfo.role } }
: {}),
currentAsset: currentAssetContext,
...(mediaPosition ? { position: mediaPosition } : {}),
...(commentAnnotation ? { annotation: true } : {}),
...(attachedFiles.length > 0 ? { attachedFiles } : {}),
...(referencedAssets.length > 0 ? { referencedAssets } : {}),
}
// 6. Call AI Chat
let folderId = ''
@@ -205,11 +308,11 @@ export async function agentChat(task: WorkflowTask): Promise<void> {
projectId: payload.projectId,
folderId,
assetId: asset.id,
agentsInstruction: instruction,
sessionId,
userId: payload.agent?.userId,
userCommentId: userCommentId || undefined,
context,
messageContext,
attachedAssets,
})
@@ -1,140 +0,0 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { agentToolCall } from './agent-tool-call'
import { prisma } from '@shumai/db'
import { setupTestDbHooks } from '@shumai/db/test'
import * as workflowUtils from '@shumai/workflow-core'
vi.mock('@shumai/workflow-core', async () => {
const actual = await vi.importActual('@shumai/workflow-core')
return {
...actual,
getActivities: vi.fn(),
executeActivity: vi.fn(),
}
})
describe('Agent Tool Call Workflow', () => {
setupTestDbHooks()
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- mockActivities holds mock functions cast to expected types
let mockActivities: any
beforeEach(() => {
vi.clearAllMocks()
mockActivities = {
updateTaskStatusActivity: Object.assign(vi.fn(), {
_activityName: 'updateTaskStatusActivity',
}),
executeAgentToolActivity: Object.assign(vi.fn(), {
_activityName: 'executeAgentToolActivity',
}),
getAgentWorkerQueueActivity: Object.assign(vi.fn(), {
_activityName: 'getAgentWorkerQueueActivity',
}),
}
mockActivities.getAgentWorkerQueueActivity.mockResolvedValue('agent_queue')
mockActivities.updateTaskStatusActivity.mockResolvedValue({})
mockActivities.executeAgentToolActivity.mockResolvedValue({ success: true, count: 42 })
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- mockActivities contains vi.fn mock functions which are cast to expected activity proxy types
vi.mocked(workflowUtils.getActivities).mockReturnValue(mockActivities as any)
vi.mocked(workflowUtils.executeActivity).mockImplementation(async (_queue, act, ...args) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- act is one of the mocked activities
return (act as any)(...args)
})
})
it('should run agent tool call workflow successfully', async () => {
const task = await prisma.workflowTask.create({
data: {
type: 'agent_tool_call',
status: 'pending',
assetId: 'a1',
payload: {
projectId: 'p1',
agentToolCall: {
toolName: 'list_assets',
args: { parent: 'folder-123' },
userId: 'user-456',
},
},
},
})
await agentToolCall(task)
// Verify queue discovery
expect(mockActivities.getAgentWorkerQueueActivity).toHaveBeenCalled()
// Verify task processing status
expect(mockActivities.updateTaskStatusActivity).toHaveBeenCalledWith({
taskId: task.id,
status: 'processing',
})
// Verify tool execution
expect(mockActivities.executeAgentToolActivity).toHaveBeenCalledWith({
taskId: task.id,
toolName: 'list_assets',
args: { parent: 'folder-123' },
userId: 'user-456',
})
// Verify task completed status with output
expect(mockActivities.updateTaskStatusActivity).toHaveBeenCalledWith({
taskId: task.id,
status: 'completed',
output: { success: true, count: 42 },
})
})
it('should throw if payload or agentToolCall is missing', async () => {
const task = await prisma.workflowTask.create({
data: {
type: 'agent_tool_call',
status: 'pending',
assetId: 'a1',
},
})
await expect(agentToolCall(task)).rejects.toThrow('Task payload or agentToolCall is missing')
// Verify status updated to failed
expect(mockActivities.updateTaskStatusActivity).toHaveBeenCalledWith({
taskId: task.id,
status: 'failed',
output: { error: 'Task payload or agentToolCall is missing' },
})
})
it('should handle tool execution failures by updating task to failed and throwing', async () => {
mockActivities.executeAgentToolActivity.mockRejectedValue(new Error('Authz failure'))
const task = await prisma.workflowTask.create({
data: {
type: 'agent_tool_call',
status: 'pending',
assetId: 'a1',
payload: {
projectId: 'p1',
agentToolCall: {
toolName: 'create_folder',
args: { parent: 'folder-123', name: 'new-folder' },
userId: 'user-456',
},
},
},
})
await expect(agentToolCall(task)).rejects.toThrow('Authz failure')
// Verify task status failed
expect(mockActivities.updateTaskStatusActivity).toHaveBeenCalledWith({
taskId: task.id,
status: 'failed',
output: { error: 'Authz failure' },
})
})
})
@@ -1,60 +0,0 @@
import { ApplicationFailure } from '@temporalio/workflow'
import type { WorkflowTask } from '@shumai/db'
import { getActivities, executeActivity, TaskQueueAgent } from '@shumai/workflow-core'
export async function agentToolCall(task: WorkflowTask): Promise<void> {
const { updateTaskStatusActivity, executeAgentToolActivity, getAgentWorkerQueueActivity } =
getActivities()
let agentWorkerQueue = ''
try {
// 0. Discover queue
agentWorkerQueue = await executeActivity(TaskQueueAgent, getAgentWorkerQueueActivity)
// Update status to processing
await executeActivity(agentWorkerQueue, updateTaskStatusActivity, {
taskId: task.id,
status: 'processing',
})
const payload = task.payload
if (!payload || !payload.agentToolCall) {
throw ApplicationFailure.create({
message: 'Task payload or agentToolCall is missing',
nonRetryable: true,
})
}
const { toolName, args, userId } = payload.agentToolCall
// Execute the agent activity on specific queue
const result = await executeActivity(agentWorkerQueue, executeAgentToolActivity, {
taskId: task.id,
toolName,
args,
userId,
})
// Update status to completed with output
await executeActivity(agentWorkerQueue, updateTaskStatusActivity, {
taskId: task.id,
status: 'completed',
output: result,
})
} catch (err) {
console.error(`AgentToolCall failed for task ${task.id}:`, err)
// Update status to failed
if (agentWorkerQueue) {
await executeActivity(agentWorkerQueue, updateTaskStatusActivity, {
taskId: task.id,
status: 'failed',
output: { error: err instanceof Error ? err.message : String(err) },
})
}
throw err
}
}
export const agentToolCallWorkflow = agentToolCall
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/api",
"version": "0.3.10",
"version": "0.4.1",
"private": true,
"type": "module",
"main": "./src/index.ts",
+40
View File
@@ -188,6 +188,46 @@ describe('folder api', () => {
type: ResourceType.Asset,
id: 'test-id',
})
expect(assetService.listChildren).toHaveBeenCalledWith({
assetId: 'test-id',
assetType: 'folder',
})
})
it('GET /folders/:folderId/children forwards pagination parameters', async () => {
vi.mocked(assetService.listChildren).mockResolvedValue({
data: [
{
id: 'child-id-2',
name: 'child-folder-2',
sizeByte: 0,
fileCount: 0,
type: 'folder',
status: 'active',
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
},
],
pageInfo: { total: 30, cursor: 'cursorNextToken' },
})
const app = new Hono().use('*', authMiddleware).route('/', folderRoute)
const res = await app.request(
'/folders/test-id/children?assetType=folder&first=20&after=cursorToken123&prefix=sub',
)
expect(res.status).toBe(200)
const json = await res.json()
expect(json.data).toHaveLength(1)
expect(json.pageInfo.cursor).toBe('cursorNextToken')
expect(assetService.listChildren).toHaveBeenCalledWith({
assetId: 'test-id',
assetType: 'folder',
first: 20,
after: 'cursorToken123',
prefix: 'sub',
})
})
it('DELETE /folders', async () => {
+1 -5
View File
@@ -120,12 +120,8 @@ const route = new Hono<{ Variables: { user: User } }>()
})
const resp = await assetService.listChildren({
...req,
assetId: folderId,
assetType: req.assetType,
projectId: req.projectId,
showDeleted: req.showDeleted,
sort: req.sort,
order: req.order,
})
return c.json(resp)
})
+12
View File
@@ -31,6 +31,7 @@ describe('authMiddleware', () => {
.get('/test', (c) => c.text('ok'))
.post('/test', (c) => c.text('ok'))
.post('/test/search', (c) => c.text('ok'))
.post('/test/recents/view', (c) => c.text('ok'))
beforeEach(() => {
vi.resetAllMocks()
@@ -81,6 +82,17 @@ describe('authMiddleware', () => {
expect(await res.json()).toEqual({ error: 'System is in read-only mode' })
})
it('allows POST /recents/view for reviewer', async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
vi.mocked(auth.api.getSession).mockResolvedValue({ user: { id: 'user1' } } as any)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
vi.mocked(userService.getUserById).mockResolvedValue({ id: 'user1' } as any)
vi.mocked(teamService.hasWritableRoleInAnyTeam).mockResolvedValue(false)
const res = await app.request('/test/recents/view', { method: 'POST' })
expect(res.status).toBe(200)
})
it('allows POST /search for reviewer', async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
vi.mocked(auth.api.getSession).mockResolvedValue({ user: { id: 'user1' } } as any)
+3 -1
View File
@@ -36,7 +36,9 @@ export const authMiddleware = createMiddleware<{
if (process.env.SHUMAI_DEMO_MODE === '1') {
const method = c.req.method.toUpperCase()
const path = c.req.path
if (['POST', 'PUT', 'PATCH', 'DELETE'].includes(method) && !path.endsWith('/search')) {
const isAllowedDemoWrite =
method === 'POST' && (path.endsWith('/search') || path.endsWith('/recents/view'))
if (['POST', 'PUT', 'PATCH', 'DELETE'].includes(method) && !isAllowedDemoWrite) {
const hasWritable = await teamService.hasWritableRoleInAnyTeam(user.id)
if (!hasWritable) {
+43
View File
@@ -35,6 +35,7 @@ vi.mock('@shumai/core/src/project/project', () => ({
},
}))
vi.mock('@shumai/core/src/asset/asset')
vi.mock('@shumai/core/src/auditLog/auditLog', () => ({
auditLogService: {
logAction: vi.fn().mockResolvedValue({}),
@@ -410,4 +411,46 @@ describe('project api', () => {
})
expect(projectService.getUserProjects).toHaveBeenCalledWith('user1', 10)
})
it('GET /projects/:projectId/recents', async () => {
vi.mocked(assetService.listRecents).mockResolvedValue({
data: [{ id: 'file1', name: 'video.mp4', type: 'file' }] as any, // eslint-disable-line @typescript-eslint/no-explicit-any
pageInfo: { total: 1 },
})
const res = await app.request('/projects/p1/recents?first=20')
expect(res.status).toBe(200)
const json = await res.json()
expect(json.data).toHaveLength(1)
expect(json.data[0].id).toBe('file1')
expect(authzService.hasPermission).toHaveBeenCalledWith({
user: expect.anything(),
permission: Permission.Read,
type: ResourceType.Project,
id: 'p1',
})
expect(assetService.listRecents).toHaveBeenCalledWith('user1', 'p1', { first: 20 })
})
it('POST /projects/:projectId/recents/view', async () => {
vi.mocked(assetService.recordRecentView).mockResolvedValue(undefined)
const res = await app.request('/projects/p1/recents/view', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ assetId: 'file1' }),
})
expect(res.status).toBe(200)
const json = await res.json()
expect(json.success).toBe(true)
expect(authzService.hasPermission).toHaveBeenCalledWith({
user: expect.anything(),
permission: Permission.Read,
type: ResourceType.Project,
id: 'p1',
})
expect(assetService.recordRecentView).toHaveBeenCalledWith('user1', 'p1', 'file1')
})
})
+36
View File
@@ -11,6 +11,8 @@ import {
recentlyDeletedRequestSchema,
updateProjectMemberRoleRequestSchema,
addProjectMemberRequestSchema,
listRecentsRequestSchema,
recordRecentViewRequestSchema,
} from '@shumai/dtos'
import { listMembersQuerySchema, paginationParamsSchema, AuditAction } from '@shumai/dtos'
import type { Prisma } from '@shumai/db'
@@ -118,6 +120,40 @@ const route = new Hono<{ Variables: { user: User } }>()
return c.json(resp)
},
)
.get('/projects/:projectId/recents', zValidator('query', listRecentsRequestSchema), async (c) => {
const projectId = c.req.param('projectId')
const user = c.get('user')
const req = c.req.valid('query')
await authzService.hasPermission({
user,
permission: Permission.Read,
type: ResourceType.Project,
id: projectId,
})
const resp = await assetService.listRecents(user.id, projectId, req)
return c.json(resp)
})
.post(
'/projects/:projectId/recents/view',
zValidator('json', recordRecentViewRequestSchema),
async (c) => {
const projectId = c.req.param('projectId')
const user = c.get('user')
const req = c.req.valid('json')
await authzService.hasPermission({
user,
permission: Permission.Read,
type: ResourceType.Project,
id: projectId,
})
await assetService.recordRecentView(user.id, projectId, req.assetId)
return c.json({ success: true })
},
)
.post('/projects/:projectId/empty-trash', async (c) => {
const projectId = c.req.param('projectId')
const user = c.get('user')
+2 -2
View File
@@ -4,7 +4,7 @@ import { zValidator } from '@hono/zod-validator'
import { shareService } from '@shumai/core/src/share/share'
import { assetService } from '@shumai/core/src/asset/asset'
import { watermarkService } from '@shumai/core/src/watermark/watermark'
import { paginationParamsSchema } from '@shumai/dtos'
import { paginationParamsSchema, assetTypeFilterSchema } from '@shumai/dtos'
import { z } from 'zod'
import { metadataService } from '@shumai/core/src/metadata/metadata'
import { FieldInfo } from '@shumai/dtos'
@@ -117,7 +117,7 @@ export function handlePublicShareError(c: Context, err: unknown) {
}
const sharedChildrenRequestSchema = paginationParamsSchema.extend({
assetType: z.string().optional(),
assetType: assetTypeFilterSchema.optional().default('file'),
})
const route = app
+15
View File
@@ -245,6 +245,21 @@ describe('team api', () => {
expect(mockUpdateSettings).toHaveBeenCalledWith('t1', 'transcode.videoStrategy', 'all')
})
it('PATCH /teams/:teamId/settings updates transcode.hardwareAcceleration', async () => {
mockUpdateSettings.mockResolvedValue({ transcode: { hardwareAcceleration: 'auto' } })
const res = await app.request('/teams/t1/settings', {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ key: 'transcode.hardwareAcceleration', value: 'auto' }),
})
expect(res.status).toBe(200)
const data = await res.json()
expect(data.transcode.hardwareAcceleration).toBe('auto')
expect(mockUpdateSettings).toHaveBeenCalledWith('t1', 'transcode.hardwareAcceleration', 'auto')
})
it('GET /teams/:teamId/user-metadata returns all metadata for the user in the team', async () => {
mockListUserMetadata.mockResolvedValue([
{ key: 'key1', value: 'value1' },
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/core",
"version": "0.3.10",
"version": "0.4.1",
"private": true,
"type": "module",
"main": "./src/index.ts",
+590
View File
@@ -5,6 +5,8 @@ import { HTTPException } from 'hono/http-exception'
import { AssetType, AssetStatus, Prisma } from '@shumai/db'
import { s3Service } from '@shumai/core/src/s3/s3'
import { uploadService } from '@shumai/core/src/upload/upload'
import { metadataService } from '@shumai/core/src/metadata/metadata'
import { AssetService } from './asset'
vi.mock('@shumai/core/src/s3/s3', () => ({
@@ -568,6 +570,62 @@ describe('AssetService', () => {
})
})
it('rejects reparenting a version_stack onto a file', async () => {
const { user, assets } = await setupBasicAssets()
await expect(
assetService.reparentAssets({
assetIds: [assets.stackB.id],
newParentId: assets.fileA1.id,
creatorId: user.id,
}),
).rejects.toThrow('Source asset must be a file to create a version stack')
})
it('rejects reparenting a version_stack onto another version_stack', async () => {
const { user, assets, project } = await setupBasicAssets()
const stack2 = await prisma.asset.create({
data: {
name: 'stack2',
type: AssetType.version_stack,
projectId: project.id,
parentId: assets.folderA.id,
creatorId: user.id,
fileCount: 2,
sizeByte: 100,
status: 'uploaded',
},
})
await expect(
assetService.reparentAssets({
assetIds: [assets.stackB.id],
newParentId: stack2.id,
creatorId: user.id,
}),
).rejects.toThrow('Cannot move version_stack asset into a version stack')
})
it('rejects reparenting a folder onto a version_stack', async () => {
const { user, assets } = await setupBasicAssets()
await expect(
assetService.reparentAssets({
assetIds: [assets.folderA.id],
newParentId: assets.stackB.id,
creatorId: user.id,
}),
).rejects.toThrow('Cannot move folder asset into a version stack')
})
it('rejects reparenting multiple files onto a version_stack at once', async () => {
const { user, assets } = await setupBasicAssets()
await expect(
assetService.reparentAssets({
assetIds: [assets.fileA1.id, assets.fileA2.id],
newParentId: assets.stackB.id,
creatorId: user.id,
}),
).rejects.toThrow('Can only move one file at a time into a version stack')
})
describe('fileCount verification', () => {
it('createAsset should increment parent fileCount', async () => {
const { user, assets, project } = await setupBasicAssets()
@@ -3575,5 +3633,537 @@ describe('AssetService — natural sort by name', () => {
})
expect(updatedFile.name).toBe('renamed.png')
})
it('cascades soft-delete and restoration to symlinks and updates parent fileCount', async () => {
const team = await prisma.team.create({ data: { name: 'Test Team ' + Date.now() } })
const project = await prisma.project.create({
data: { name: 'Test Project', teamId: team.id },
})
const rootFolder = await prisma.asset.create({
data: {
name: 'Root',
type: AssetType.folder,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
const shareRoot = await prisma.asset.create({
data: {
name: 'Share Root',
type: AssetType.share_root,
projectId: project.id,
status: AssetStatus.uploaded,
fileCount: 0,
},
})
const file = await prisma.asset.create({
data: {
name: 'test-file.txt',
type: AssetType.file,
parentId: rootFolder.id,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
await prisma.asset.update({
where: { id: rootFolder.id },
data: { fileCount: 1 },
})
const symlink = await prisma.asset.create({
data: {
name: file.name,
type: AssetType.symlink,
parentId: shareRoot.id,
targetId: file.id,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
await prisma.asset.update({
where: { id: shareRoot.id },
data: { fileCount: 1 },
})
// Soft delete the file
await assetService.deleteAssets([file.id])
const deletedSymlink = await prisma.asset.findUnique({ where: { id: symlink.id } })
expect(deletedSymlink?.isDeleted).toBe(true)
expect(deletedSymlink?.status).toBe(AssetStatus.trashed)
const updatedShareRoot = await prisma.asset.findUnique({ where: { id: shareRoot.id } })
expect(updatedShareRoot?.fileCount).toBe(0)
// Restore the file
await assetService.restoreAssets([file.id])
const restoredSymlink = await prisma.asset.findUnique({ where: { id: symlink.id } })
expect(restoredSymlink?.isDeleted).toBe(false)
expect(restoredSymlink?.status).toBe(AssetStatus.processed)
const restoredShareRoot = await prisma.asset.findUnique({ where: { id: shareRoot.id } })
expect(restoredShareRoot?.fileCount).toBe(1)
})
it('cascades permanent purge to symlinks when emptying trash', async () => {
const team = await prisma.team.create({ data: { name: 'Test Team ' + Date.now() } })
const project = await prisma.project.create({
data: { name: 'Test Project', teamId: team.id },
})
const rootFolder = await prisma.asset.create({
data: {
name: 'Root',
type: AssetType.folder,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
const shareRoot = await prisma.asset.create({
data: {
name: 'Share Root',
type: AssetType.share_root,
projectId: project.id,
status: AssetStatus.uploaded,
fileCount: 0,
},
})
const file = await prisma.asset.create({
data: {
name: 'file-to-purge.txt',
type: AssetType.file,
parentId: rootFolder.id,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
const symlink = await prisma.asset.create({
data: {
name: file.name,
type: AssetType.symlink,
parentId: shareRoot.id,
targetId: file.id,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
// Soft delete then empty trash
await assetService.deleteAssets([file.id])
await assetService.emptyTrash(project.id)
const purgedFile = await prisma.asset.findUnique({ where: { id: file.id } })
expect(purgedFile).toBeNull()
const purgedSymlink = await prisma.asset.findUnique({ where: { id: symlink.id } })
expect(purgedSymlink).toBeNull()
})
})
describe('createFile', () => {
it('creates a file, updates ancestor sizes, persists metadata, and triggers workflows', async () => {
const user = await prisma.user.create({
data: { name: 'FileUser', email: `fileuser-${Date.now()}@example.com` },
})
const team = await prisma.team.create({ data: { name: 'FileTeam' } })
const project = await prisma.project.create({
data: { name: 'FileProject', teamId: team.id },
})
const rootFolder = await prisma.asset.create({
data: {
name: 'RootFolder',
type: AssetType.folder,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
const promptField = await metadataService.createProjectField(project.id, {
description: 'Prompt field',
config: {
name: 'Prompt',
type: 'text',
autofillSource: 'CREATION_CONTEXT',
},
})
const triggerSpy = vi
.spyOn(uploadService, 'triggerPostUploadWorkflows')
.mockResolvedValue(undefined)
const fileInfo = await assetService.createFile({
parentId: rootFolder.id,
name: 'document.txt',
key: 'files/test/doc.txt',
sizeByte: 1024,
contentType: 'text/plain',
creatorId: user.id,
metadata: { [promptField.key]: 'Project overview document' },
})
expect(fileInfo.id).toBeDefined()
expect(fileInfo.name).toBe('document.txt')
expect(fileInfo.type).toBe(AssetType.file)
expect(fileInfo.sizeByte).toBe(1024)
const folderAfter = await prisma.asset.findUnique({ where: { id: rootFolder.id } })
expect(folderAfter?.sizeByte).toBe(1024n)
expect(folderAfter?.fileCount).toBe(1)
const metaVal = await prisma.assetMetadataValue.findFirst({
where: { assetId: fileInfo.id, fieldKey: promptField.key },
})
expect(metaVal?.stringValue).toBe('Project overview document')
expect(triggerSpy).toHaveBeenCalledWith(expect.anything(), fileInfo.id, team.id, project.id)
})
it('rejects if metadata contains invalid keys', async () => {
const user = await prisma.user.create({
data: { name: 'FileUser2', email: `fileuser2-${Date.now()}@example.com` },
})
const team = await prisma.team.create({ data: { name: 'FileTeam2' } })
const project = await prisma.project.create({
data: { name: 'FileProject2', teamId: team.id },
})
const rootFolder = await prisma.asset.create({
data: {
name: 'RootFolder2',
type: AssetType.folder,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
await expect(
assetService.createFile({
parentId: rootFolder.id,
name: 'invalid.txt',
key: 'files/test/inv.txt',
sizeByte: 100,
contentType: 'text/plain',
creatorId: user.id,
metadata: { unknownField: 'val' },
}),
).rejects.toThrow(/metadata contains keys that are not valid in this project/)
})
it('rolls back completely if post-upload workflow fails in transaction', async () => {
const user = await prisma.user.create({
data: { name: 'FileRollbackUser', email: `filerollback-${Date.now()}@example.com` },
})
const team = await prisma.team.create({ data: { name: 'FileRollbackTeam' } })
const project = await prisma.project.create({
data: { name: 'FileRollbackProject', teamId: team.id },
})
const rootFolder = await prisma.asset.create({
data: {
name: 'RootFolder',
type: AssetType.folder,
projectId: project.id,
status: AssetStatus.uploaded,
sizeByte: 0n,
fileCount: 0,
},
})
vi.spyOn(uploadService, 'triggerPostUploadWorkflows').mockRejectedValueOnce(
new Error('Simulated workflow failure'),
)
await expect(
assetService.createFile({
parentId: rootFolder.id,
name: 'should_rollback.txt',
key: 'files/test/should_rollback.txt',
sizeByte: 1024,
contentType: 'text/plain',
creatorId: user.id,
}),
).rejects.toThrow('Simulated workflow failure')
// Assert no asset was created
const created = await prisma.asset.findFirst({
where: { name: 'should_rollback.txt', projectId: project.id },
})
expect(created).toBeNull()
// Assert parent folder counters remained untouched
const folderAfter = await prisma.asset.findUnique({ where: { id: rootFolder.id } })
expect(folderAfter?.fileCount).toBe(0)
expect(folderAfter?.sizeByte).toBe(0n)
})
})
describe('createVersion', () => {
it('creates a version stack when target is a regular file', async () => {
const user = await prisma.user.create({
data: { name: 'VersionUser', email: `veruser-${Date.now()}@example.com` },
})
const team = await prisma.team.create({ data: { name: 'VersionTeam' } })
const project = await prisma.project.create({
data: { name: 'VersionProject', teamId: team.id },
})
const rootFolder = await prisma.asset.create({
data: {
name: 'RootFolder',
type: AssetType.folder,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
const v1 = await prisma.asset.create({
data: {
name: 'image.png',
type: AssetType.file,
projectId: project.id,
parentId: rootFolder.id,
status: AssetStatus.uploaded,
sizeByte: 2000n,
},
})
const triggerSpy = vi
.spyOn(uploadService, 'triggerPostUploadWorkflows')
.mockResolvedValue(undefined)
const v2Info = await assetService.createVersion({
parentId: v1.id,
name: 'image.png',
key: 'files/test/v2.png',
sizeByte: 3000,
contentType: 'image/png',
creatorId: user.id,
})
expect(v2Info.id).toBeDefined()
const v2Record = await prisma.asset.findUnique({
where: { id: v2Info.id },
include: { parent: true },
})
expect(v2Record?.parent?.type).toBe(AssetType.version_stack)
expect(v2Record?.parent?.parentId).toBe(rootFolder.id)
const v1Record = await prisma.asset.findUnique({ where: { id: v1.id } })
expect(v1Record?.parentId).toBe(v2Record?.parentId)
const stackRecord = await prisma.asset.findUnique({ where: { id: v2Record!.parentId! } })
expect(stackRecord?.fileCount).toBe(2)
expect(stackRecord?.sizeByte).toBe(5000n)
expect(triggerSpy).toHaveBeenCalledWith(expect.anything(), v2Info.id, team.id, project.id)
})
it('appends a new version when target is in an existing version stack', async () => {
const user = await prisma.user.create({
data: { name: 'VersionUser2', email: `veruser2-${Date.now()}@example.com` },
})
const team = await prisma.team.create({ data: { name: 'VersionTeam2' } })
const project = await prisma.project.create({
data: { name: 'VersionProject2', teamId: team.id },
})
const rootFolder = await prisma.asset.create({
data: {
name: 'RootFolder',
type: AssetType.folder,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
const stack = await prisma.asset.create({
data: {
name: 'image.png',
type: AssetType.version_stack,
projectId: project.id,
parentId: rootFolder.id,
status: AssetStatus.uploaded,
sizeByte: 2000n,
fileCount: 1,
},
})
const v1 = await prisma.asset.create({
data: {
name: 'image.png',
type: AssetType.file,
projectId: project.id,
parentId: stack.id,
status: AssetStatus.uploaded,
sortIndex: 'a0',
sizeByte: 2000n,
},
})
const triggerSpy = vi
.spyOn(uploadService, 'triggerPostUploadWorkflows')
.mockResolvedValue(undefined)
const v2Info = await assetService.createVersion({
parentId: v1.id,
name: 'image_v2.png',
key: 'files/test/v2.png',
sizeByte: 3000,
contentType: 'image/png',
creatorId: user.id,
})
expect(v2Info.id).toBeDefined()
const v2Record = await prisma.asset.findUnique({ where: { id: v2Info.id } })
expect(v2Record?.parentId).toBe(stack.id)
const stackAfter = await prisma.asset.findUnique({ where: { id: stack.id } })
expect(stackAfter?.fileCount).toBe(2)
expect(stackAfter?.sizeByte).toBe(5000n)
expect(triggerSpy).toHaveBeenCalledWith(expect.anything(), v2Info.id, team.id, project.id)
})
it('rolls back completely if workflow triggering fails in createVersion', async () => {
const user = await prisma.user.create({
data: { name: 'VersionRollbackUser', email: `verrollback-${Date.now()}@example.com` },
})
const team = await prisma.team.create({ data: { name: 'VersionRollbackTeam' } })
const project = await prisma.project.create({
data: { name: 'VersionRollbackProject', teamId: team.id },
})
const rootFolder = await prisma.asset.create({
data: {
name: 'RootFolder',
type: AssetType.folder,
projectId: project.id,
status: AssetStatus.uploaded,
sizeByte: 2000n,
fileCount: 1,
},
})
const v1 = await prisma.asset.create({
data: {
name: 'image.png',
type: AssetType.file,
projectId: project.id,
parentId: rootFolder.id,
status: AssetStatus.uploaded,
sizeByte: 2000n,
},
})
vi.spyOn(uploadService, 'triggerPostUploadWorkflows').mockRejectedValueOnce(
new Error('Simulated version workflow failure'),
)
await expect(
assetService.createVersion({
parentId: v1.id,
name: 'image_v2_fail.png',
key: 'files/test/v2_fail.png',
sizeByte: 3000,
contentType: 'image/png',
creatorId: user.id,
}),
).rejects.toThrow('Simulated version workflow failure')
// Check that new version was rolled back
const createdV2 = await prisma.asset.findFirst({
where: { name: 'image_v2_fail.png', projectId: project.id },
})
expect(createdV2).toBeNull()
// Check that v1 remains under rootFolder (no orphaned version stack created)
const v1After = await prisma.asset.findUnique({ where: { id: v1.id } })
expect(v1After?.parentId).toBe(rootFolder.id)
// Check root folder counters remained unchanged
const rootFolderAfter = await prisma.asset.findUnique({ where: { id: rootFolder.id } })
expect(rootFolderAfter?.fileCount).toBe(1)
expect(rootFolderAfter?.sizeByte).toBe(2000n)
})
})
describe('listChildren type filtering', () => {
it('returns files, folders, and version stacks when assetType is all or omitted', async () => {
const team = await prisma.team.create({ data: { name: 'ListTypeTeam' } })
const project = await prisma.project.create({
data: { name: 'ListTypeProject', teamId: team.id },
})
const rootFolder = await prisma.asset.create({
data: {
name: 'RootFolder',
type: AssetType.folder,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
const subFolder = await prisma.asset.create({
data: {
name: 'subfolder',
type: AssetType.folder,
projectId: project.id,
parentId: rootFolder.id,
status: AssetStatus.uploaded,
},
})
const file = await prisma.asset.create({
data: {
name: 'file.txt',
type: AssetType.file,
projectId: project.id,
parentId: rootFolder.id,
status: AssetStatus.uploaded,
},
})
const stack = await prisma.asset.create({
data: {
name: 'stack.png',
type: AssetType.version_stack,
projectId: project.id,
parentId: rootFolder.id,
status: AssetStatus.uploaded,
},
})
// Query with assetType: 'all'
const allRes = await assetService.listChildren({
assetId: rootFolder.id,
assetType: 'all',
})
const allIds = allRes.data.map((a) => a.id)
expect(allIds).toContain(subFolder.id)
expect(allIds).toContain(file.id)
expect(allIds).toContain(stack.id)
expect(allRes.data.length).toBe(3)
// Query with assetType: 'file'
const fileRes = await assetService.listChildren({
assetId: rootFolder.id,
assetType: 'file',
})
const fileIds = fileRes.data.map((a) => a.id)
expect(fileIds).toContain(file.id)
expect(fileIds).toContain(stack.id)
expect(fileIds).not.toContain(subFolder.id)
expect(fileRes.data.length).toBe(2)
// Query with assetType: 'folder'
const folderRes = await assetService.listChildren({
assetId: rootFolder.id,
assetType: 'folder',
})
const folderIds = folderRes.data.map((a) => a.id)
expect(folderIds).toContain(subFolder.id)
expect(folderIds).not.toContain(file.id)
expect(folderIds).not.toContain(stack.id)
expect(folderRes.data.length).toBe(1)
})
})
})
+428 -34
View File
@@ -16,6 +16,7 @@ import {
UpdateAssetNameRequest,
UpdateAssetOrderRequest,
AssetUserInfo,
ListRecentsRequest,
} from '@shumai/dtos'
import { type Asset, AssetStatus, AssetType, Prisma, type StorageKey } from '@shumai/db'
import { HTTPException } from 'hono/http-exception'
@@ -28,26 +29,30 @@ import { generateKeyBetween } from 'jittered-fractional-indexing'
import { getAvatarUrl } from '@shumai/core/src/user/avatar'
import { getAgentRequiredLevel, getRoleLevel } from '@shumai/core/src/agent/permissions'
import { resolveEffectiveRole } from '@shumai/core/src/authz/authz'
import { metadataService } from '@shumai/core/src/metadata/metadata'
import { uploadService } from '@shumai/core/src/upload/upload'
type AssetWithIncludes = Prisma.AssetGetPayload<{
include: {
creator: true
metadataValues: true
storageKey: true
target: {
include: {
creator: true
metadataValues: true
storageKey: true
children: {
include: { creator: true; metadataValues: true; storageKey: true }
}
}
}
children: {
include: { creator: true; metadataValues: true; storageKey: true }
}
}
export const assetInclude = {
creator: true,
metadataValues: true,
storageKey: true,
target: {
include: {
creator: true,
metadataValues: true,
storageKey: true,
children: {
include: { creator: true, metadataValues: true, storageKey: true },
},
},
},
children: {
include: { creator: true, metadataValues: true, storageKey: true },
},
} as const
export type AssetWithIncludes = Prisma.AssetGetPayload<{
include: typeof assetInclude
}>
type CommentWithIncludes = Prisma.AssetCommentGetPayload<{
@@ -206,6 +211,12 @@ export class AssetService {
return this.reparentFileToFile(tx, newParent, req.assetIds, req.creatorId)
}
if (newParent.type === AssetType.version_stack) {
if (req.assetIds.length !== 1) {
throw new Error('Can only move one file at a time into a version stack')
}
}
const assetsToMove = await tx.asset.findMany({
where: { id: { in: req.assetIds } },
include: { project: { include: { team: true } } },
@@ -217,6 +228,14 @@ export class AssetService {
if (assetsToMove.length === 0) return
if (newParent.type === AssetType.version_stack) {
for (const a of assetsToMove) {
if (a.type !== AssetType.file) {
throw new Error(`Cannot move ${a.type} asset into a version stack`)
}
}
}
let totalSize = 0
const oldParentId = assetsToMove[0].parentId
if (!oldParentId) {
@@ -519,6 +538,10 @@ export class AssetService {
assetIds: string[],
creatorId?: string,
) {
if (destFile.type !== AssetType.file) {
throw new Error('Destination asset must be a file')
}
if (assetIds.length !== 1) {
throw new Error('Can only reparent one file to another file')
}
@@ -534,6 +557,10 @@ export class AssetService {
if (!sourceAsset) throw new Error('Source asset not found')
if (sourceAsset.type !== AssetType.file) {
throw new Error('Source asset must be a file to create a version stack')
}
if (!sourceAsset.project || !sourceAsset.project.team) {
throw new Error(`Asset ${sourceAsset.id} is not associated with a team`)
}
@@ -611,9 +638,13 @@ export class AssetService {
}
async listChildren(req: ListChildrenRequest): Promise<PaginatedData<AssetInfo[]>> {
const typesToQuery: AssetType[] = [req.assetType as AssetType]
if (req.assetType === AssetType.file) {
typesToQuery.push(AssetType.version_stack)
let typesToQuery: AssetType[]
if (req.assetType === 'file') {
typesToQuery = [AssetType.file, AssetType.version_stack]
} else if (req.assetType === 'folder') {
typesToQuery = [AssetType.folder]
} else {
typesToQuery = [AssetType.file, AssetType.folder, AssetType.version_stack]
}
let where: Prisma.AssetWhereInput = {}
@@ -629,10 +660,7 @@ export class AssetService {
projectId: req.projectId,
isDeleted: true,
deletedAt: { gte: thirtyDaysAgo },
OR: [
{ type: { in: typesToQuery } },
{ type: AssetType.symlink, target: { type: { in: typesToQuery } } },
],
type: { in: typesToQuery },
}
} else {
if (!req.assetId) {
@@ -651,7 +679,7 @@ export class AssetService {
isDeleted: false,
OR: [
{ type: { in: typesToQuery } },
{ type: AssetType.symlink, target: { type: { in: typesToQuery } } },
{ type: AssetType.symlink, target: { isDeleted: false, type: { in: typesToQuery } } },
],
}
}
@@ -721,12 +749,17 @@ export class AssetService {
return { data: infos, pageInfo }
}
async createAsset(req: CreateAssetRequest): Promise<AssetInfo> {
async createAsset(
req: CreateAssetRequest,
txClient?: Prisma.TransactionClient,
): Promise<AssetInfo> {
const db = txClient ?? this.prismaClient
let projectId = req.projectId
let parent: Prisma.AssetGetPayload<{ include: { project: true } }> | null = null
if (req.parentId) {
parent = await this.prismaClient.asset.findUnique({
parent = await db.asset.findUnique({
where: { id: req.parentId },
include: { project: true },
})
@@ -738,7 +771,7 @@ export class AssetService {
let sortIndex: string | null = null
if (parent) {
const firstFile = await this.prismaClient.asset.findFirst({
const firstFile = await db.asset.findFirst({
where: { parentId: parent.id },
orderBy: { sortIndex: 'asc' },
})
@@ -766,7 +799,7 @@ export class AssetService {
if (req.contentType) data.mediaType = req.contentType
if (req.creatorId) data.creator = { connect: { id: req.creatorId } }
const asset = await this.prismaClient.$transaction(async (tx) => {
const executeInTx = async (tx: Prisma.TransactionClient) => {
const createdAsset = await tx.asset.create({
data,
include: {
@@ -803,12 +836,165 @@ export class AssetService {
}
return createdAsset
})
}
const asset = txClient
? await executeInTx(txClient)
: await this.prismaClient.$transaction(executeInTx)
const infos = await this.toAssetInfos([asset])
return infos[0]
}
async createFile(params: {
parentId: string
name: string
key: string
sizeByte: number
contentType: string
creatorId: string
metadata?: Record<string, unknown>
}): Promise<AssetInfo> {
const { parentId, name, key, sizeByte, contentType, creatorId, metadata } = params
const parentAsset = await this.prismaClient.asset.findUnique({
where: { id: parentId },
include: { project: true },
})
if (!parentAsset || !parentAsset.projectId || !parentAsset.project?.teamId) {
throw new Error(`Parent folder ${parentId} is invalid or has no project associated`)
}
if (metadata) {
await metadataService.validateCreationContextMetadata(
creatorId,
parentAsset.projectId,
metadata,
)
}
let newFileId = ''
await this.prismaClient.$transaction(async (tx) => {
const newFile = await this.createAsset(
{
name,
type: 'file',
parentId,
key,
sizeByte,
contentType,
creatorId,
},
tx,
)
newFileId = newFile.id
await this.updateAncestorsSize(tx, parentId, sizeByte)
if (metadata) {
const metadataUpdates = Object.entries(metadata)
.filter(([, value]) => value !== null)
.map(([k, v]) => ({ key: k, value: v }))
if (metadataUpdates.length > 0) {
await metadataService.updateAssetMetadataInTx(tx, newFile.id, metadataUpdates)
}
}
await uploadService.triggerPostUploadWorkflows(
tx,
newFile.id,
parentAsset.project!.teamId,
parentAsset.projectId!,
)
})
return this.getAsset({ assetId: newFileId })
}
async createVersion(params: {
parentId: string
name: string
key: string
sizeByte: number
contentType: string
creatorId: string
metadata?: Record<string, unknown>
}): Promise<AssetInfo> {
const { parentId, name, key, sizeByte, contentType, creatorId, metadata } = params
const targetAsset = await this.prismaClient.asset.findUnique({
where: { id: parentId },
include: { project: true, parent: true },
})
if (!targetAsset || !targetAsset.projectId || !targetAsset.project?.teamId) {
throw new Error(`Target file ${parentId} is invalid or has no project associated`)
}
if (metadata) {
await metadataService.validateCreationContextMetadata(
creatorId,
targetAsset.projectId,
metadata,
)
}
let targetFolderId: string
let reparentTargetId: string
if (targetAsset.type === AssetType.version_stack) {
targetFolderId = targetAsset.parentId!
reparentTargetId = targetAsset.id
} else if (targetAsset.parent?.type === AssetType.version_stack) {
targetFolderId = targetAsset.parent.parentId!
reparentTargetId = targetAsset.parentId!
} else {
targetFolderId = targetAsset.parentId!
reparentTargetId = targetAsset.id
}
let newFileId = ''
await this.prismaClient.$transaction(async (tx) => {
const newFile = await this.createAsset(
{
name,
type: 'file',
parentId: targetFolderId,
key,
sizeByte,
contentType,
creatorId,
},
tx,
)
newFileId = newFile.id
await this.reparentAssets(
{
assetIds: [newFile.id],
newParentId: reparentTargetId,
creatorId,
},
tx,
)
if (metadata) {
const metadataUpdates = Object.entries(metadata)
.filter(([, value]) => value !== null)
.map(([k, v]) => ({ key: k, value: v }))
if (metadataUpdates.length > 0) {
await metadataService.updateAssetMetadataInTx(tx, newFile.id, metadataUpdates)
}
}
await uploadService.triggerPostUploadWorkflows(
tx,
newFile.id,
targetAsset.project!.teamId,
targetAsset.projectId!,
)
})
return this.getAsset({ assetId: newFileId })
}
async findAsset(parentId: string, name: string): Promise<AssetInfo | null> {
const asset = await this.prismaClient.asset.findFirst({
where: { parentId, name },
@@ -1100,6 +1286,39 @@ export class AssetService {
})
}
const allDeletedIds = [a.id, ...descendantIds]
const symlinks = await tx.asset.findMany({
where: {
targetId: { in: allDeletedIds },
isDeleted: false,
type: AssetType.symlink,
},
})
if (symlinks.length > 0) {
await tx.asset.updateMany({
where: { id: { in: symlinks.map((s) => s.id) } },
data: {
isDeleted: true,
status: AssetStatus.trashed,
deletedAt: new Date(),
},
})
const parentCounts = new Map<string, number>()
for (const s of symlinks) {
if (s.parentId) {
parentCounts.set(s.parentId, (parentCounts.get(s.parentId) || 0) + 1)
}
}
for (const [parentId, count] of parentCounts.entries()) {
await tx.asset.update({
where: { id: parentId },
data: { fileCount: { decrement: count } },
})
}
}
await tx.asset.update({
where: { id: a.id },
data: {
@@ -1123,9 +1342,16 @@ export class AssetService {
UNION ALL
SELECT a.id FROM assets a
INNER JOIN descendant d ON a.parent_id = d.id
),
all_purging_targets AS (
SELECT id FROM descendant
),
all_affected_symlinks AS (
SELECT s.id FROM assets s
WHERE s.type = 'symlink' AND s.target_id IN (SELECT id FROM all_purging_targets)
)
UPDATE assets SET status = 'pending_purge', updated_at = NOW()
WHERE id IN (SELECT id FROM descendant);
WHERE id IN (SELECT id FROM all_purging_targets) OR id IN (SELECT id FROM all_affected_symlinks);
`
}
@@ -1311,6 +1537,39 @@ export class AssetService {
})
}
const allRestoredIds = [a.id, ...descendantIds]
const symlinks = await tx.asset.findMany({
where: {
targetId: { in: allRestoredIds },
isDeleted: true,
type: AssetType.symlink,
},
})
if (symlinks.length > 0) {
await tx.asset.updateMany({
where: { id: { in: symlinks.map((s) => s.id) } },
data: {
isDeleted: false,
status: AssetStatus.processed,
deletedAt: null,
},
})
const parentCounts = new Map<string, number>()
for (const s of symlinks) {
if (s.parentId) {
parentCounts.set(s.parentId, (parentCounts.get(s.parentId) || 0) + 1)
}
}
for (const [parentId, count] of parentCounts.entries()) {
await tx.asset.update({
where: { id: parentId },
data: { fileCount: { increment: count } },
})
}
}
await tx.asset.update({
where: { id: a.id },
data: {
@@ -1623,7 +1882,7 @@ export class AssetService {
return { data: infos, pageInfo }
}
private async toAssetInfos(assets: AssetWithIncludes[]): Promise<AssetInfo[]> {
async toAssetInfos(assets: AssetWithIncludes[]): Promise<AssetInfo[]> {
const stackIds = new Set<string>()
for (const a of assets) {
@@ -2360,6 +2619,141 @@ export class AssetService {
return results
}
/**
* Record a file view by user in project.
* If the asset is a child file in a version stack, resolves to the version stack.
* Enforces a maximum cap of 100 recent file items per (userId, projectId).
*/
async recordRecentView(userId: string, projectId: string, assetId: string): Promise<void> {
const asset = await this.prismaClient.asset.findFirst({
where: { id: assetId, projectId },
select: {
id: true,
type: true,
parentId: true,
isDeleted: true,
target: { select: { type: true, projectId: true, isDeleted: true } },
},
})
if (!asset || asset.isDeleted) return
const isFileAsset =
asset.type === AssetType.file ||
asset.type === AssetType.version_stack ||
(asset.type === AssetType.symlink &&
asset.target !== null &&
(asset.target.type === AssetType.file || asset.target.type === AssetType.version_stack) &&
asset.target.projectId === projectId &&
!asset.target.isDeleted)
if (!isFileAsset) return
let targetAssetId = asset.id
// If it's a file inside a version stack, record the version stack instead
if (asset.type === AssetType.file && asset.parentId) {
const parent = await this.prismaClient.asset.findFirst({
where: { id: asset.parentId, projectId, type: AssetType.version_stack, isDeleted: false },
select: { id: true },
})
if (parent) {
targetAssetId = parent.id
}
}
const now = new Date()
// Upsert into recent_file_items
await this.prismaClient.recentFileItem.upsert({
where: {
userIdProjectIdAssetId: {
userId,
projectId,
assetId: targetAssetId,
},
},
update: {
viewedAt: now,
},
create: {
userId,
projectId,
assetId: targetAssetId,
viewedAt: now,
},
})
// Prune if more than 100 items for this (userId, projectId)
const count = await this.prismaClient.recentFileItem.count({
where: { userId, projectId },
})
if (count > 100) {
const itemsToKeep = await this.prismaClient.recentFileItem.findMany({
where: { userId, projectId },
orderBy: [{ viewedAt: 'desc' }, { id: 'desc' }],
take: 100,
select: { id: true },
})
const keepIds = itemsToKeep.map((item) => item.id)
await this.prismaClient.recentFileItem.deleteMany({
where: {
userId,
projectId,
id: { notIn: keepIds },
},
})
}
}
/**
* List recent files for user in project, paginated up to 100 total items.
*/
async listRecents(
userId: string,
projectId: string,
req: ListRecentsRequest,
): Promise<PaginatedData<AssetInfo[]>> {
const where = {
userId,
projectId,
asset: {
isDeleted: false,
projectId,
},
}
return paginateQuery(
async (skip, take) => {
if (skip >= 100) return []
const effectiveTake = Math.min(take, 100 - skip)
if (effectiveTake <= 0) return []
const recents = await this.prismaClient.recentFileItem.findMany({
where,
orderBy: [{ viewedAt: 'desc' }, { id: 'desc' }],
skip,
take: effectiveTake,
include: {
asset: {
include: assetInclude,
},
},
})
const assets = recents.map((r) => r.asset).filter((a): a is AssetWithIncludes => !!a)
return await this.toAssetInfos(assets)
},
async () => {
const total = await this.prismaClient.recentFileItem.count({ where })
return Math.min(total, 100)
},
req,
)
}
}
export const assetService = new AssetService()
+278
View File
@@ -0,0 +1,278 @@
import { describe, it, expect } from 'vitest'
import { prisma, AssetType, AssetStatus } from '@shumai/db'
import { setupTestDbHooks } from '@shumai/db/test'
import { assetService } from './asset'
import { projectService } from '../project/project'
describe('AssetService - Recently Viewed', () => {
setupTestDbHooks()
async function setupProject() {
const user1 = await prisma.user.create({
data: { name: 'User 1', email: 'user1@example.com' },
})
const user2 = await prisma.user.create({
data: { name: 'User 2', email: 'user2@example.com' },
})
const team = await prisma.team.create({
data: {
name: 'Test Team',
settings: {
transcode: { videoStrategy: 'best_match' },
},
sandbox: { create: {} },
},
})
await prisma.teamMember.create({
data: {
teamId: team.id,
userId: user1.id,
role: 'owner',
scope: 'team',
},
})
await prisma.teamMember.create({
data: {
teamId: team.id,
userId: user2.id,
role: 'editor',
scope: 'team',
},
})
const project = await projectService.createProject(user1, {
name: 'Test Project',
teamId: team.id,
})
return { user1, user2, team, project }
}
it('records recent file view and returns it in descending order', async () => {
const { user1, project } = await setupProject()
const file1 = await prisma.asset.create({
data: {
name: 'file1.mp4',
type: AssetType.file,
status: 'processed',
projectId: project.id,
parentId: project.rootFolder!,
},
})
const file2 = await prisma.asset.create({
data: {
name: 'file2.mp4',
type: AssetType.file,
status: 'processed',
projectId: project.id,
parentId: project.rootFolder!,
},
})
await assetService.recordRecentView(user1.id, project.id, file1.id)
await assetService.recordRecentView(user1.id, project.id, file2.id)
const list = await assetService.listRecents(user1.id, project.id, {})
expect(list.data.length).toBe(2)
expect(list.data[0].id).toBe(file2.id)
expect(list.data[1].id).toBe(file1.id)
expect(list.pageInfo.total).toBe(2)
})
it('updates viewedAt when viewing the same file again', async () => {
const { user1, project } = await setupProject()
const file1 = await prisma.asset.create({
data: {
name: 'file1.mp4',
type: AssetType.file,
status: 'processed',
projectId: project.id,
parentId: project.rootFolder!,
},
})
const file2 = await prisma.asset.create({
data: {
name: 'file2.mp4',
type: AssetType.file,
status: 'processed',
projectId: project.id,
parentId: project.rootFolder!,
},
})
await assetService.recordRecentView(user1.id, project.id, file1.id)
await assetService.recordRecentView(user1.id, project.id, file2.id)
// View file1 again
await assetService.recordRecentView(user1.id, project.id, file1.id)
const list = await assetService.listRecents(user1.id, project.id, {})
expect(list.data.length).toBe(2)
expect(list.data[0].id).toBe(file1.id)
expect(list.data[1].id).toBe(file2.id)
})
it('records version stack when viewing a child version file', async () => {
const { user1, project } = await setupProject()
const stack = await prisma.asset.create({
data: {
name: 'version_stack',
type: AssetType.version_stack,
status: 'processed',
projectId: project.id,
parentId: project.rootFolder!,
},
})
const version1 = await prisma.asset.create({
data: {
name: 'v1.mp4',
type: AssetType.file,
status: 'processed',
projectId: project.id,
parentId: stack.id,
},
})
await assetService.recordRecentView(user1.id, project.id, version1.id)
const list = await assetService.listRecents(user1.id, project.id, {})
expect(list.data.length).toBe(1)
expect(list.data[0].id).toBe(stack.id)
expect(list.data[0].type).toBe(AssetType.version_stack)
})
it('isolates recents per user', async () => {
const { user1, user2, project } = await setupProject()
const file1 = await prisma.asset.create({
data: {
name: 'file1.mp4',
type: AssetType.file,
status: 'processed',
projectId: project.id,
parentId: project.rootFolder!,
},
})
await assetService.recordRecentView(user1.id, project.id, file1.id)
const user1List = await assetService.listRecents(user1.id, project.id, {})
const user2List = await assetService.listRecents(user2.id, project.id, {})
expect(user1List.data.length).toBe(1)
expect(user2List.data.length).toBe(0)
})
it('does not record assets from another project', async () => {
const { user1, team, project } = await setupProject()
const otherProject = await projectService.createProject(user1, {
name: 'Other Project',
teamId: team.id,
})
const foreignFile = await prisma.asset.create({
data: {
name: 'foreign-file.mp4',
type: AssetType.file,
status: AssetStatus.processed,
projectId: otherProject.id,
parentId: otherProject.rootFolder!,
},
})
await assetService.recordRecentView(user1.id, project.id, foreignFile.id)
const list = await assetService.listRecents(user1.id, project.id, {})
expect(list.data).toHaveLength(0)
})
it('does not record non-file assets', async () => {
const { user1, project } = await setupProject()
const folder = await prisma.asset.create({
data: {
name: 'folder',
type: AssetType.folder,
status: AssetStatus.processed,
projectId: project.id,
parentId: project.rootFolder!,
},
})
await assetService.recordRecentView(user1.id, project.id, folder.id)
const list = await assetService.listRecents(user1.id, project.id, {})
expect(list.data).toHaveLength(0)
})
it('does not return soft-deleted files in recents', async () => {
const { user1, project } = await setupProject()
const file1 = await prisma.asset.create({
data: {
name: 'file1.mp4',
type: AssetType.file,
status: 'processed',
projectId: project.id,
parentId: project.rootFolder!,
},
})
await assetService.recordRecentView(user1.id, project.id, file1.id)
// Soft delete file1
await prisma.asset.update({
where: { id: file1.id },
data: { isDeleted: true, status: 'trashed' },
})
const list = await assetService.listRecents(user1.id, project.id, {})
expect(list.data.length).toBe(0)
})
it('caps recents at 100 items per user/project', async () => {
const { user1, project } = await setupProject()
// Batch create 105 assets
const assetsData = Array.from({ length: 105 }, (_, i) => ({
name: `file_${i}.mp4`,
type: AssetType.file,
status: AssetStatus.processed,
projectId: project.id,
parentId: project.rootFolder!,
}))
await prisma.asset.createMany({ data: assetsData })
const allAssets = await prisma.asset.findMany({
where: { projectId: project.id, parentId: project.rootFolder! },
orderBy: { id: 'asc' },
})
// Seed 100 items in recentFileItem
const baseDate = new Date('2026-01-01T00:00:00Z')
await prisma.recentFileItem.createMany({
data: allAssets.slice(0, 100).map((a, i) => ({
userId: user1.id,
projectId: project.id,
assetId: a.id,
viewedAt: new Date(baseDate.getTime() + i * 1000),
})),
})
// Now record view for the 101st asset to trigger pruning
const newAsset = allAssets[100]
await assetService.recordRecentView(user1.id, project.id, newAsset.id)
const count = await prisma.recentFileItem.count({
where: { userId: user1.id, projectId: project.id },
})
expect(count).toBe(100)
const list = await assetService.listRecents(user1.id, project.id, { first: 100 })
expect(list.data.length).toBe(100)
// The most recently viewed file should be newAsset
expect(list.data[0].id).toBe(newAsset.id)
// The oldest file (allAssets[0]) should have been pruned
expect(list.data.some((d) => d.id === allAssets[0].id)).toBe(false)
}, 15000)
})
+212 -1
View File
@@ -1,7 +1,7 @@
import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest'
import { prisma } from '@shumai/db'
import { setupTestDbHooks } from '@shumai/db/test'
import { auth } from './auth'
import { auth, authService } from './auth'
import { userMetadataService } from '../user-metadata/user-metadata'
import { teamService } from '@shumai/core/src/team/team'
@@ -93,3 +93,214 @@ describe('Auth Signup Locale Hook', () => {
}
})
})
describe('AuthService Password Reset', () => {
setupTestDbHooks()
beforeEach(() => {
vi.spyOn(teamService, 'getSignupInfo').mockResolvedValue({
initialized: false,
demoMode: false,
userCount: 1,
})
})
it('should throw error when generating reset link for non-existent user', async () => {
await expect(authService.generatePasswordResetLink('nonexistent@example.com')).rejects.toThrow(
'User with email "nonexistent@example.com" not found',
)
})
it('should generate a valid reset link and invalidate previous pending tokens', async () => {
const email = `reset-user-${Date.now()}@example.com`
const signUpRes = await auth.api.signUpEmail({
headers: new Headers(),
body: {
email,
password: 'initialPassword123',
name: 'Reset User',
},
})
const userId = signUpRes.user.id
const firstLink = await authService.generatePasswordResetLink(email)
expect(firstLink).toContain('/reset-password?token=')
const firstToken = new URL(firstLink).searchParams.get('token')!
expect(firstToken).toBeTruthy()
// Check that verification record exists with identifier: reset-password:<token> and value: userId
const firstVerification = await prisma.verification.findFirst({
where: { identifier: `reset-password:${firstToken}` },
})
expect(firstVerification).not.toBeNull()
expect(firstVerification?.value).toBe(userId)
// Generating a second link should produce a new token and invalidate the first token
const secondLink = await authService.generatePasswordResetLink(email)
const secondToken = new URL(secondLink).searchParams.get('token')!
expect(secondToken).not.toBe(firstToken)
const newVerification = await prisma.verification.findFirst({
where: { identifier: `reset-password:${secondToken}` },
})
expect(newVerification).not.toBeNull()
expect(newVerification?.value).toBe(userId)
// The first token's verification record must have been deleted
const oldVerification = await prisma.verification.findFirst({
where: { identifier: `reset-password:${firstToken}` },
})
expect(oldVerification).toBeNull()
// First token must fail to reset password
await expect(
authService.resetPassword(firstToken, 'newPasswordFromFirstToken'),
).rejects.toThrow()
// Second token must succeed
const resetRes = await authService.resetPassword(secondToken, 'newPasswordFromSecondToken')
expect(resetRes.success).toBe(true)
})
it('should reset password with valid token and revoke active sessions', async () => {
const email = `reset-valid-${Date.now()}@example.com`
const signUpRes = await auth.api.signUpEmail({
headers: new Headers(),
body: {
email,
password: 'oldPassword123',
name: 'Valid Reset User',
},
})
const userId = signUpRes.user.id
// Create an active session
await prisma.session.create({
data: {
userId,
token: `session-${Date.now()}`,
expiresAt: new Date(Date.now() + 86400 * 1000),
},
})
const activeSessionsBefore = await prisma.session.findMany({
where: { userId },
})
expect(activeSessionsBefore.length).toBeGreaterThan(0)
// Generate reset link
const link = await authService.generatePasswordResetLink(email)
const token = new URL(link).searchParams.get('token')!
// Reset password
const result = await authService.resetPassword(token, 'newPassword456')
expect(result.success).toBe(true)
// Verify active sessions are revoked
const activeSessionsAfter = await prisma.session.findMany({
where: { userId },
})
expect(activeSessionsAfter.length).toBe(0)
// Verify token was deleted
const usedToken = await prisma.verification.findFirst({
where: { identifier: `reset-password:${token}` },
})
expect(usedToken).toBeNull()
// Verify user password was updated to new password
const account = await prisma.account.findFirst({
where: { userId, providerId: 'credential' },
})
expect(account).toBeDefined()
expect(account?.password).toBeTruthy()
const { verifyPassword } = await import('better-auth/crypto')
const isNewValid = await verifyPassword({
hash: account!.password!,
password: 'newPassword456',
})
expect(isNewValid).toBe(true)
const isOldValid = await verifyPassword({
hash: account!.password!,
password: 'oldPassword123',
})
expect(isOldValid).toBe(false)
})
it('should reject expired or invalid token', async () => {
const email = `reset-expired-${Date.now()}@example.com`
const user = await prisma.user.create({
data: {
email,
name: 'Expired User',
},
})
// Create expired token fixture with identifier: reset-password:<token> and value: userId
const token = 'expired-token-123'
await prisma.verification.create({
data: {
identifier: `reset-password:${token}`,
value: user.id,
expiresAt: new Date(Date.now() - 1000), // Expired 1 second ago
},
})
await expect(authService.resetPassword(token, 'newPassword123')).rejects.toThrow()
// Non-existent token
await expect(
authService.resetPassword('non-existent-token', 'newPassword123'),
).rejects.toThrow()
})
it('should handle concurrent link generation for different users without crosstalk', async () => {
const emailA = `concurrent-a-${Date.now()}@example.com`
const emailB = `concurrent-b-${Date.now()}@example.com`
const [resA, resB] = await Promise.all([
auth.api.signUpEmail({
headers: new Headers(),
body: { email: emailA, password: 'passwordA123', name: 'User A' },
}),
auth.api.signUpEmail({
headers: new Headers(),
body: { email: emailB, password: 'passwordB123', name: 'User B' },
}),
])
const [linkA, linkB] = await Promise.all([
authService.generatePasswordResetLink(emailA),
authService.generatePasswordResetLink(emailB),
])
const tokenA = new URL(linkA).searchParams.get('token')!
const tokenB = new URL(linkB).searchParams.get('token')!
expect(tokenA).toBeTruthy()
expect(tokenB).toBeTruthy()
expect(tokenA).not.toBe(tokenB)
const verificationA = await prisma.verification.findFirst({
where: { identifier: `reset-password:${tokenA}` },
})
const verificationB = await prisma.verification.findFirst({
where: { identifier: `reset-password:${tokenB}` },
})
expect(verificationA?.value).toBe(resA.user.id)
expect(verificationB?.value).toBe(resB.user.id)
// Reset both passwords concurrently
const [resetResA, resetResB] = await Promise.all([
authService.resetPassword(tokenA, 'newPasswordA123'),
authService.resetPassword(tokenB, 'newPasswordB123'),
])
expect(resetResA.success).toBe(true)
expect(resetResB.success).toBe(true)
})
})
+96
View File
@@ -1,3 +1,4 @@
import { AsyncLocalStorage } from 'node:async_hooks'
import { betterAuth } from 'better-auth'
import { prismaAdapter } from 'better-auth/adapters/prisma'
import { prisma } from '@shumai/db'
@@ -6,6 +7,13 @@ import { inviteService } from '@shumai/core/src/invite/invite'
import { createAuthMiddleware } from 'better-auth/api'
import { userMetadataService } from '@shumai/core/src/user-metadata/user-metadata'
interface GeneratedResetLink {
url: string
token: string
}
const resetLinkStorage = new AsyncLocalStorage<GeneratedResetLink>()
export const auth = betterAuth({
database: prismaAdapter(prisma, {
provider: 'postgresql',
@@ -13,6 +21,15 @@ export const auth = betterAuth({
emailAndPassword: {
enabled: true,
minPasswordLength: 3,
revokeSessionsOnPasswordReset: true,
resetPasswordTokenExpiresIn: 3600,
sendResetPassword: async ({ url, token }) => {
const store = resetLinkStorage.getStore()
if (store) {
store.url = url
store.token = token
}
},
},
secret: process.env.BETTER_AUTH_SECRET,
// eslint-disable-next-line @typescript-eslint/naming-convention
@@ -122,3 +139,82 @@ export const auth = betterAuth({
}),
},
})
export class AuthService {
constructor(private readonly prismaClient: typeof prisma = prisma) {}
async generatePasswordResetLink(email: string): Promise<string> {
const user = await this.prismaClient.user.findUnique({
where: { email },
})
if (!user) {
throw new Error(`User with email "${email}" not found`)
}
const context: GeneratedResetLink = { url: '', token: '' }
await resetLinkStorage.run(context, async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const res = await (auth.api.requestPasswordReset as any)({
headers: new Headers(),
body: {
email,
redirectTo: '/reset-password',
},
})
if (res?.error) {
throw new Error(res.error.message || 'Failed to generate reset link')
}
})
if (context.token) {
// Invalidate any other pending reset tokens for this user
await this.prismaClient.verification.deleteMany({
where: {
value: user.id,
identifier: {
startsWith: 'reset-password:',
not: `reset-password:${context.token}`,
},
},
})
const rawBaseUrl =
process.env.BETTER_AUTH_URL ||
`http://localhost:${process.env.SHUMAI_SERVER_PORT || '3000'}`
const baseUrl = rawBaseUrl.replace(/\/$/, '')
return `${baseUrl}/reset-password?token=${context.token}`
}
throw new Error('Failed to generate reset link')
}
async resetPassword(token: string, newPassword: string): Promise<{ success: boolean }> {
if (!token || !token.trim()) {
throw new Error('Token is required')
}
if (!newPassword || newPassword.length < 3) {
throw new Error('Password must be at least 3 characters')
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const res = await (auth.api.resetPassword as any)({
headers: new Headers(),
body: {
token,
newPassword,
password: newPassword,
},
})
if (res?.error) {
throw new Error(res.error.message || 'Failed to reset password')
}
return { success: true }
}
}
export const authService = new AuthService()
+88
View File
@@ -613,6 +613,53 @@ describe('ChatService', () => {
expect(mapEntryToMessage(leafRecord)).toBeNull()
})
it('should map shumai_message custom_message entries with clean text and structured details', () => {
const entryRecord = {
id: 'entry-shumai-msg',
type: 'custom_message',
parentId: null,
createdAt: new Date('2026-07-07T00:05:00.000Z'),
data: {
customType: 'shumai_message',
content: 'Please adjust color grading',
display: true,
details: {
user: { id: 'u1', name: 'Alice', role: 'editor' },
currentAsset: { id: 'a1', name: 'video.mp4', type: 'file' },
position: { type: 'time', seconds: 12.5 },
},
},
} as unknown as Parameters<typeof mapEntryToMessage>[0]
const msg = mapEntryToMessage(entryRecord)
expect(msg).toBeDefined()
expect(msg?.id).toBe('entry-shumai-msg')
expect(msg?.role).toBe('custom')
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expect((msg as any)?.customType).toBe('shumai_message')
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expect((msg as any)?.content).toBe('Please adjust color grading')
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expect((msg as any)?.details?.user?.name).toBe('Alice')
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expect((msg as any)?.details?.position?.seconds).toBe(12.5)
})
it('should skip legacy context custom_message in mapEntryToMessage', () => {
const entryRecord = {
id: 'entry-legacy-context',
type: 'custom_message',
parentId: null,
createdAt: new Date('2026-07-07T00:05:00.000Z'),
data: {
customType: 'context',
content: 'System context prompt...',
},
} as unknown as Parameters<typeof mapEntryToMessage>[0]
expect(mapEntryToMessage(entryRecord)).toBeNull()
})
describe('getNewSessionMessages', () => {
it('returns new messages and lastEntryId', async () => {
const { user, team, project } = await setupBasicData()
@@ -900,5 +947,46 @@ describe('ChatService', () => {
}),
).rejects.toThrow(/Insufficient role/)
})
it('safely maps entries without message object or with customType shumai_message', () => {
// 1. Entry with type: 'message' but customType: 'shumai_message'
const legacyEntry = {
id: 'legacy-1',
sessionId: 'sess-1',
assetId: null,
parentId: null,
type: 'message',
data: {
customType: 'shumai_message',
content: 'Hello legacy',
display: true,
details: { user: { id: 'u1', name: 'User 1' } },
},
createdAt: new Date(),
}
const msg1 = mapEntryToMessage(legacyEntry)
expect(msg1).toBeDefined()
expect(msg1?.role).toBe('custom')
if (msg1 && msg1.role === 'custom') {
expect(msg1.customType).toBe('shumai_message')
expect(msg1.content).toBe('Hello legacy')
expect(msg1.details).toEqual({ user: { id: 'u1', name: 'User 1' } })
}
// 2. Entry with type: 'message' but empty data / no message
const emptyEntry = {
id: 'empty-1',
sessionId: 'sess-1',
assetId: null,
parentId: null,
type: 'message',
data: {},
createdAt: new Date(),
}
const msg2 = mapEntryToMessage(emptyEntry)
expect(msg2).toBeNull()
})
})
})
+30 -6
View File
@@ -30,11 +30,31 @@ export function buildSessionMessages(pathEntries: PathEntry[]): ChatMessage[] {
const appendMessage = (entry: PathEntry) => {
const timestampMs = new Date(entry.timestamp).getTime()
if (entry.type === 'message') {
messages.push({
...entry.message,
id: entry.id,
timestamp: entry.message.timestamp || timestampMs,
} as unknown as ChatMessage)
if ((entry as unknown as { customType?: string }).customType === 'shumai_message') {
const customEntry = entry as unknown as {
customType: string
content: string
display?: boolean
details?: Record<string, unknown>
}
messages.push({
id: entry.id,
role: 'custom',
customType: customEntry.customType,
content: customEntry.content,
display: customEntry.display,
details: customEntry.details,
timestamp: timestampMs,
} as unknown as ChatMessage)
return
}
if (entry.message) {
messages.push({
...entry.message,
id: entry.id,
timestamp: entry.message.timestamp || timestampMs,
} as unknown as ChatMessage)
}
} else if (entry.type === 'custom_message') {
if (entry.customType === 'context') return
messages.push({
@@ -117,9 +137,13 @@ export function mapEntryToMessage(
entryRecord: Prisma.AgentSessionEntryGetPayload<Record<string, never>>,
): ChatMessage | null {
const payload = (entryRecord.data as Record<string, unknown>) || {}
let type = (entryRecord.type || 'message') as SessionTreeEntry['type']
if (type === 'message' && payload.customType === 'shumai_message') {
type = 'custom_message'
}
const entryObj = {
id: entryRecord.id,
type: (entryRecord.type || 'message') as SessionTreeEntry['type'],
type,
parentId: entryRecord.parentId,
timestamp: entryRecord.createdAt.toISOString(),
...payload,
@@ -549,4 +549,65 @@ describe('MetadataService', () => {
]),
).rejects.toThrow('expected string or {newOption}')
})
describe('validateCreationContextMetadata', () => {
it('passes for allowed CREATION_CONTEXT fields and throws for invalid fields', async () => {
const team = await prisma.team.create({ data: { name: 'test-team-meta' } })
const project = await prisma.project.create({
data: { name: 'test-project-meta', teamId: team.id },
})
const validField = await prisma.metadataField.create({
data: {
key: 'prompt_field',
scope: 'PROJECT',
project: { connect: { id: project.id } },
config: {
name: 'Prompt',
type: 'text',
autofillSource: 'CREATION_CONTEXT',
},
},
})
await prisma.metadataField.create({
data: {
key: 'other_field',
scope: 'PROJECT',
project: { connect: { id: project.id } },
config: {
name: 'Other',
type: 'text',
autofillSource: 'NONE',
},
},
})
// Valid: empty metadata or null/undefined
await expect(
metadataService.validateCreationContextMetadata(null, project.id, null),
).resolves.toBeUndefined()
await expect(
metadataService.validateCreationContextMetadata(null, project.id, {}),
).resolves.toBeUndefined()
// Valid: allowed key
await expect(
metadataService.validateCreationContextMetadata(null, project.id, {
[validField.key]: 'valid value',
}),
).resolves.toBeUndefined()
// Invalid: non-CREATION_CONTEXT key or non-existent key
await expect(
metadataService.validateCreationContextMetadata(null, project.id, {
otherField: 'value',
}),
).rejects.toThrow(/metadata contains keys that are not valid in this project/)
await expect(
metadataService.validateCreationContextMetadata(null, project.id, {
randomFakeKey: 'value',
}),
).rejects.toThrow(/metadata contains keys that are not valid in this project/)
})
})
})
+23
View File
@@ -215,6 +215,29 @@ export class MetadataService {
return res
}
async validateCreationContextMetadata(
userId: string | null,
projectId: string,
metadata?: Record<string, unknown> | null,
): Promise<void> {
if (!metadata || Object.keys(metadata).length === 0) return
const fields = await this.listProjectFields(userId, projectId)
const allowedKeys = new Set(
fields
.filter((f) => f.field.config?.autofillSource === 'CREATION_CONTEXT')
.map((f) => f.field.key),
)
const invalidKeys = Object.keys(metadata).filter((key) => !allowedKeys.has(key))
if (invalidKeys.length > 0) {
throw new Error(
`metadata contains keys that are not valid in this project: ${invalidKeys.join(', ')}. ` +
"The valid metadata fields are fixed to the current conversation's project. " +
'If the target folder or file belongs to a different project, call the tool WITHOUT the metadata parameter.',
)
}
}
private async getProjectFieldsOrder(
userId: string,
projectId: string,
+157
View File
@@ -335,4 +335,161 @@ describe('ShareService', () => {
const item = list.data.find((l) => l.id === shareLink.id)
expect(item?.creator?.image).toBe('http://s3/avatars/user123-presigned.png')
})
it('hides soft-deleted files from share link and restores them upon file restoration', async () => {
const project = await prisma.project.findUniqueOrThrow({ where: { id: projectId } })
const file = await prisma.asset.create({
data: {
name: 'shared-doc.pdf',
type: AssetType.file,
status: 'processed',
projectId,
parentId: project.rootFolderId,
},
})
const shareLink = await shareService.createShareLink(projectId, {
name: 'Doc Share',
})
await shareService.addAssetToShare(shareLink.id, {
assetIds: [file.id],
})
// Verify initial state: 1 file in share link
const initialChildren = await assetService.listChildren({
assetId: shareLink.rootFolderId,
assetType: 'file',
})
expect(initialChildren.data).toHaveLength(1)
expect(initialChildren.data[0].name).toBe('shared-doc.pdf')
const initialShareRoot = await prisma.asset.findUnique({
where: { id: shareLink.rootFolderId },
})
expect(initialShareRoot?.fileCount).toBe(1)
const symlink = await prisma.asset.findFirst({
where: { targetId: file.id, parentId: shareLink.rootFolderId },
})
expect(symlink).toBeDefined()
await expect(shareService.verifyPublicAccess(file.id)).resolves.toBeDefined()
await expect(shareService.verifyPublicAccess(symlink!.id)).resolves.toBeDefined()
// 1. Soft-delete the file (move to trash)
await assetService.deleteAssets([file.id])
// Verify: file should disappear from share link children
const afterDeleteChildren = await assetService.listChildren({
assetId: shareLink.rootFolderId,
assetType: 'file',
})
expect(afterDeleteChildren.data).toHaveLength(0)
// Verify: share root fileCount should be decremented to 0
const afterDeleteShareRoot = await prisma.asset.findUnique({
where: { id: shareLink.rootFolderId },
})
expect(afterDeleteShareRoot?.fileCount).toBe(0)
// Verify: public access is rejected
await expect(shareService.verifyPublicAccess(file.id)).rejects.toThrow()
await expect(shareService.verifyPublicAccess(symlink!.id)).rejects.toThrow()
// Verify: project's recently-deleted view does NOT list symlinks
const recentlyDeleted = await assetService.listChildren({
projectId,
showDeleted: true,
assetType: 'file',
})
expect(recentlyDeleted.data).toHaveLength(1)
expect(recentlyDeleted.data[0].id).toBe(file.id)
// 2. Restore the file from trash
await assetService.restoreAssets([file.id])
// Verify: file reappears in share link children
const afterRestoreChildren = await assetService.listChildren({
assetId: shareLink.rootFolderId,
assetType: 'file',
})
expect(afterRestoreChildren.data).toHaveLength(1)
expect(afterRestoreChildren.data[0].name).toBe('shared-doc.pdf')
// Verify: share root fileCount is restored to 1
const afterRestoreShareRoot = await prisma.asset.findUnique({
where: { id: shareLink.rootFolderId },
})
expect(afterRestoreShareRoot?.fileCount).toBe(1)
// Verify: public access works again
await expect(shareService.verifyPublicAccess(file.id)).resolves.toBeDefined()
await expect(shareService.verifyPublicAccess(symlink!.id)).resolves.toBeDefined()
})
it('hides soft-deleted folders from share link and restores them upon folder restoration', async () => {
const project = await prisma.project.findUniqueOrThrow({ where: { id: projectId } })
const folder = await prisma.asset.create({
data: {
name: 'Shared Folder',
type: AssetType.folder,
status: 'processed',
projectId,
parentId: project.rootFolderId,
},
})
const childFile = await prisma.asset.create({
data: {
name: 'inner-file.txt',
type: AssetType.file,
status: 'processed',
projectId,
parentId: folder.id,
},
})
const shareLink = await shareService.createShareLink(projectId, {
name: 'Folder Share',
})
await shareService.addAssetToShare(shareLink.id, {
assetIds: [folder.id],
})
// Initial check: folder is in share link
const initialChildren = await assetService.listChildren({
assetId: shareLink.rootFolderId,
assetType: 'folder',
})
expect(initialChildren.data).toHaveLength(1)
expect(initialChildren.data[0].name).toBe('Shared Folder')
await expect(shareService.verifyPublicAccess(childFile.id)).resolves.toBeDefined()
// 1. Soft-delete the folder
await assetService.deleteAssets([folder.id])
// Verify: folder disappears from share link
const afterDeleteChildren = await assetService.listChildren({
assetId: shareLink.rootFolderId,
assetType: 'folder',
})
expect(afterDeleteChildren.data).toHaveLength(0)
// Verify: access to child file inside folder is rejected
await expect(shareService.verifyPublicAccess(childFile.id)).rejects.toThrow()
// 2. Restore the folder
await assetService.restoreAssets([folder.id])
// Verify: folder reappears in share link
const afterRestoreChildren = await assetService.listChildren({
assetId: shareLink.rootFolderId,
assetType: 'folder',
})
expect(afterRestoreChildren.data).toHaveLength(1)
expect(afterRestoreChildren.data[0].name).toBe('Shared Folder')
// Verify: access to child file inside folder is restored
await expect(shareService.verifyPublicAccess(childFile.id)).resolves.toBeDefined()
})
})
+4 -2
View File
@@ -260,16 +260,17 @@ export class ShareService {
WITH RECURSIVE
-- Trace ancestors in the real asset tree
real_ancestors AS (
SELECT id, parent_id, type::text FROM assets WHERE id = ${assetId}
SELECT id, parent_id, type::text FROM assets WHERE id = ${assetId} AND is_deleted = false
UNION ALL
SELECT a.id, a.parent_id, a.type::text FROM assets a
INNER JOIN real_ancestors ra ON ra.parent_id = a.id
WHERE a.is_deleted = false
),
-- Find all symlinks pointing to any of these real ancestors
found_symlinks AS (
SELECT s.id, s.parent_id, s.type::text FROM assets s
INNER JOIN real_ancestors ra ON s.target_id = ra.id
WHERE s.type = 'symlink'
WHERE s.type = 'symlink' AND s.is_deleted = false
),
-- Combine: start with either real ancestors that are 'share' type, or symlinks that lead to 'share' type
search_starts AS (
@@ -283,6 +284,7 @@ export class ShareService {
UNION ALL
SELECT a.id, a.parent_id, a.type::text FROM assets a
INNER JOIN share_trace st ON st.parent_id = a.id
WHERE a.is_deleted = false
)
SELECT id as "shareRootId" FROM share_trace WHERE type = 'share' LIMIT 1;
`
+2 -1
View File
@@ -371,11 +371,12 @@ describe('TeamService', () => {
expect(newSettings).toEqual({ theme: 'dark', semanticSearchEnabled: false })
await teamService.updateSettings(team.id, 'transcode.videoStrategy', 'all')
await teamService.updateSettings(team.id, 'transcode.hardwareAcceleration', 'auto')
const finalSettings = await teamService.getSettings(team.id)
expect(finalSettings).toEqual({
theme: 'dark',
transcode: { videoStrategy: 'all' },
transcode: { videoStrategy: 'all', hardwareAcceleration: 'auto' },
semanticSearchEnabled: false,
})
})
+7 -1
View File
@@ -31,7 +31,7 @@ export class TeamService {
data: {
name: 'Default Team',
settings: {
transcode: { videoStrategy: 'best_match' },
transcode: { videoStrategy: 'best_match', hardwareAcceleration: 'off' },
},
sandbox: { create: {} },
},
@@ -318,6 +318,12 @@ export class TeamService {
}
settings.transcode.videoStrategy = value
delete settings['transcode.videoStrategy']
} else if (key === 'transcode.hardwareAcceleration') {
if (!settings.transcode) {
settings.transcode = {}
}
settings.transcode.hardwareAcceleration = value
delete settings['transcode.hardwareAcceleration']
} else {
settings[key] = value
}
+626 -1
View File
@@ -1,5 +1,13 @@
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
import { transcodeService, calculatePreviewDimensions } from './transcode'
import {
transcodeService,
calculatePreviewDimensions,
getPlatformEncoderCandidates,
getDefaultBitrate,
getDefaultBitrateBps,
calculateMaxBitrate,
H264_ENCODER_CONFIGS,
} from './transcode'
import { s3Service } from '@shumai/core/src/s3/s3'
import * as path from 'path'
import * as child_process from 'child_process'
@@ -109,6 +117,118 @@ describe('TranscodeService', () => {
)
})
it('should extract videoBitRate from stream bit_rate or tags or fallback correctly', async () => {
/* eslint-disable @typescript-eslint/naming-convention */
// 1. Direct video stream bit_rate
const output1 = JSON.stringify({
format: { duration: '10', bit_rate: '2000000' },
streams: [
{ codec_type: 'video', width: 1920, height: 1080, bit_rate: '1800000' },
{ codec_type: 'audio', bit_rate: '128000' },
],
})
vi.mocked(execFile).mockImplementation(
(
_cmd: unknown,
_args: unknown,
callback: unknown,
): ReturnType<typeof child_process.execFile> => {
const cb = callback as (
err: Error | null,
result: { stdout: string; stderr: string },
) => void
if (typeof cb === 'function') {
cb(null, { stdout: output1, stderr: '' })
}
return {} as ReturnType<typeof child_process.execFile>
},
)
const info1 = await transcodeService.getVideoInfo('test1.mp4')
expect(info1.videoBitRate).toBe(1800000)
// 2. Stream BPS tag
const output2 = JSON.stringify({
format: { duration: '10', bit_rate: '2000000' },
streams: [
{ codec_type: 'video', width: 1920, height: 1080, tags: { BPS: '1500000' } },
{ codec_type: 'audio', bit_rate: '128000' },
],
})
vi.mocked(execFile).mockImplementation(
(
_cmd: unknown,
_args: unknown,
callback: unknown,
): ReturnType<typeof child_process.execFile> => {
const cb = callback as (
err: Error | null,
result: { stdout: string; stderr: string },
) => void
if (typeof cb === 'function') {
cb(null, { stdout: output2, stderr: '' })
}
return {} as ReturnType<typeof child_process.execFile>
},
)
const info2 = await transcodeService.getVideoInfo('test2.mp4')
expect(info2.videoBitRate).toBe(1500000)
// 3. Stream NUMBER_OF_BYTES tag
const output3 = JSON.stringify({
format: { duration: '10', bit_rate: '2000000' },
streams: [
{ codec_type: 'video', width: 1920, height: 1080, tags: { NUMBER_OF_BYTES: '1000000' } },
{ codec_type: 'audio', bit_rate: '128000' },
],
})
vi.mocked(execFile).mockImplementation(
(
_cmd: unknown,
_args: unknown,
callback: unknown,
): ReturnType<typeof child_process.execFile> => {
const cb = callback as (
err: Error | null,
result: { stdout: string; stderr: string },
) => void
if (typeof cb === 'function') {
cb(null, { stdout: output3, stderr: '' })
}
return {} as ReturnType<typeof child_process.execFile>
},
)
const info3 = await transcodeService.getVideoInfo('test3.mp4')
expect(info3.videoBitRate).toBe(800000) // (1,000,000 * 8) / 10 = 800,000
// 4. Fallback totalBitrate - audioBitrate
const output4 = JSON.stringify({
format: { duration: '10', bit_rate: '1000000' },
streams: [
{ codec_type: 'video', width: 1920, height: 1080 },
{ codec_type: 'audio', bit_rate: '128000' },
],
})
/* eslint-enable @typescript-eslint/naming-convention */
vi.mocked(execFile).mockImplementation(
(
_cmd: unknown,
_args: unknown,
callback: unknown,
): ReturnType<typeof child_process.execFile> => {
const cb = callback as (
err: Error | null,
result: { stdout: string; stderr: string },
) => void
if (typeof cb === 'function') {
cb(null, { stdout: output4, stderr: '' })
}
return {} as ReturnType<typeof child_process.execFile>
},
)
const info4 = await transcodeService.getVideoInfo('test4.mp4')
expect(info4.videoBitRate).toBe(872000) // 1,000,000 - 128,000 = 872,000
})
it('should get image info using sharp', async () => {
const mockMetadata = {
width: 800,
@@ -897,4 +1017,509 @@ describe('TranscodeService', () => {
})
})
})
describe('Hardware Acceleration & Encoder Resolution', () => {
beforeEach(() => {
transcodeService.clearEncodersCache()
})
afterEach(() => {
vi.restoreAllMocks()
})
it('should return platform candidates correctly', () => {
expect(getPlatformEncoderCandidates('darwin')).toEqual([
'h264_videotoolbox',
'h264_nvenc',
'h264_qsv',
'h264_amf',
])
expect(getPlatformEncoderCandidates('win32')).toEqual(['h264_nvenc', 'h264_qsv', 'h264_amf'])
expect(getPlatformEncoderCandidates('linux')).toEqual(['h264_nvenc', 'h264_qsv', 'h264_amf'])
})
it('should calculate default bitrates by resolution height and width correctly', () => {
expect(getDefaultBitrateBps(2160, 3840)).toBe(12_000_000)
expect(getDefaultBitrate(2160, 3840)).toBe('12000k')
expect(getDefaultBitrate(1080, 1920)).toBe('4500k')
expect(getDefaultBitrate(720, 1280)).toBe('2500k')
expect(getDefaultBitrate(540, 960)).toBe('1200k')
expect(getDefaultBitrate(360, 640)).toBe('800k')
expect(getDefaultBitrate(180, 320)).toBe('100k')
expect(getDefaultBitrate(100, 100)).toBe('100k')
})
it('calculateMaxBitrate should cap bitrate based on sourceVideoBitrate, ceiling, and targetFps', () => {
// Default without source bitrate
expect(calculateMaxBitrate(720, 1280)).toEqual({
maxrate: '2500k',
bufsize: '5000k',
})
// With low source bitrate (600k * 1.2 = 720k)
expect(calculateMaxBitrate(720, 1280, 600_000)).toEqual({
maxrate: '720k',
bufsize: '1440k',
})
// With high source bitrate (3000k * 1.2 = 3600k, capped at 2500k)
expect(calculateMaxBitrate(720, 1280, 3_000_000)).toEqual({
maxrate: '2500k',
bufsize: '5000k',
})
// With downsampled targetFps (180p preview @ 0.78 fps: 100k * (0.78/24) = 3.25k -> capped at min 50k)
expect(calculateMaxBitrate(180, 320, 600_000, 0.78)).toEqual({
maxrate: '50k',
bufsize: '100k',
})
// With downsampled targetFps string (180p preview @ 24 fps)
expect(calculateMaxBitrate(180, 320, 600_000, 24)).toEqual({
maxrate: '100k',
bufsize: '200k',
})
// With extremely low source bitrate without targetFps (50k * 1.2 = 60k, minimum floor 100k)
expect(calculateMaxBitrate(720, 1280, 50_000)).toEqual({
maxrate: '100k',
bufsize: '200k',
})
})
it('selectH264Encoder should return libx264 when hardwareAcceleration is off', async () => {
const encoder = await transcodeService.selectH264Encoder('off')
expect(encoder).toEqual(H264_ENCODER_CONFIGS.libx264)
expect(child_process.execFile).not.toHaveBeenCalledWith(
'ffmpeg',
['-encoders'],
expect.any(Function),
)
})
it('selectH264Encoder should select h264_videotoolbox on darwin when available', async () => {
const mockEncodersOutput = `
V....D libx264 libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
V....D h264_videotoolbox VideoToolbox H.264 Encoder
`
vi.mocked(execFile).mockImplementation(
(
_cmd: unknown,
args: unknown,
callback: unknown,
): ReturnType<typeof child_process.execFile> => {
const cb = callback as (
err: Error | null,
result: { stdout: string; stderr: string },
) => void
const argsArr = args as string[] | undefined
if (argsArr && argsArr[0] === '-encoders') {
cb(null, { stdout: mockEncodersOutput, stderr: '' })
} else if (typeof cb === 'function') {
cb(null, { stdout: '', stderr: '' })
}
return {} as ReturnType<typeof child_process.execFile>
},
)
const encoder = await transcodeService.selectH264Encoder('auto', 'darwin')
expect(encoder.name).toBe('h264_videotoolbox')
expect(encoder.presetArgs).toEqual(['-q:v', '74'])
})
it('selectH264Encoder should select h264_nvenc on linux when available', async () => {
const mockEncodersOutput = `
V....D libx264 libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
V....D h264_nvenc NVIDIA NVENC H.264 encoder
V....D h264_qsv Intel Quick Sync Video H.264
`
vi.mocked(execFile).mockImplementation(
(
_cmd: unknown,
args: unknown,
callback: unknown,
): ReturnType<typeof child_process.execFile> => {
const cb = callback as (
err: Error | null,
result: { stdout: string; stderr: string },
) => void
const argsArr = args as string[] | undefined
if (argsArr && argsArr[0] === '-encoders') {
cb(null, { stdout: mockEncodersOutput, stderr: '' })
} else if (typeof cb === 'function') {
cb(null, { stdout: '', stderr: '' })
}
return {} as ReturnType<typeof child_process.execFile>
},
)
const encoder = await transcodeService.selectH264Encoder('auto', 'linux')
expect(encoder.name).toBe('h264_nvenc')
expect(encoder.presetArgs).toEqual([
'-preset',
'p4',
'-rc:v',
'vbr',
'-cq:v',
'26',
'-b:v',
'0',
])
})
it('selectH264Encoder should select h264_qsv on linux when nvenc is not available', async () => {
const mockEncodersOutput = `
V....D libx264 libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
V....D h264_qsv Intel Quick Sync Video H.264
`
vi.mocked(execFile).mockImplementation(
(
_cmd: unknown,
args: unknown,
callback: unknown,
): ReturnType<typeof child_process.execFile> => {
const cb = callback as (
err: Error | null,
result: { stdout: string; stderr: string },
) => void
const argsArr = args as string[] | undefined
if (argsArr && argsArr[0] === '-encoders') {
cb(null, { stdout: mockEncodersOutput, stderr: '' })
} else if (typeof cb === 'function') {
cb(null, { stdout: '', stderr: '' })
}
return {} as ReturnType<typeof child_process.execFile>
},
)
const encoder = await transcodeService.selectH264Encoder('auto', 'linux')
expect(encoder.name).toBe('h264_qsv')
expect(encoder.presetArgs).toEqual(['-preset', 'fast', '-global_quality', '26'])
})
it('selectH264Encoder should select h264_amf on win32 when available', async () => {
const mockEncodersOutput = `
V....D libx264 libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
V....D h264_amf AMD AMF H.264 Encoder
`
vi.mocked(execFile).mockImplementation(
(
_cmd: unknown,
args: unknown,
callback: unknown,
): ReturnType<typeof child_process.execFile> => {
const cb = callback as (
err: Error | null,
result: { stdout: string; stderr: string },
) => void
const argsArr = args as string[] | undefined
if (argsArr && argsArr[0] === '-encoders') {
cb(null, { stdout: mockEncodersOutput, stderr: '' })
} else if (typeof cb === 'function') {
cb(null, { stdout: '', stderr: '' })
}
return {} as ReturnType<typeof child_process.execFile>
},
)
const encoder = await transcodeService.selectH264Encoder('auto', 'win32')
expect(encoder.name).toBe('h264_amf')
expect(encoder.presetArgs).toEqual([
'-quality',
'balanced',
'-rc',
'qvbr',
'-qvbr_quality_level',
'26',
])
})
it('selectH264Encoder should fallback to libx264 when no hw encoder is in ffmpeg build', async () => {
const mockEncodersOutput = `
V....D libx264 libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
`
vi.mocked(execFile).mockImplementation(
(
_cmd: unknown,
args: unknown,
callback: unknown,
): ReturnType<typeof child_process.execFile> => {
const cb = callback as (
err: Error | null,
result: { stdout: string; stderr: string },
) => void
const argsArr = args as string[] | undefined
if (argsArr && argsArr[0] === '-encoders') {
cb(null, { stdout: mockEncodersOutput, stderr: '' })
} else if (typeof cb === 'function') {
cb(null, { stdout: '', stderr: '' })
}
return {} as ReturnType<typeof child_process.execFile>
},
)
const encoder = await transcodeService.selectH264Encoder('auto', 'linux')
expect(encoder.name).toBe('libx264')
expect(encoder.presetArgs).toEqual(['-preset', 'fast', '-crf', '26'])
})
it('transcodeVideo with hardwareAcceleration off should use libx264, preset fast, crf 26, maxrate, and yuv420p', async () => {
vi.mocked(execFile).mockImplementation(
(
_cmd: unknown,
_args: unknown,
callback: unknown,
): ReturnType<typeof child_process.execFile> => {
const cb = callback as (
err: Error | null,
result: { stdout: string; stderr: string },
) => void
if (typeof cb === 'function') {
cb(null, { stdout: '', stderr: '' })
}
return {} as ReturnType<typeof child_process.execFile>
},
)
const outputFile = path.join(tempDir, 'out_off.mp4')
await transcodeService.transcodeVideo({
inputFile: 'input.mp4',
outputFile,
width: 1280,
height: 720,
hardwareAcceleration: 'off',
sourceVideoBitrate: 600_000,
})
expect(child_process.execFile).toHaveBeenCalledWith(
'ffmpeg',
expect.arrayContaining([
'-c:v',
'libx264',
'-preset',
'fast',
'-crf',
'26',
'-maxrate',
'720k',
'-bufsize',
'1440k',
'-pix_fmt',
'yuv420p',
]),
expect.any(Function),
)
})
it('transcodeVideo with hardwareAcceleration auto and videotoolbox should use -q:v 74 and -maxrate', async () => {
vi.spyOn(transcodeService, 'selectH264Encoder').mockResolvedValue(
H264_ENCODER_CONFIGS.h264_videotoolbox,
)
vi.mocked(execFile).mockImplementation(
(
_cmd: unknown,
_args: unknown,
callback: unknown,
): ReturnType<typeof child_process.execFile> => {
const cb = callback as (
err: Error | null,
result: { stdout: string; stderr: string },
) => void
if (typeof cb === 'function') {
cb(null, { stdout: '', stderr: '' })
}
return {} as ReturnType<typeof child_process.execFile>
},
)
const outputFile = path.join(tempDir, 'out_vt.mp4')
await transcodeService.transcodeVideo({
inputFile: 'input.mp4',
outputFile,
width: 1280,
height: 720,
hardwareAcceleration: 'auto',
sourceVideoBitrate: 600_000,
})
expect(child_process.execFile).toHaveBeenCalledWith(
'ffmpeg',
expect.arrayContaining([
'-c:v',
'h264_videotoolbox',
'-q:v',
'74',
'-maxrate',
'720k',
'-bufsize',
'1440k',
'-pix_fmt',
'yuv420p',
]),
expect.any(Function),
)
})
it('transcodeVideo with hardwareAcceleration auto and nvenc should use -preset p4, -rc:v vbr, -cq:v 26, -b:v 0, and -maxrate', async () => {
vi.spyOn(transcodeService, 'selectH264Encoder').mockResolvedValue(
H264_ENCODER_CONFIGS.h264_nvenc,
)
vi.mocked(execFile).mockImplementation(
(
_cmd: unknown,
_args: unknown,
callback: unknown,
): ReturnType<typeof child_process.execFile> => {
const cb = callback as (
err: Error | null,
result: { stdout: string; stderr: string },
) => void
if (typeof cb === 'function') {
cb(null, { stdout: '', stderr: '' })
}
return {} as ReturnType<typeof child_process.execFile>
},
)
const outputFile = path.join(tempDir, 'out_nvenc.mp4')
await transcodeService.transcodeVideo({
inputFile: 'input.mp4',
outputFile,
width: 1920,
height: 1080,
hardwareAcceleration: 'auto',
sourceVideoBitrate: 1_000_000,
})
expect(child_process.execFile).toHaveBeenCalledWith(
'ffmpeg',
expect.arrayContaining([
'-c:v',
'h264_nvenc',
'-preset',
'p4',
'-rc:v',
'vbr',
'-cq:v',
'26',
'-b:v',
'0',
'-maxrate',
'1200k',
'-bufsize',
'2400k',
'-pix_fmt',
'yuv420p',
]),
expect.any(Function),
)
})
it('transcodeVideo with hardwareAcceleration auto and amf should use -quality balanced, -rc qvbr, -qvbr_quality_level 26, and -maxrate', async () => {
vi.spyOn(transcodeService, 'selectH264Encoder').mockResolvedValue(
H264_ENCODER_CONFIGS.h264_amf,
)
vi.mocked(execFile).mockImplementation(
(
_cmd: unknown,
_args: unknown,
callback: unknown,
): ReturnType<typeof child_process.execFile> => {
const cb = callback as (
err: Error | null,
result: { stdout: string; stderr: string },
) => void
if (typeof cb === 'function') {
cb(null, { stdout: '', stderr: '' })
}
return {} as ReturnType<typeof child_process.execFile>
},
)
const outputFile = path.join(tempDir, 'out_amf.mp4')
await transcodeService.transcodeVideo({
inputFile: 'input.mp4',
outputFile,
width: 1280,
height: 720,
hardwareAcceleration: 'auto',
sourceVideoBitrate: 600_000,
})
expect(child_process.execFile).toHaveBeenCalledWith(
'ffmpeg',
expect.arrayContaining([
'-c:v',
'h264_amf',
'-quality',
'balanced',
'-rc',
'qvbr',
'-qvbr_quality_level',
'26',
'-maxrate',
'720k',
'-bufsize',
'1440k',
'-pix_fmt',
'yuv420p',
]),
expect.any(Function),
)
})
it('transcodeVideo with explicit videoBitrate should use -b:v directly', async () => {
vi.mocked(execFile).mockImplementation(
(
_cmd: unknown,
_args: unknown,
callback: unknown,
): ReturnType<typeof child_process.execFile> => {
const cb = callback as (
err: Error | null,
result: { stdout: string; stderr: string },
) => void
if (typeof cb === 'function') {
cb(null, { stdout: '', stderr: '' })
}
return {} as ReturnType<typeof child_process.execFile>
},
)
const outputFile = path.join(tempDir, 'out_explicit.mp4')
await transcodeService.transcodeVideo({
inputFile: 'input.mp4',
outputFile,
width: 1280,
height: 720,
hardwareAcceleration: 'off',
videoBitrate: '1500k',
})
expect(child_process.execFile).toHaveBeenCalledWith(
'ffmpeg',
expect.arrayContaining([
'-c:v',
'libx264',
'-preset',
'fast',
'-crf',
'26',
'-b:v',
'1500k',
'-pix_fmt',
'yuv420p',
]),
expect.any(Function),
)
expect(child_process.execFile).not.toHaveBeenCalledWith(
'ffmpeg',
expect.arrayContaining(['-maxrate']),
expect.any(Function),
)
})
})
})
+201 -1
View File
@@ -91,6 +91,7 @@ export interface MediaMetadata {
originalHeight: number
duration: number
bitRate: number
videoBitRate?: number
frameRate: number
totalFrames: number
startTimecode?: string
@@ -111,6 +112,113 @@ export interface TranscodeVideoParams {
frameRate?: number | string
disableAudio?: boolean
overlayFile?: string
hardwareAcceleration?: 'off' | 'auto'
videoBitrate?: string
sourceVideoBitrate?: number
}
export interface EncoderConfig {
name: string
presetArgs: string[]
}
export const H264_ENCODER_CONFIGS: Record<string, EncoderConfig> = {
h264_nvenc: {
name: 'h264_nvenc',
presetArgs: ['-preset', 'p4', '-rc:v', 'vbr', '-cq:v', '26', '-b:v', '0'],
},
h264_qsv: {
name: 'h264_qsv',
presetArgs: ['-preset', 'fast', '-global_quality', '26'],
},
h264_amf: {
name: 'h264_amf',
presetArgs: ['-quality', 'balanced', '-rc', 'qvbr', '-qvbr_quality_level', '26'],
},
h264_videotoolbox: {
name: 'h264_videotoolbox',
presetArgs: ['-q:v', '74'],
},
libx264: {
name: 'libx264',
presetArgs: ['-preset', 'fast', '-crf', '26'],
},
}
export function getPlatformEncoderCandidates(
platform: NodeJS.Platform = process.platform,
): string[] {
switch (platform) {
case 'darwin':
return ['h264_videotoolbox', 'h264_nvenc', 'h264_qsv', 'h264_amf']
case 'win32':
return ['h264_nvenc', 'h264_qsv', 'h264_amf']
case 'linux':
default:
return ['h264_nvenc', 'h264_qsv', 'h264_amf']
}
}
export function getDefaultBitrateBps(height: number, width?: number): number {
const longSide = Math.max(width || 0, height)
const shortSide = Math.min(width || height, height)
const effectiveHeight = shortSide > 0 ? shortSide : height
if (effectiveHeight >= 2160 || longSide >= 3840) return 12_000_000
if (effectiveHeight >= 1080 || longSide >= 1920) return 4_500_000
if (effectiveHeight >= 720 || longSide >= 1280) return 2_500_000
if (effectiveHeight >= 540 || longSide >= 960) return 1_200_000
if (effectiveHeight >= 360 || longSide >= 640) return 800_000
return 100_000
}
export function getDefaultBitrate(height: number, width?: number): string {
const bps = getDefaultBitrateBps(height, width)
return `${Math.round(bps / 1000)}k`
}
export function calculateMaxBitrate(
targetHeight: number,
targetWidth?: number,
sourceVideoBitrate?: number,
targetFps?: number | string,
): { maxrate: string; bufsize: string } {
let configuredMaxBps = getDefaultBitrateBps(targetHeight, targetWidth)
// If frame rate is downsampled (e.g. 180p preview with < 24 fps), scale the bitrate ceiling proportionally
if (targetFps) {
let parsedFps: number | undefined
if (typeof targetFps === 'number') {
parsedFps = targetFps
} else {
const parts = targetFps.split('/')
if (parts.length === 2) {
parsedFps = parseFloat(parts[0]) / parseFloat(parts[1])
} else {
parsedFps = parseFloat(targetFps)
}
}
if (Number.isFinite(parsedFps) && parsedFps > 0 && parsedFps < 24) {
const fpsRatio = Math.max(0.1, parsedFps / 24)
configuredMaxBps = Math.max(50_000, Math.round(configuredMaxBps * fpsRatio))
}
}
let effectiveMaxBps =
sourceVideoBitrate && sourceVideoBitrate > 0
? Math.min(configuredMaxBps, Math.round(sourceVideoBitrate * 1.2))
: configuredMaxBps
const minFloor = targetFps ? 50_000 : 100_000
effectiveMaxBps = Math.max(minFloor, effectiveMaxBps)
const maxrateKbps = Math.max(50, Math.round(effectiveMaxBps / 1000))
const bufsizeKbps = maxrateKbps * 2
return {
maxrate: `${maxrateKbps}k`,
bufsize: `${bufsizeKbps}k`,
}
}
export interface ExtractVideoFramesParams {
@@ -295,11 +403,38 @@ export class TranscodeService {
}
const startTimecode = videoStream.tags?.timecode || info.format?.tags?.timecode
let videoBitRate: number | undefined
if (videoStream.bit_rate && parseInt(videoStream.bit_rate, 10) > 0) {
videoBitRate = parseInt(videoStream.bit_rate, 10)
} else {
const bpsTag = videoStream.tags?.BPS || videoStream.tags?.['BPS-eng']
if (bpsTag && parseInt(bpsTag, 10) > 0) {
videoBitRate = parseInt(bpsTag, 10)
} else {
const bytesTag =
videoStream.tags?.NUMBER_OF_BYTES || videoStream.tags?.['NUMBER_OF_BYTES-eng']
if (bytesTag && duration > 0) {
videoBitRate = Math.round((parseInt(bytesTag, 10) * 8) / duration)
} else {
const totalBitrate = parseFloat(info.format.bit_rate)
if (Number.isFinite(totalBitrate) && totalBitrate > 0) {
const audioBitrate = audioStream?.bit_rate
? parseFloat(audioStream.bit_rate)
: audioStream
? 128_000
: 0
videoBitRate = Math.max(100_000, Math.round(totalBitrate - audioBitrate))
}
}
}
}
return {
originalWidth: videoStream.width,
originalHeight: videoStream.height,
duration,
bitRate: parseFloat(info.format.bit_rate),
videoBitRate,
frameRate: fps || 30,
totalFrames: totalFrames || 0,
startTimecode,
@@ -373,6 +508,53 @@ export class TranscodeService {
}
}
private availableEncodersCache: Set<string> | null = null
clearEncodersCache(): void {
this.availableEncodersCache = null
}
async getAvailableEncoders(): Promise<Set<string>> {
if (this.availableEncodersCache) {
return this.availableEncodersCache
}
try {
const { stdout } = await execFileAsync('ffmpeg', ['-encoders'])
const encoders = new Set<string>()
const lines = stdout.split('\n')
for (const line of lines) {
const match = line.match(/^\s*[A-Z.]{6}\s+([a-zA-Z0-9_-]+)/)
if (match) {
encoders.add(match[1])
}
}
this.availableEncodersCache = encoders
return encoders
} catch (err) {
console.warn('Failed to probe ffmpeg encoders:', err)
return new Set<string>()
}
}
async selectH264Encoder(
hardwareAcceleration?: 'off' | 'auto',
platform: NodeJS.Platform = process.platform,
): Promise<EncoderConfig> {
if (hardwareAcceleration !== 'auto') {
return H264_ENCODER_CONFIGS.libx264
}
const available = await this.getAvailableEncoders()
const candidates = getPlatformEncoderCandidates(platform)
for (const enc of candidates) {
if (available.has(enc) && H264_ENCODER_CONFIGS[enc]) {
return H264_ENCODER_CONFIGS[enc]
}
}
return H264_ENCODER_CONFIGS.libx264
}
async transcodeVideo(params: TranscodeVideoParams): Promise<void> {
let filterComplex: string
const args: string[] = ['-i', params.inputFile]
@@ -420,7 +602,25 @@ export class TranscodeService {
args.push('-map', '0:a?')
}
args.push('-c:v', 'libx264', '-preset', 'fast', '-crf', '26')
const encoder = await this.selectH264Encoder(params.hardwareAcceleration)
args.push('-c:v', encoder.name)
if (encoder.presetArgs.length > 0) {
args.push(...encoder.presetArgs)
}
if (params.videoBitrate) {
args.push('-b:v', params.videoBitrate)
} else {
const { maxrate, bufsize } = calculateMaxBitrate(
params.height,
params.width,
params.sourceVideoBitrate,
params.frameRate,
)
args.push('-maxrate', maxrate, '-bufsize', bufsize)
}
args.push('-pix_fmt', 'yuv420p')
if (!params.disableAudio) {
args.push('-c:a', 'aac', '-b:a', '128k')
+1
View File
@@ -190,6 +190,7 @@ describe('UploadService', () => {
projectId: projectId,
transcode: {
videoStrategy: 'best_match',
hardwareAcceleration: 'off',
sprite: true,
poster: true,
},
+2
View File
@@ -303,9 +303,11 @@ export class UploadService {
const settings = team.settings as PrismaJson.Settings | null
if (isVideo) {
const strategy = settings?.transcode?.videoStrategy || 'best_match'
const hardwareAcceleration = settings?.transcode?.hardwareAcceleration || 'off'
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await new VideoTranscoder(tx as any, asset.id, team.id, projectId)
.setStrategy(strategy)
.setHardwareAcceleration(hardwareAcceleration)
.withSprite()
.withPoster()
.submit()
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/db",
"version": "0.3.10",
"version": "0.4.1",
"private": true,
"type": "module",
"main": "./src/index.ts",
@@ -0,0 +1,28 @@
-- CreateTable
CREATE TABLE "recent_file_items" (
"id" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"project_id" TEXT NOT NULL,
"asset_id" TEXT NOT NULL,
"viewed_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "recent_file_items_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "recent_file_items_user_id_project_id_viewed_at_idx" ON "recent_file_items"("user_id", "project_id", "viewed_at" DESC);
-- CreateIndex
CREATE INDEX "recent_file_items_asset_id_idx" ON "recent_file_items"("asset_id");
-- CreateIndex
CREATE UNIQUE INDEX "recent_file_items_user_id_project_id_asset_id_key" ON "recent_file_items"("user_id", "project_id", "asset_id");
-- AddForeignKey
ALTER TABLE "recent_file_items" ADD CONSTRAINT "recent_file_items_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "recent_file_items" ADD CONSTRAINT "recent_file_items_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "projects"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "recent_file_items" ADD CONSTRAINT "recent_file_items_asset_id_fkey" FOREIGN KEY ("asset_id") REFERENCES "assets"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+23 -3
View File
@@ -117,7 +117,7 @@ enum WorkflowTaskType {
chat
ai_embedding
query_embedding_for_search
agent_tool_call
agent_tool_call // @deprecated: Agent tools now execute directly in-process via Core services
kanban_agent_run
}
@@ -236,8 +236,9 @@ model User {
kanbanTasksReported KanbanTask[] @relation("KanbanTaskReporter")
kanbanTasksAssigned KanbanTask[] @relation("KanbanTaskAssignee")
kanbanGoalsCreated KanbanGoal[] @relation("UserToKanbanGoal")
kanbanTaskComments KanbanTaskComment[]
kanbanTaskEvents KanbanTaskEvent[]
kanbanTaskComments KanbanTaskComment[]
kanbanTaskEvents KanbanTaskEvent[]
recentFiles RecentFileItem[]
@@map("users")
}
@@ -414,6 +415,7 @@ model Project {
collections Collection[] @relation("ProjectToCollection")
auditLogs AuditLog[] @relation("ProjectToAuditLog")
kanbanTasks KanbanTask[] @relation("ProjectToKanbanTask")
recentFiles RecentFileItem[]
@@map("projects")
@@index([createdAt])
@@ -564,6 +566,7 @@ model Asset {
agentMd AssetAgentMd? @relation("AssetToAgentMd")
kanbanTargetTasks KanbanTask[] @relation("KanbanTaskTargetFolder")
kanbanTasks KanbanTaskAsset[]
recentFiles RecentFileItem[]
@@map("assets")
@@index([type])
@@ -1273,5 +1276,22 @@ model KanbanTaskEvent {
@@map("kanban_task_events")
}
model RecentFileItem {
id String @id @default(ulid())
userId String @map("user_id")
projectId String @map("project_id")
assetId String @map("asset_id")
viewedAt DateTime @default(now()) @map("viewed_at")
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
asset Asset @relation(fields: [assetId], references: [id], onDelete: Cascade)
@@unique([userId, projectId, assetId], name: "userIdProjectIdAssetId")
@@index([userId, projectId, viewedAt(sort: Desc)])
@@index([assetId])
@@map("recent_file_items")
}
+5
View File
@@ -267,3 +267,8 @@ export type KanbanTaskComment = Prisma.KanbanTaskCommentModel
*
*/
export type KanbanTaskEvent = Prisma.KanbanTaskEventModel
/**
* Model RecentFileItem
*
*/
export type RecentFileItem = Prisma.RecentFileItemModel
+5
View File
@@ -291,3 +291,8 @@ export type KanbanTaskComment = Prisma.KanbanTaskCommentModel
*
*/
export type KanbanTaskEvent = Prisma.KanbanTaskEventModel
/**
* Model RecentFileItem
*
*/
export type RecentFileItem = Prisma.RecentFileItemModel
File diff suppressed because one or more lines are too long
+89 -2
View File
@@ -433,7 +433,8 @@ export const ModelName = {
KanbanTaskLink: 'KanbanTaskLink',
KanbanTaskAsset: 'KanbanTaskAsset',
KanbanTaskComment: 'KanbanTaskComment',
KanbanTaskEvent: 'KanbanTaskEvent'
KanbanTaskEvent: 'KanbanTaskEvent',
RecentFileItem: 'RecentFileItem'
} as const
export type ModelName = (typeof ModelName)[keyof typeof ModelName]
@@ -449,7 +450,7 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
omit: GlobalOmitOptions
}
meta: {
modelProps: "user" | "session" | "account" | "verification" | "authToken" | "team" | "sandbox" | "skill" | "teamMember" | "project" | "projectMember" | "shareLink" | "watermarkConfig" | "watermarkTemplate" | "watermarkFile" | "asset" | "storageKey" | "assetMetadataValue" | "assetAgentMd" | "assetComment" | "assetCommentAttachment" | "assetEmbedding" | "invite" | "metadataField" | "notification" | "systemSettings" | "task" | "workflowTask" | "agent" | "agentSkill" | "mcpServer" | "agentMcpServer" | "mcpServerCredential" | "agentSession" | "agentSessionEntry" | "userMetadata" | "model" | "provider" | "collection" | "apiToken" | "aiUsage" | "auditLog" | "quotaRule" | "quotaRecord" | "kanbanGoal" | "kanbanTask" | "kanbanTaskLink" | "kanbanTaskAsset" | "kanbanTaskComment" | "kanbanTaskEvent"
modelProps: "user" | "session" | "account" | "verification" | "authToken" | "team" | "sandbox" | "skill" | "teamMember" | "project" | "projectMember" | "shareLink" | "watermarkConfig" | "watermarkTemplate" | "watermarkFile" | "asset" | "storageKey" | "assetMetadataValue" | "assetAgentMd" | "assetComment" | "assetCommentAttachment" | "assetEmbedding" | "invite" | "metadataField" | "notification" | "systemSettings" | "task" | "workflowTask" | "agent" | "agentSkill" | "mcpServer" | "agentMcpServer" | "mcpServerCredential" | "agentSession" | "agentSessionEntry" | "userMetadata" | "model" | "provider" | "collection" | "apiToken" | "aiUsage" | "auditLog" | "quotaRule" | "quotaRecord" | "kanbanGoal" | "kanbanTask" | "kanbanTaskLink" | "kanbanTaskAsset" | "kanbanTaskComment" | "kanbanTaskEvent" | "recentFileItem"
txIsolationLevel: TransactionIsolationLevel
}
model: {
@@ -4153,6 +4154,80 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
}
}
}
RecentFileItem: {
payload: Prisma.$RecentFileItemPayload<ExtArgs>
fields: Prisma.RecentFileItemFieldRefs
operations: {
findUnique: {
args: Prisma.RecentFileItemFindUniqueArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$RecentFileItemPayload> | null
}
findUniqueOrThrow: {
args: Prisma.RecentFileItemFindUniqueOrThrowArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$RecentFileItemPayload>
}
findFirst: {
args: Prisma.RecentFileItemFindFirstArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$RecentFileItemPayload> | null
}
findFirstOrThrow: {
args: Prisma.RecentFileItemFindFirstOrThrowArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$RecentFileItemPayload>
}
findMany: {
args: Prisma.RecentFileItemFindManyArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$RecentFileItemPayload>[]
}
create: {
args: Prisma.RecentFileItemCreateArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$RecentFileItemPayload>
}
createMany: {
args: Prisma.RecentFileItemCreateManyArgs<ExtArgs>
result: BatchPayload
}
createManyAndReturn: {
args: Prisma.RecentFileItemCreateManyAndReturnArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$RecentFileItemPayload>[]
}
delete: {
args: Prisma.RecentFileItemDeleteArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$RecentFileItemPayload>
}
update: {
args: Prisma.RecentFileItemUpdateArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$RecentFileItemPayload>
}
deleteMany: {
args: Prisma.RecentFileItemDeleteManyArgs<ExtArgs>
result: BatchPayload
}
updateMany: {
args: Prisma.RecentFileItemUpdateManyArgs<ExtArgs>
result: BatchPayload
}
updateManyAndReturn: {
args: Prisma.RecentFileItemUpdateManyAndReturnArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$RecentFileItemPayload>[]
}
upsert: {
args: Prisma.RecentFileItemUpsertArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$RecentFileItemPayload>
}
aggregate: {
args: Prisma.RecentFileItemAggregateArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.AggregateRecentFileItem>
}
groupBy: {
args: Prisma.RecentFileItemGroupByArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.RecentFileItemGroupByOutputType>[]
}
count: {
args: Prisma.RecentFileItemCountArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.RecentFileItemCountAggregateOutputType> | number
}
}
}
}
} & {
other: {
@@ -4918,6 +4993,17 @@ export const KanbanTaskEventScalarFieldEnum = {
export type KanbanTaskEventScalarFieldEnum = (typeof KanbanTaskEventScalarFieldEnum)[keyof typeof KanbanTaskEventScalarFieldEnum]
export const RecentFileItemScalarFieldEnum = {
id: 'id',
userId: 'userId',
projectId: 'projectId',
assetId: 'assetId',
viewedAt: 'viewedAt'
} as const
export type RecentFileItemScalarFieldEnum = (typeof RecentFileItemScalarFieldEnum)[keyof typeof RecentFileItemScalarFieldEnum]
export const SortOrder = {
asc: 'asc',
desc: 'desc'
@@ -5572,6 +5658,7 @@ export type GlobalOmitConfig = {
kanbanTaskAsset?: Prisma.KanbanTaskAssetOmit
kanbanTaskComment?: Prisma.KanbanTaskCommentOmit
kanbanTaskEvent?: Prisma.KanbanTaskEventOmit
recentFileItem?: Prisma.RecentFileItemOmit
}
/* Types for Logging */
@@ -100,7 +100,8 @@ export const ModelName = {
KanbanTaskLink: 'KanbanTaskLink',
KanbanTaskAsset: 'KanbanTaskAsset',
KanbanTaskComment: 'KanbanTaskComment',
KanbanTaskEvent: 'KanbanTaskEvent'
KanbanTaskEvent: 'KanbanTaskEvent',
RecentFileItem: 'RecentFileItem'
} as const
export type ModelName = (typeof ModelName)[keyof typeof ModelName]
@@ -845,6 +846,17 @@ export const KanbanTaskEventScalarFieldEnum = {
export type KanbanTaskEventScalarFieldEnum = (typeof KanbanTaskEventScalarFieldEnum)[keyof typeof KanbanTaskEventScalarFieldEnum]
export const RecentFileItemScalarFieldEnum = {
id: 'id',
userId: 'userId',
projectId: 'projectId',
assetId: 'assetId',
viewedAt: 'viewedAt'
} as const
export type RecentFileItemScalarFieldEnum = (typeof RecentFileItemScalarFieldEnum)[keyof typeof RecentFileItemScalarFieldEnum]
export const SortOrder = {
asc: 'asc',
desc: 'desc'
+1
View File
@@ -58,4 +58,5 @@ export type * from './models/KanbanTaskLink.ts'
export type * from './models/KanbanTaskAsset.ts'
export type * from './models/KanbanTaskComment.ts'
export type * from './models/KanbanTaskEvent.ts'
export type * from './models/RecentFileItem.ts'
export type * from './commonInputTypes.ts'
+322
View File
@@ -364,6 +364,7 @@ export type AssetWhereInput = {
agentMd?: Prisma.XOR<Prisma.AssetAgentMdNullableScalarRelationFilter, Prisma.AssetAgentMdWhereInput> | null
kanbanTargetTasks?: Prisma.KanbanTaskListRelationFilter
kanbanTasks?: Prisma.KanbanTaskAssetListRelationFilter
recentFiles?: Prisma.RecentFileItemListRelationFilter
}
export type AssetOrderByWithRelationInput = {
@@ -410,6 +411,7 @@ export type AssetOrderByWithRelationInput = {
agentMd?: Prisma.AssetAgentMdOrderByWithRelationInput
kanbanTargetTasks?: Prisma.KanbanTaskOrderByRelationAggregateInput
kanbanTasks?: Prisma.KanbanTaskAssetOrderByRelationAggregateInput
recentFiles?: Prisma.RecentFileItemOrderByRelationAggregateInput
}
export type AssetWhereUniqueInput = Prisma.AtLeast<{
@@ -460,6 +462,7 @@ export type AssetWhereUniqueInput = Prisma.AtLeast<{
agentMd?: Prisma.XOR<Prisma.AssetAgentMdNullableScalarRelationFilter, Prisma.AssetAgentMdWhereInput> | null
kanbanTargetTasks?: Prisma.KanbanTaskListRelationFilter
kanbanTasks?: Prisma.KanbanTaskAssetListRelationFilter
recentFiles?: Prisma.RecentFileItemListRelationFilter
}, "id" | "parentIdTargetId">
export type AssetOrderByWithAggregationInput = {
@@ -556,6 +559,7 @@ export type AssetCreateInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateInput = {
@@ -596,6 +600,7 @@ export type AssetUncheckedCreateInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetUpdateInput = {
@@ -636,6 +641,7 @@ export type AssetUpdateInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateInput = {
@@ -676,6 +682,7 @@ export type AssetUncheckedUpdateInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetCreateManyInput = {
@@ -1372,6 +1379,20 @@ export type AssetUpdateOneRequiredWithoutKanbanTasksNestedInput = {
update?: Prisma.XOR<Prisma.XOR<Prisma.AssetUpdateToOneWithWhereWithoutKanbanTasksInput, Prisma.AssetUpdateWithoutKanbanTasksInput>, Prisma.AssetUncheckedUpdateWithoutKanbanTasksInput>
}
export type AssetCreateNestedOneWithoutRecentFilesInput = {
create?: Prisma.XOR<Prisma.AssetCreateWithoutRecentFilesInput, Prisma.AssetUncheckedCreateWithoutRecentFilesInput>
connectOrCreate?: Prisma.AssetCreateOrConnectWithoutRecentFilesInput
connect?: Prisma.AssetWhereUniqueInput
}
export type AssetUpdateOneRequiredWithoutRecentFilesNestedInput = {
create?: Prisma.XOR<Prisma.AssetCreateWithoutRecentFilesInput, Prisma.AssetUncheckedCreateWithoutRecentFilesInput>
connectOrCreate?: Prisma.AssetCreateOrConnectWithoutRecentFilesInput
upsert?: Prisma.AssetUpsertWithoutRecentFilesInput
connect?: Prisma.AssetWhereUniqueInput
update?: Prisma.XOR<Prisma.XOR<Prisma.AssetUpdateToOneWithWhereWithoutRecentFilesInput, Prisma.AssetUpdateWithoutRecentFilesInput>, Prisma.AssetUncheckedUpdateWithoutRecentFilesInput>
}
export type AssetCreateWithoutCreatorInput = {
id?: string
name?: string
@@ -1409,6 +1430,7 @@ export type AssetCreateWithoutCreatorInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutCreatorInput = {
@@ -1448,6 +1470,7 @@ export type AssetUncheckedCreateWithoutCreatorInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutCreatorInput = {
@@ -1540,6 +1563,7 @@ export type AssetCreateWithoutTeamRootFolderInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutTeamRootFolderInput = {
@@ -1579,6 +1603,7 @@ export type AssetUncheckedCreateWithoutTeamRootFolderInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutTeamRootFolderInput = {
@@ -1634,6 +1659,7 @@ export type AssetUpdateWithoutTeamRootFolderInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutTeamRootFolderInput = {
@@ -1673,6 +1699,7 @@ export type AssetUncheckedUpdateWithoutTeamRootFolderInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetCreateWithoutProjectRootFolderInput = {
@@ -1712,6 +1739,7 @@ export type AssetCreateWithoutProjectRootFolderInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutProjectRootFolderInput = {
@@ -1751,6 +1779,7 @@ export type AssetUncheckedCreateWithoutProjectRootFolderInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutProjectRootFolderInput = {
@@ -1795,6 +1824,7 @@ export type AssetCreateWithoutProjectShareRootInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutProjectShareRootInput = {
@@ -1834,6 +1864,7 @@ export type AssetUncheckedCreateWithoutProjectShareRootInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutProjectShareRootInput = {
@@ -1878,6 +1909,7 @@ export type AssetCreateWithoutProjectInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutProjectInput = {
@@ -1917,6 +1949,7 @@ export type AssetUncheckedCreateWithoutProjectInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutProjectInput = {
@@ -1977,6 +2010,7 @@ export type AssetUpdateWithoutProjectRootFolderInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutProjectRootFolderInput = {
@@ -2016,6 +2050,7 @@ export type AssetUncheckedUpdateWithoutProjectRootFolderInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetUpsertWithoutProjectShareRootInput = {
@@ -2066,6 +2101,7 @@ export type AssetUpdateWithoutProjectShareRootInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutProjectShareRootInput = {
@@ -2105,6 +2141,7 @@ export type AssetUncheckedUpdateWithoutProjectShareRootInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetUpsertWithWhereUniqueWithoutProjectInput = {
@@ -2160,6 +2197,7 @@ export type AssetCreateWithoutShareLinkRootFolderInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutShareLinkRootFolderInput = {
@@ -2199,6 +2237,7 @@ export type AssetUncheckedCreateWithoutShareLinkRootFolderInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutShareLinkRootFolderInput = {
@@ -2254,6 +2293,7 @@ export type AssetUpdateWithoutShareLinkRootFolderInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutShareLinkRootFolderInput = {
@@ -2293,6 +2333,7 @@ export type AssetUncheckedUpdateWithoutShareLinkRootFolderInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetCreateWithoutWatermarkFilesInput = {
@@ -2332,6 +2373,7 @@ export type AssetCreateWithoutWatermarkFilesInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutWatermarkFilesInput = {
@@ -2371,6 +2413,7 @@ export type AssetUncheckedCreateWithoutWatermarkFilesInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutWatermarkFilesInput = {
@@ -2426,6 +2469,7 @@ export type AssetUpdateWithoutWatermarkFilesInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutWatermarkFilesInput = {
@@ -2465,6 +2509,7 @@ export type AssetUncheckedUpdateWithoutWatermarkFilesInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetCreateWithoutChildrenInput = {
@@ -2504,6 +2549,7 @@ export type AssetCreateWithoutChildrenInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutChildrenInput = {
@@ -2543,6 +2589,7 @@ export type AssetUncheckedCreateWithoutChildrenInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutChildrenInput = {
@@ -2587,6 +2634,7 @@ export type AssetCreateWithoutParentInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutParentInput = {
@@ -2626,6 +2674,7 @@ export type AssetUncheckedCreateWithoutParentInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutParentInput = {
@@ -2675,6 +2724,7 @@ export type AssetCreateWithoutSymlinksInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutSymlinksInput = {
@@ -2714,6 +2764,7 @@ export type AssetUncheckedCreateWithoutSymlinksInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutSymlinksInput = {
@@ -2758,6 +2809,7 @@ export type AssetCreateWithoutTargetInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutTargetInput = {
@@ -2797,6 +2849,7 @@ export type AssetUncheckedCreateWithoutTargetInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutTargetInput = {
@@ -2857,6 +2910,7 @@ export type AssetUpdateWithoutChildrenInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutChildrenInput = {
@@ -2896,6 +2950,7 @@ export type AssetUncheckedUpdateWithoutChildrenInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetUpsertWithWhereUniqueWithoutParentInput = {
@@ -2962,6 +3017,7 @@ export type AssetUpdateWithoutSymlinksInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutSymlinksInput = {
@@ -3001,6 +3057,7 @@ export type AssetUncheckedUpdateWithoutSymlinksInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetUpsertWithWhereUniqueWithoutTargetInput = {
@@ -3056,6 +3113,7 @@ export type AssetCreateWithoutStorageKeyInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutStorageKeyInput = {
@@ -3095,6 +3153,7 @@ export type AssetUncheckedCreateWithoutStorageKeyInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutStorageKeyInput = {
@@ -3160,6 +3219,7 @@ export type AssetCreateWithoutMetadataValuesInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutMetadataValuesInput = {
@@ -3199,6 +3259,7 @@ export type AssetUncheckedCreateWithoutMetadataValuesInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutMetadataValuesInput = {
@@ -3254,6 +3315,7 @@ export type AssetUpdateWithoutMetadataValuesInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutMetadataValuesInput = {
@@ -3293,6 +3355,7 @@ export type AssetUncheckedUpdateWithoutMetadataValuesInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetCreateWithoutAgentMdInput = {
@@ -3332,6 +3395,7 @@ export type AssetCreateWithoutAgentMdInput = {
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutAgentMdInput = {
@@ -3371,6 +3435,7 @@ export type AssetUncheckedCreateWithoutAgentMdInput = {
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutAgentMdInput = {
@@ -3426,6 +3491,7 @@ export type AssetUpdateWithoutAgentMdInput = {
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutAgentMdInput = {
@@ -3465,6 +3531,7 @@ export type AssetUncheckedUpdateWithoutAgentMdInput = {
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetCreateWithoutCommentsInput = {
@@ -3504,6 +3571,7 @@ export type AssetCreateWithoutCommentsInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutCommentsInput = {
@@ -3543,6 +3611,7 @@ export type AssetUncheckedCreateWithoutCommentsInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutCommentsInput = {
@@ -3598,6 +3667,7 @@ export type AssetUpdateWithoutCommentsInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutCommentsInput = {
@@ -3637,6 +3707,7 @@ export type AssetUncheckedUpdateWithoutCommentsInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetCreateWithoutCommentAttachmentsInput = {
@@ -3676,6 +3747,7 @@ export type AssetCreateWithoutCommentAttachmentsInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutCommentAttachmentsInput = {
@@ -3715,6 +3787,7 @@ export type AssetUncheckedCreateWithoutCommentAttachmentsInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutCommentAttachmentsInput = {
@@ -3770,6 +3843,7 @@ export type AssetUpdateWithoutCommentAttachmentsInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutCommentAttachmentsInput = {
@@ -3809,6 +3883,7 @@ export type AssetUncheckedUpdateWithoutCommentAttachmentsInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetCreateWithoutEmbeddingsInput = {
@@ -3848,6 +3923,7 @@ export type AssetCreateWithoutEmbeddingsInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutEmbeddingsInput = {
@@ -3887,6 +3963,7 @@ export type AssetUncheckedCreateWithoutEmbeddingsInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutEmbeddingsInput = {
@@ -3942,6 +4019,7 @@ export type AssetUpdateWithoutEmbeddingsInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutEmbeddingsInput = {
@@ -3981,6 +4059,7 @@ export type AssetUncheckedUpdateWithoutEmbeddingsInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetCreateWithoutNotificationsInput = {
@@ -4020,6 +4099,7 @@ export type AssetCreateWithoutNotificationsInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutNotificationsInput = {
@@ -4059,6 +4139,7 @@ export type AssetUncheckedCreateWithoutNotificationsInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutNotificationsInput = {
@@ -4114,6 +4195,7 @@ export type AssetUpdateWithoutNotificationsInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutNotificationsInput = {
@@ -4153,6 +4235,7 @@ export type AssetUncheckedUpdateWithoutNotificationsInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetCreateWithoutTaskInput = {
@@ -4192,6 +4275,7 @@ export type AssetCreateWithoutTaskInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutTaskInput = {
@@ -4231,6 +4315,7 @@ export type AssetUncheckedCreateWithoutTaskInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutTaskInput = {
@@ -4296,6 +4381,7 @@ export type AssetCreateWithoutAgentSessionsInput = {
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutAgentSessionsInput = {
@@ -4335,6 +4421,7 @@ export type AssetUncheckedCreateWithoutAgentSessionsInput = {
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutAgentSessionsInput = {
@@ -4390,6 +4477,7 @@ export type AssetUpdateWithoutAgentSessionsInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutAgentSessionsInput = {
@@ -4429,6 +4517,7 @@ export type AssetUncheckedUpdateWithoutAgentSessionsInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetCreateWithoutKanbanTargetTasksInput = {
@@ -4468,6 +4557,7 @@ export type AssetCreateWithoutKanbanTargetTasksInput = {
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutKanbanTargetTasksInput = {
@@ -4507,6 +4597,7 @@ export type AssetUncheckedCreateWithoutKanbanTargetTasksInput = {
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutKanbanTargetTasksInput = {
@@ -4562,6 +4653,7 @@ export type AssetUpdateWithoutKanbanTargetTasksInput = {
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutKanbanTargetTasksInput = {
@@ -4601,6 +4693,7 @@ export type AssetUncheckedUpdateWithoutKanbanTargetTasksInput = {
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetCreateWithoutKanbanTasksInput = {
@@ -4640,6 +4733,7 @@ export type AssetCreateWithoutKanbanTasksInput = {
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutKanbanTasksInput = {
@@ -4679,6 +4773,7 @@ export type AssetUncheckedCreateWithoutKanbanTasksInput = {
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutKanbanTasksInput = {
@@ -4734,6 +4829,7 @@ export type AssetUpdateWithoutKanbanTasksInput = {
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutKanbanTasksInput = {
@@ -4773,6 +4869,183 @@ export type AssetUncheckedUpdateWithoutKanbanTasksInput = {
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetCreateWithoutRecentFilesInput = {
id?: string
name?: string
nameNgram?: Prisma.AssetCreatenameNgramInput | string[]
type: $Enums.AssetType
mediaType?: string | null
fileCount?: number
sizeByte?: bigint | number
status: $Enums.AssetStatus
transcodeTaskId?: string | null
media?:PrismaJson.MediaInfo | Prisma.NullableJsonNullValueInput
isDeleted?: boolean
deletedAt?: Date | string | null
sortIndex?: string | null
createdAt?: Date | string
updatedAt?: Date | string
parent?: Prisma.AssetCreateNestedOneWithoutChildrenInput
children?: Prisma.AssetCreateNestedManyWithoutParentInput
target?: Prisma.AssetCreateNestedOneWithoutSymlinksInput
symlinks?: Prisma.AssetCreateNestedManyWithoutTargetInput
storageKey?: Prisma.StorageKeyCreateNestedOneWithoutAssetsInput
metadataValues?: Prisma.AssetMetadataValueCreateNestedManyWithoutAssetInput
creator?: Prisma.UserCreateNestedOneWithoutAssetsInput
task?: Prisma.TaskCreateNestedOneWithoutAssetsInput
project?: Prisma.ProjectCreateNestedOneWithoutAssetsInput
comments?: Prisma.AssetCommentCreateNestedManyWithoutAssetInput
commentAttachments?: Prisma.AssetCommentAttachmentCreateNestedManyWithoutAssetInput
notifications?: Prisma.NotificationCreateNestedManyWithoutAssetInput
embeddings?: Prisma.AssetEmbeddingCreateNestedManyWithoutAssetInput
teamRootFolder?: Prisma.TeamCreateNestedOneWithoutRootFolderInput
projectRootFolder?: Prisma.ProjectCreateNestedOneWithoutRootFolderInput
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetCreateNestedManyWithoutAssetInput
}
export type AssetUncheckedCreateWithoutRecentFilesInput = {
id?: string
name?: string
nameNgram?: Prisma.AssetCreatenameNgramInput | string[]
type: $Enums.AssetType
mediaType?: string | null
fileCount?: number
sizeByte?: bigint | number
status: $Enums.AssetStatus
transcodeTaskId?: string | null
media?:PrismaJson.MediaInfo | Prisma.NullableJsonNullValueInput
isDeleted?: boolean
deletedAt?: Date | string | null
sortIndex?: string | null
createdAt?: Date | string
updatedAt?: Date | string
parentId?: string | null
targetId?: string | null
storageKeyId?: string | null
creatorId?: string | null
taskId?: string | null
projectId?: string | null
children?: Prisma.AssetUncheckedCreateNestedManyWithoutParentInput
symlinks?: Prisma.AssetUncheckedCreateNestedManyWithoutTargetInput
metadataValues?: Prisma.AssetMetadataValueUncheckedCreateNestedManyWithoutAssetInput
comments?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutAssetInput
commentAttachments?: Prisma.AssetCommentAttachmentUncheckedCreateNestedManyWithoutAssetInput
notifications?: Prisma.NotificationUncheckedCreateNestedManyWithoutAssetInput
embeddings?: Prisma.AssetEmbeddingUncheckedCreateNestedManyWithoutAssetInput
teamRootFolder?: Prisma.TeamUncheckedCreateNestedOneWithoutRootFolderInput
projectRootFolder?: Prisma.ProjectUncheckedCreateNestedOneWithoutRootFolderInput
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
agentMd?: Prisma.AssetAgentMdUncheckedCreateNestedOneWithoutAssetInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutTargetFolderInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedCreateNestedManyWithoutAssetInput
}
export type AssetCreateOrConnectWithoutRecentFilesInput = {
where: Prisma.AssetWhereUniqueInput
create: Prisma.XOR<Prisma.AssetCreateWithoutRecentFilesInput, Prisma.AssetUncheckedCreateWithoutRecentFilesInput>
}
export type AssetUpsertWithoutRecentFilesInput = {
update: Prisma.XOR<Prisma.AssetUpdateWithoutRecentFilesInput, Prisma.AssetUncheckedUpdateWithoutRecentFilesInput>
create: Prisma.XOR<Prisma.AssetCreateWithoutRecentFilesInput, Prisma.AssetUncheckedCreateWithoutRecentFilesInput>
where?: Prisma.AssetWhereInput
}
export type AssetUpdateToOneWithWhereWithoutRecentFilesInput = {
where?: Prisma.AssetWhereInput
data: Prisma.XOR<Prisma.AssetUpdateWithoutRecentFilesInput, Prisma.AssetUncheckedUpdateWithoutRecentFilesInput>
}
export type AssetUpdateWithoutRecentFilesInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
name?: Prisma.StringFieldUpdateOperationsInput | string
nameNgram?: Prisma.AssetUpdatenameNgramInput | string[]
type?: Prisma.EnumAssetTypeFieldUpdateOperationsInput | $Enums.AssetType
mediaType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
fileCount?: Prisma.IntFieldUpdateOperationsInput | number
sizeByte?: Prisma.BigIntFieldUpdateOperationsInput | bigint | number
status?: Prisma.EnumAssetStatusFieldUpdateOperationsInput | $Enums.AssetStatus
transcodeTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
media?:PrismaJson.MediaInfo | Prisma.NullableJsonNullValueInput
isDeleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
sortIndex?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
parent?: Prisma.AssetUpdateOneWithoutChildrenNestedInput
children?: Prisma.AssetUpdateManyWithoutParentNestedInput
target?: Prisma.AssetUpdateOneWithoutSymlinksNestedInput
symlinks?: Prisma.AssetUpdateManyWithoutTargetNestedInput
storageKey?: Prisma.StorageKeyUpdateOneWithoutAssetsNestedInput
metadataValues?: Prisma.AssetMetadataValueUpdateManyWithoutAssetNestedInput
creator?: Prisma.UserUpdateOneWithoutAssetsNestedInput
task?: Prisma.TaskUpdateOneWithoutAssetsNestedInput
project?: Prisma.ProjectUpdateOneWithoutAssetsNestedInput
comments?: Prisma.AssetCommentUpdateManyWithoutAssetNestedInput
commentAttachments?: Prisma.AssetCommentAttachmentUpdateManyWithoutAssetNestedInput
notifications?: Prisma.NotificationUpdateManyWithoutAssetNestedInput
embeddings?: Prisma.AssetEmbeddingUpdateManyWithoutAssetNestedInput
teamRootFolder?: Prisma.TeamUpdateOneWithoutRootFolderNestedInput
projectRootFolder?: Prisma.ProjectUpdateOneWithoutRootFolderNestedInput
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutRecentFilesInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
name?: Prisma.StringFieldUpdateOperationsInput | string
nameNgram?: Prisma.AssetUpdatenameNgramInput | string[]
type?: Prisma.EnumAssetTypeFieldUpdateOperationsInput | $Enums.AssetType
mediaType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
fileCount?: Prisma.IntFieldUpdateOperationsInput | number
sizeByte?: Prisma.BigIntFieldUpdateOperationsInput | bigint | number
status?: Prisma.EnumAssetStatusFieldUpdateOperationsInput | $Enums.AssetStatus
transcodeTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
media?:PrismaJson.MediaInfo | Prisma.NullableJsonNullValueInput
isDeleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
sortIndex?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
parentId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
targetId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
storageKeyId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
taskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
projectId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
children?: Prisma.AssetUncheckedUpdateManyWithoutParentNestedInput
symlinks?: Prisma.AssetUncheckedUpdateManyWithoutTargetNestedInput
metadataValues?: Prisma.AssetMetadataValueUncheckedUpdateManyWithoutAssetNestedInput
comments?: Prisma.AssetCommentUncheckedUpdateManyWithoutAssetNestedInput
commentAttachments?: Prisma.AssetCommentAttachmentUncheckedUpdateManyWithoutAssetNestedInput
notifications?: Prisma.NotificationUncheckedUpdateManyWithoutAssetNestedInput
embeddings?: Prisma.AssetEmbeddingUncheckedUpdateManyWithoutAssetNestedInput
teamRootFolder?: Prisma.TeamUncheckedUpdateOneWithoutRootFolderNestedInput
projectRootFolder?: Prisma.ProjectUncheckedUpdateOneWithoutRootFolderNestedInput
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetCreateManyCreatorInput = {
@@ -4835,6 +5108,7 @@ export type AssetUpdateWithoutCreatorInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutCreatorInput = {
@@ -4874,6 +5148,7 @@ export type AssetUncheckedUpdateWithoutCreatorInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateManyWithoutCreatorInput = {
@@ -4959,6 +5234,7 @@ export type AssetUpdateWithoutProjectInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutProjectInput = {
@@ -4998,6 +5274,7 @@ export type AssetUncheckedUpdateWithoutProjectInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateManyWithoutProjectInput = {
@@ -5106,6 +5383,7 @@ export type AssetUpdateWithoutParentInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutParentInput = {
@@ -5145,6 +5423,7 @@ export type AssetUncheckedUpdateWithoutParentInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateManyWithoutParentInput = {
@@ -5207,6 +5486,7 @@ export type AssetUpdateWithoutTargetInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutTargetInput = {
@@ -5246,6 +5526,7 @@ export type AssetUncheckedUpdateWithoutTargetInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateManyWithoutTargetInput = {
@@ -5331,6 +5612,7 @@ export type AssetUpdateWithoutStorageKeyInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutStorageKeyInput = {
@@ -5370,6 +5652,7 @@ export type AssetUncheckedUpdateWithoutStorageKeyInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateManyWithoutStorageKeyInput = {
@@ -5455,6 +5738,7 @@ export type AssetUpdateWithoutTaskInput = {
agentMd?: Prisma.AssetAgentMdUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateWithoutTaskInput = {
@@ -5494,6 +5778,7 @@ export type AssetUncheckedUpdateWithoutTaskInput = {
agentMd?: Prisma.AssetAgentMdUncheckedUpdateOneWithoutAssetNestedInput
kanbanTargetTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutTargetFolderNestedInput
kanbanTasks?: Prisma.KanbanTaskAssetUncheckedUpdateManyWithoutAssetNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutAssetNestedInput
}
export type AssetUncheckedUpdateManyWithoutTaskInput = {
@@ -5536,6 +5821,7 @@ export type AssetCountOutputType = {
watermarkFiles: number
kanbanTargetTasks: number
kanbanTasks: number
recentFiles: number
}
export type AssetCountOutputTypeSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
@@ -5550,6 +5836,7 @@ export type AssetCountOutputTypeSelect<ExtArgs extends runtime.Types.Extensions.
watermarkFiles?: boolean | AssetCountOutputTypeCountWatermarkFilesArgs
kanbanTargetTasks?: boolean | AssetCountOutputTypeCountKanbanTargetTasksArgs
kanbanTasks?: boolean | AssetCountOutputTypeCountKanbanTasksArgs
recentFiles?: boolean | AssetCountOutputTypeCountRecentFilesArgs
}
/**
@@ -5639,6 +5926,13 @@ export type AssetCountOutputTypeCountKanbanTasksArgs<ExtArgs extends runtime.Typ
where?: Prisma.KanbanTaskAssetWhereInput
}
/**
* AssetCountOutputType without action
*/
export type AssetCountOutputTypeCountRecentFilesArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
where?: Prisma.RecentFileItemWhereInput
}
export type AssetSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean
@@ -5684,6 +5978,7 @@ export type AssetSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs =
agentMd?: boolean | Prisma.Asset$agentMdArgs<ExtArgs>
kanbanTargetTasks?: boolean | Prisma.Asset$kanbanTargetTasksArgs<ExtArgs>
kanbanTasks?: boolean | Prisma.Asset$kanbanTasksArgs<ExtArgs>
recentFiles?: boolean | Prisma.Asset$recentFilesArgs<ExtArgs>
_count?: boolean | Prisma.AssetCountOutputTypeDefaultArgs<ExtArgs>
}, ExtArgs["result"]["asset"]>
@@ -5795,6 +6090,7 @@ export type AssetInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs =
agentMd?: boolean | Prisma.Asset$agentMdArgs<ExtArgs>
kanbanTargetTasks?: boolean | Prisma.Asset$kanbanTargetTasksArgs<ExtArgs>
kanbanTasks?: boolean | Prisma.Asset$kanbanTasksArgs<ExtArgs>
recentFiles?: boolean | Prisma.Asset$recentFilesArgs<ExtArgs>
_count?: boolean | Prisma.AssetCountOutputTypeDefaultArgs<ExtArgs>
}
export type AssetIncludeCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
@@ -5839,6 +6135,7 @@ export type $AssetPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs
agentMd: Prisma.$AssetAgentMdPayload<ExtArgs> | null
kanbanTargetTasks: Prisma.$KanbanTaskPayload<ExtArgs>[]
kanbanTasks: Prisma.$KanbanTaskAssetPayload<ExtArgs>[]
recentFiles: Prisma.$RecentFileItemPayload<ExtArgs>[]
}
scalars: runtime.Types.Extensions.GetPayloadResult<{
id: string
@@ -6281,6 +6578,7 @@ export interface Prisma__AssetClient<T, Null = never, ExtArgs extends runtime.Ty
agentMd<T extends Prisma.Asset$agentMdArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Asset$agentMdArgs<ExtArgs>>): Prisma.Prisma__AssetAgentMdClient<runtime.Types.Result.GetResult<Prisma.$AssetAgentMdPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
kanbanTargetTasks<T extends Prisma.Asset$kanbanTargetTasksArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Asset$kanbanTargetTasksArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$KanbanTaskPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
kanbanTasks<T extends Prisma.Asset$kanbanTasksArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Asset$kanbanTasksArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$KanbanTaskAssetPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
recentFiles<T extends Prisma.Asset$recentFilesArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Asset$recentFilesArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$RecentFileItemPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
@@ -7204,6 +7502,30 @@ export type Asset$kanbanTasksArgs<ExtArgs extends runtime.Types.Extensions.Inter
distinct?: Prisma.KanbanTaskAssetScalarFieldEnum | Prisma.KanbanTaskAssetScalarFieldEnum[]
}
/**
* Asset.recentFiles
*/
export type Asset$recentFilesArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
/**
* Select specific fields to fetch from the RecentFileItem
*/
select?: Prisma.RecentFileItemSelect<ExtArgs> | null
/**
* Omit specific fields from the RecentFileItem
*/
omit?: Prisma.RecentFileItemOmit<ExtArgs> | null
/**
* Choose, which related nodes to fetch as well
*/
include?: Prisma.RecentFileItemInclude<ExtArgs> | null
where?: Prisma.RecentFileItemWhereInput
orderBy?: Prisma.RecentFileItemOrderByWithRelationInput | Prisma.RecentFileItemOrderByWithRelationInput[]
cursor?: Prisma.RecentFileItemWhereUniqueInput
take?: number
skip?: number
distinct?: Prisma.RecentFileItemScalarFieldEnum | Prisma.RecentFileItemScalarFieldEnum[]
}
/**
* Asset without action
*/
+210
View File
@@ -232,6 +232,7 @@ export type ProjectWhereInput = {
collections?: Prisma.CollectionListRelationFilter
auditLogs?: Prisma.AuditLogListRelationFilter
kanbanTasks?: Prisma.KanbanTaskListRelationFilter
recentFiles?: Prisma.RecentFileItemListRelationFilter
}
export type ProjectOrderByWithRelationInput = {
@@ -257,6 +258,7 @@ export type ProjectOrderByWithRelationInput = {
collections?: Prisma.CollectionOrderByRelationAggregateInput
auditLogs?: Prisma.AuditLogOrderByRelationAggregateInput
kanbanTasks?: Prisma.KanbanTaskOrderByRelationAggregateInput
recentFiles?: Prisma.RecentFileItemOrderByRelationAggregateInput
}
export type ProjectWhereUniqueInput = Prisma.AtLeast<{
@@ -285,6 +287,7 @@ export type ProjectWhereUniqueInput = Prisma.AtLeast<{
collections?: Prisma.CollectionListRelationFilter
auditLogs?: Prisma.AuditLogListRelationFilter
kanbanTasks?: Prisma.KanbanTaskListRelationFilter
recentFiles?: Prisma.RecentFileItemListRelationFilter
}, "id" | "rootFolderId" | "shareRootId">
export type ProjectOrderByWithAggregationInput = {
@@ -339,6 +342,7 @@ export type ProjectCreateInput = {
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateInput = {
@@ -361,6 +365,7 @@ export type ProjectUncheckedCreateInput = {
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectUpdateInput = {
@@ -383,6 +388,7 @@ export type ProjectUpdateInput = {
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateInput = {
@@ -405,6 +411,7 @@ export type ProjectUncheckedUpdateInput = {
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectCreateManyInput = {
@@ -744,6 +751,20 @@ export type ProjectUpdateOneWithoutKanbanTasksNestedInput = {
update?: Prisma.XOR<Prisma.XOR<Prisma.ProjectUpdateToOneWithWhereWithoutKanbanTasksInput, Prisma.ProjectUpdateWithoutKanbanTasksInput>, Prisma.ProjectUncheckedUpdateWithoutKanbanTasksInput>
}
export type ProjectCreateNestedOneWithoutRecentFilesInput = {
create?: Prisma.XOR<Prisma.ProjectCreateWithoutRecentFilesInput, Prisma.ProjectUncheckedCreateWithoutRecentFilesInput>
connectOrCreate?: Prisma.ProjectCreateOrConnectWithoutRecentFilesInput
connect?: Prisma.ProjectWhereUniqueInput
}
export type ProjectUpdateOneRequiredWithoutRecentFilesNestedInput = {
create?: Prisma.XOR<Prisma.ProjectCreateWithoutRecentFilesInput, Prisma.ProjectUncheckedCreateWithoutRecentFilesInput>
connectOrCreate?: Prisma.ProjectCreateOrConnectWithoutRecentFilesInput
upsert?: Prisma.ProjectUpsertWithoutRecentFilesInput
connect?: Prisma.ProjectWhereUniqueInput
update?: Prisma.XOR<Prisma.XOR<Prisma.ProjectUpdateToOneWithWhereWithoutRecentFilesInput, Prisma.ProjectUpdateWithoutRecentFilesInput>, Prisma.ProjectUncheckedUpdateWithoutRecentFilesInput>
}
export type ProjectCreateWithoutTeamInput = {
id?: string
name: string
@@ -763,6 +784,7 @@ export type ProjectCreateWithoutTeamInput = {
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutTeamInput = {
@@ -784,6 +806,7 @@ export type ProjectUncheckedCreateWithoutTeamInput = {
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutTeamInput = {
@@ -847,6 +870,7 @@ export type ProjectCreateWithoutMembersInput = {
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutMembersInput = {
@@ -868,6 +892,7 @@ export type ProjectUncheckedCreateWithoutMembersInput = {
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutMembersInput = {
@@ -905,6 +930,7 @@ export type ProjectUpdateWithoutMembersInput = {
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutMembersInput = {
@@ -926,6 +952,7 @@ export type ProjectUncheckedUpdateWithoutMembersInput = {
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectCreateWithoutShareLinksInput = {
@@ -947,6 +974,7 @@ export type ProjectCreateWithoutShareLinksInput = {
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutShareLinksInput = {
@@ -968,6 +996,7 @@ export type ProjectUncheckedCreateWithoutShareLinksInput = {
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutShareLinksInput = {
@@ -1005,6 +1034,7 @@ export type ProjectUpdateWithoutShareLinksInput = {
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutShareLinksInput = {
@@ -1026,6 +1056,7 @@ export type ProjectUncheckedUpdateWithoutShareLinksInput = {
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectCreateWithoutAssetsInput = {
@@ -1047,6 +1078,7 @@ export type ProjectCreateWithoutAssetsInput = {
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutAssetsInput = {
@@ -1068,6 +1100,7 @@ export type ProjectUncheckedCreateWithoutAssetsInput = {
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutAssetsInput = {
@@ -1094,6 +1127,7 @@ export type ProjectCreateWithoutRootFolderInput = {
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutRootFolderInput = {
@@ -1115,6 +1149,7 @@ export type ProjectUncheckedCreateWithoutRootFolderInput = {
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutRootFolderInput = {
@@ -1141,6 +1176,7 @@ export type ProjectCreateWithoutShareRootInput = {
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutShareRootInput = {
@@ -1162,6 +1198,7 @@ export type ProjectUncheckedCreateWithoutShareRootInput = {
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutShareRootInput = {
@@ -1199,6 +1236,7 @@ export type ProjectUpdateWithoutAssetsInput = {
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutAssetsInput = {
@@ -1220,6 +1258,7 @@ export type ProjectUncheckedUpdateWithoutAssetsInput = {
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectUpsertWithoutRootFolderInput = {
@@ -1252,6 +1291,7 @@ export type ProjectUpdateWithoutRootFolderInput = {
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutRootFolderInput = {
@@ -1273,6 +1313,7 @@ export type ProjectUncheckedUpdateWithoutRootFolderInput = {
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectUpsertWithoutShareRootInput = {
@@ -1305,6 +1346,7 @@ export type ProjectUpdateWithoutShareRootInput = {
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutShareRootInput = {
@@ -1326,6 +1368,7 @@ export type ProjectUncheckedUpdateWithoutShareRootInput = {
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectCreateWithoutInvitesInput = {
@@ -1347,6 +1390,7 @@ export type ProjectCreateWithoutInvitesInput = {
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutInvitesInput = {
@@ -1368,6 +1412,7 @@ export type ProjectUncheckedCreateWithoutInvitesInput = {
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutInvitesInput = {
@@ -1405,6 +1450,7 @@ export type ProjectUpdateWithoutInvitesInput = {
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutInvitesInput = {
@@ -1426,6 +1472,7 @@ export type ProjectUncheckedUpdateWithoutInvitesInput = {
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectCreateWithoutMetadataFieldsInput = {
@@ -1447,6 +1494,7 @@ export type ProjectCreateWithoutMetadataFieldsInput = {
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutMetadataFieldsInput = {
@@ -1468,6 +1516,7 @@ export type ProjectUncheckedCreateWithoutMetadataFieldsInput = {
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutMetadataFieldsInput = {
@@ -1505,6 +1554,7 @@ export type ProjectUpdateWithoutMetadataFieldsInput = {
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutMetadataFieldsInput = {
@@ -1526,6 +1576,7 @@ export type ProjectUncheckedUpdateWithoutMetadataFieldsInput = {
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectCreateWithoutNotificationsInput = {
@@ -1547,6 +1598,7 @@ export type ProjectCreateWithoutNotificationsInput = {
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutNotificationsInput = {
@@ -1568,6 +1620,7 @@ export type ProjectUncheckedCreateWithoutNotificationsInput = {
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutNotificationsInput = {
@@ -1605,6 +1658,7 @@ export type ProjectUpdateWithoutNotificationsInput = {
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutNotificationsInput = {
@@ -1626,6 +1680,7 @@ export type ProjectUncheckedUpdateWithoutNotificationsInput = {
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectCreateWithoutCollectionsInput = {
@@ -1647,6 +1702,7 @@ export type ProjectCreateWithoutCollectionsInput = {
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutCollectionsInput = {
@@ -1668,6 +1724,7 @@ export type ProjectUncheckedCreateWithoutCollectionsInput = {
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutCollectionsInput = {
@@ -1705,6 +1762,7 @@ export type ProjectUpdateWithoutCollectionsInput = {
shareLinks?: Prisma.ShareLinkUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutCollectionsInput = {
@@ -1726,6 +1784,7 @@ export type ProjectUncheckedUpdateWithoutCollectionsInput = {
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectCreateWithoutAuditLogsInput = {
@@ -1747,6 +1806,7 @@ export type ProjectCreateWithoutAuditLogsInput = {
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutAuditLogsInput = {
@@ -1768,6 +1828,7 @@ export type ProjectUncheckedCreateWithoutAuditLogsInput = {
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutAuditLogsInput = {
@@ -1805,6 +1866,7 @@ export type ProjectUpdateWithoutAuditLogsInput = {
shareLinks?: Prisma.ShareLinkUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutAuditLogsInput = {
@@ -1826,6 +1888,7 @@ export type ProjectUncheckedUpdateWithoutAuditLogsInput = {
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectCreateWithoutKanbanTasksInput = {
@@ -1847,6 +1910,7 @@ export type ProjectCreateWithoutKanbanTasksInput = {
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutKanbanTasksInput = {
@@ -1868,6 +1932,7 @@ export type ProjectUncheckedCreateWithoutKanbanTasksInput = {
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutProjectInput
recentFiles?: Prisma.RecentFileItemUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutKanbanTasksInput = {
@@ -1905,6 +1970,7 @@ export type ProjectUpdateWithoutKanbanTasksInput = {
shareLinks?: Prisma.ShareLinkUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutKanbanTasksInput = {
@@ -1926,6 +1992,111 @@ export type ProjectUncheckedUpdateWithoutKanbanTasksInput = {
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectCreateWithoutRecentFilesInput = {
id?: string
name: string
coverImageKey?: string | null
metadataOverrides?:PrismaJson.MetadataOverrides | Prisma.NullableJsonNullValueInput
enableNotification?: boolean
createdAt?: Date | string
updatedAt?: Date | string
team: Prisma.TeamCreateNestedOneWithoutProjectsInput
rootFolder?: Prisma.AssetCreateNestedOneWithoutProjectRootFolderInput
shareRoot?: Prisma.AssetCreateNestedOneWithoutProjectShareRootInput
members?: Prisma.ProjectMemberCreateNestedManyWithoutProjectInput
assets?: Prisma.AssetCreateNestedManyWithoutProjectInput
metadataFields?: Prisma.MetadataFieldCreateNestedManyWithoutProjectInput
invites?: Prisma.InviteCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskCreateNestedManyWithoutProjectInput
}
export type ProjectUncheckedCreateWithoutRecentFilesInput = {
id?: string
name: string
coverImageKey?: string | null
metadataOverrides?:PrismaJson.MetadataOverrides | Prisma.NullableJsonNullValueInput
enableNotification?: boolean
createdAt?: Date | string
updatedAt?: Date | string
teamId: string
rootFolderId?: string | null
shareRootId?: string | null
members?: Prisma.ProjectMemberUncheckedCreateNestedManyWithoutProjectInput
assets?: Prisma.AssetUncheckedCreateNestedManyWithoutProjectInput
metadataFields?: Prisma.MetadataFieldUncheckedCreateNestedManyWithoutProjectInput
invites?: Prisma.InviteUncheckedCreateNestedManyWithoutProjectInput
notifications?: Prisma.NotificationUncheckedCreateNestedManyWithoutProjectInput
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutProjectInput
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutProjectInput
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutProjectInput
kanbanTasks?: Prisma.KanbanTaskUncheckedCreateNestedManyWithoutProjectInput
}
export type ProjectCreateOrConnectWithoutRecentFilesInput = {
where: Prisma.ProjectWhereUniqueInput
create: Prisma.XOR<Prisma.ProjectCreateWithoutRecentFilesInput, Prisma.ProjectUncheckedCreateWithoutRecentFilesInput>
}
export type ProjectUpsertWithoutRecentFilesInput = {
update: Prisma.XOR<Prisma.ProjectUpdateWithoutRecentFilesInput, Prisma.ProjectUncheckedUpdateWithoutRecentFilesInput>
create: Prisma.XOR<Prisma.ProjectCreateWithoutRecentFilesInput, Prisma.ProjectUncheckedCreateWithoutRecentFilesInput>
where?: Prisma.ProjectWhereInput
}
export type ProjectUpdateToOneWithWhereWithoutRecentFilesInput = {
where?: Prisma.ProjectWhereInput
data: Prisma.XOR<Prisma.ProjectUpdateWithoutRecentFilesInput, Prisma.ProjectUncheckedUpdateWithoutRecentFilesInput>
}
export type ProjectUpdateWithoutRecentFilesInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
name?: Prisma.StringFieldUpdateOperationsInput | string
coverImageKey?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
metadataOverrides?:PrismaJson.MetadataOverrides | Prisma.NullableJsonNullValueInput
enableNotification?: Prisma.BoolFieldUpdateOperationsInput | boolean
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
team?: Prisma.TeamUpdateOneRequiredWithoutProjectsNestedInput
rootFolder?: Prisma.AssetUpdateOneWithoutProjectRootFolderNestedInput
shareRoot?: Prisma.AssetUpdateOneWithoutProjectShareRootNestedInput
members?: Prisma.ProjectMemberUpdateManyWithoutProjectNestedInput
assets?: Prisma.AssetUpdateManyWithoutProjectNestedInput
metadataFields?: Prisma.MetadataFieldUpdateManyWithoutProjectNestedInput
invites?: Prisma.InviteUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutRecentFilesInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
name?: Prisma.StringFieldUpdateOperationsInput | string
coverImageKey?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
metadataOverrides?:PrismaJson.MetadataOverrides | Prisma.NullableJsonNullValueInput
enableNotification?: Prisma.BoolFieldUpdateOperationsInput | boolean
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
teamId?: Prisma.StringFieldUpdateOperationsInput | string
rootFolderId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
shareRootId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
members?: Prisma.ProjectMemberUncheckedUpdateManyWithoutProjectNestedInput
assets?: Prisma.AssetUncheckedUpdateManyWithoutProjectNestedInput
metadataFields?: Prisma.MetadataFieldUncheckedUpdateManyWithoutProjectNestedInput
invites?: Prisma.InviteUncheckedUpdateManyWithoutProjectNestedInput
notifications?: Prisma.NotificationUncheckedUpdateManyWithoutProjectNestedInput
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutProjectNestedInput
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectCreateManyTeamInput = {
@@ -1959,6 +2130,7 @@ export type ProjectUpdateWithoutTeamInput = {
collections?: Prisma.CollectionUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateWithoutTeamInput = {
@@ -1980,6 +2152,7 @@ export type ProjectUncheckedUpdateWithoutTeamInput = {
collections?: Prisma.CollectionUncheckedUpdateManyWithoutProjectNestedInput
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutProjectNestedInput
kanbanTasks?: Prisma.KanbanTaskUncheckedUpdateManyWithoutProjectNestedInput
recentFiles?: Prisma.RecentFileItemUncheckedUpdateManyWithoutProjectNestedInput
}
export type ProjectUncheckedUpdateManyWithoutTeamInput = {
@@ -2009,6 +2182,7 @@ export type ProjectCountOutputType = {
collections: number
auditLogs: number
kanbanTasks: number
recentFiles: number
}
export type ProjectCountOutputTypeSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
@@ -2021,6 +2195,7 @@ export type ProjectCountOutputTypeSelect<ExtArgs extends runtime.Types.Extension
collections?: boolean | ProjectCountOutputTypeCountCollectionsArgs
auditLogs?: boolean | ProjectCountOutputTypeCountAuditLogsArgs
kanbanTasks?: boolean | ProjectCountOutputTypeCountKanbanTasksArgs
recentFiles?: boolean | ProjectCountOutputTypeCountRecentFilesArgs
}
/**
@@ -2096,6 +2271,13 @@ export type ProjectCountOutputTypeCountKanbanTasksArgs<ExtArgs extends runtime.T
where?: Prisma.KanbanTaskWhereInput
}
/**
* ProjectCountOutputType without action
*/
export type ProjectCountOutputTypeCountRecentFilesArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
where?: Prisma.RecentFileItemWhereInput
}
export type ProjectSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean
@@ -2120,6 +2302,7 @@ export type ProjectSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs
collections?: boolean | Prisma.Project$collectionsArgs<ExtArgs>
auditLogs?: boolean | Prisma.Project$auditLogsArgs<ExtArgs>
kanbanTasks?: boolean | Prisma.Project$kanbanTasksArgs<ExtArgs>
recentFiles?: boolean | Prisma.Project$recentFilesArgs<ExtArgs>
_count?: boolean | Prisma.ProjectCountOutputTypeDefaultArgs<ExtArgs>
}, ExtArgs["result"]["project"]>
@@ -2182,6 +2365,7 @@ export type ProjectInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs
collections?: boolean | Prisma.Project$collectionsArgs<ExtArgs>
auditLogs?: boolean | Prisma.Project$auditLogsArgs<ExtArgs>
kanbanTasks?: boolean | Prisma.Project$kanbanTasksArgs<ExtArgs>
recentFiles?: boolean | Prisma.Project$recentFilesArgs<ExtArgs>
_count?: boolean | Prisma.ProjectCountOutputTypeDefaultArgs<ExtArgs>
}
export type ProjectIncludeCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
@@ -2210,6 +2394,7 @@ export type $ProjectPayload<ExtArgs extends runtime.Types.Extensions.InternalArg
collections: Prisma.$CollectionPayload<ExtArgs>[]
auditLogs: Prisma.$AuditLogPayload<ExtArgs>[]
kanbanTasks: Prisma.$KanbanTaskPayload<ExtArgs>[]
recentFiles: Prisma.$RecentFileItemPayload<ExtArgs>[]
}
scalars: runtime.Types.Extensions.GetPayloadResult<{
id: string
@@ -2631,6 +2816,7 @@ export interface Prisma__ProjectClient<T, Null = never, ExtArgs extends runtime.
collections<T extends Prisma.Project$collectionsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Project$collectionsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$CollectionPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
auditLogs<T extends Prisma.Project$auditLogsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Project$auditLogsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$AuditLogPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
kanbanTasks<T extends Prisma.Project$kanbanTasksArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Project$kanbanTasksArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$KanbanTaskPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
recentFiles<T extends Prisma.Project$recentFilesArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Project$recentFilesArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$RecentFileItemPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
@@ -3324,6 +3510,30 @@ export type Project$kanbanTasksArgs<ExtArgs extends runtime.Types.Extensions.Int
distinct?: Prisma.KanbanTaskScalarFieldEnum | Prisma.KanbanTaskScalarFieldEnum[]
}
/**
* Project.recentFiles
*/
export type Project$recentFilesArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
/**
* Select specific fields to fetch from the RecentFileItem
*/
select?: Prisma.RecentFileItemSelect<ExtArgs> | null
/**
* Omit specific fields from the RecentFileItem
*/
omit?: Prisma.RecentFileItemOmit<ExtArgs> | null
/**
* Choose, which related nodes to fetch as well
*/
include?: Prisma.RecentFileItemInclude<ExtArgs> | null
where?: Prisma.RecentFileItemWhereInput
orderBy?: Prisma.RecentFileItemOrderByWithRelationInput | Prisma.RecentFileItemOrderByWithRelationInput[]
cursor?: Prisma.RecentFileItemWhereUniqueInput
take?: number
skip?: number
distinct?: Prisma.RecentFileItemScalarFieldEnum | Prisma.RecentFileItemScalarFieldEnum[]
}
/**
* Project without action
*/
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+7 -7
View File
@@ -8,6 +8,8 @@ declare global {
'id' | 'type' | 'parentId' | 'timestamp'
>
export type ShumaiMessageContext = import('@shumai/dtos').ShumaiMessageContext
// ----------------------------------------------------------------------
// User Agent Settings
// ----------------------------------------------------------------------
@@ -46,6 +48,7 @@ declare global {
// Team Settings
// ----------------------------------------------------------------------
export type VideoTranscodeStrategy = 'best_match' | 'all'
export type HardwareAcceleration = 'off' | 'auto'
// ----------------------------------------------------------------------
// Collection Filter
@@ -54,6 +57,7 @@ declare global {
export interface TranscodeSettings {
videoStrategy: VideoTranscodeStrategy
hardwareAcceleration?: HardwareAcceleration
}
export interface Settings {
@@ -103,6 +107,7 @@ declare global {
hasAudio: boolean
duration: number
bitRate: number
videoBitRate?: number
frameRate: number
totalFrames: number
startTimecode: string
@@ -272,7 +277,6 @@ declare global {
queryEmbeddingForSearch?: {
text: string
}
agentToolCall?: AgentToolCallPayload
screenshot?: ScreenshotSpec
imageAnnotation?: ImageAnnotationSpec
pdfPages?: PdfPagesSpec
@@ -282,14 +286,9 @@ declare global {
// ----------------------------------------------------------------------
// Task Spec & Payload
// ----------------------------------------------------------------------
export interface AgentToolCallPayload {
toolName: string
args: Record<string, unknown>
userId: string
}
export interface TaskSpec {
videoStrategy?: VideoTranscodeStrategy
hardwareAcceleration?: HardwareAcceleration
thumbnail?: boolean
sprite?: boolean
poster?: boolean
@@ -306,6 +305,7 @@ declare global {
assetIds?: string[]
isNewChat?: boolean
hasAssetChanged?: boolean
context?: import('@shumai/dtos').ShumaiMessageContext
}
// ----------------------------------------------------------------------
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/dtos",
"version": "0.3.10",
"version": "0.4.1",
"private": true,
"type": "module",
"main": "./src/index.ts",
+4 -1
View File
@@ -160,9 +160,12 @@ export const updateAssetNameRequestSchema = z.object({
})
export type UpdateAssetNameRequest = z.infer<typeof updateAssetNameRequestSchema>
export const assetTypeFilterSchema = z.enum(['file', 'folder', 'all'])
export type AssetTypeFilter = z.infer<typeof assetTypeFilterSchema>
export const listChildrenRequestSchema = z.object({
assetId: z.string().optional(),
assetType: z.string(),
assetType: assetTypeFilterSchema.optional().default('all'),
projectId: z.string().optional(),
showDeleted: z.boolean().optional(),
prefix: z.string().optional(),
+69 -2
View File
@@ -39,11 +39,78 @@ export const chatSessionInfoSchema = z.object({
export type ChatSessionInfo = z.infer<typeof chatSessionInfoSchema>
export const shumaiAssetContextSchema = z.object({
id: z.string(),
name: z.string(),
type: z.string(),
mediaType: z.enum(['image', 'video', 'pdf', 'audio', 'other']).optional(),
mimeType: z.string().optional(),
parentId: z.string().optional(),
path: z.string().optional(),
durationSeconds: z.number().optional(),
totalFrames: z.number().optional(),
totalPages: z.number().optional(),
navigated: z.boolean().optional(),
ancestors: z.array(z.object({ id: z.string(), name: z.string() })).optional(),
})
export type ShumaiAssetContext = z.infer<typeof shumaiAssetContextSchema>
export const shumaiAttachedFileContextSchema = z.object({
id: z.string(),
name: z.string(),
type: z.string(),
mediaType: z.enum(['image', 'video', 'pdf', 'audio', 'other']).optional(),
mimeType: z.string().optional(),
path: z.string().optional(),
})
export type ShumaiAttachedFileContext = z.infer<typeof shumaiAttachedFileContextSchema>
export const shumaiMediaPositionSchema = z.discriminatedUnion('type', [
z.object({ type: z.literal('time'), seconds: z.number() }),
z.object({ type: z.literal('page'), page: z.number() }),
])
export type ShumaiMediaPosition = z.infer<typeof shumaiMediaPositionSchema>
export const shumaiMessageContextSchema = z.object({
user: z
.object({
id: z.string(),
name: z.string(),
role: z.string(),
})
.optional(),
currentAsset: shumaiAssetContextSchema.optional(),
position: shumaiMediaPositionSchema.optional(),
annotation: z.boolean().optional(),
attachedFiles: z.array(shumaiAttachedFileContextSchema).optional(),
referencedAssets: z.array(shumaiAttachedFileContextSchema).optional(),
})
export type ShumaiMessageContext = z.infer<typeof shumaiMessageContextSchema>
export const chatMessageSchema = z.intersection(
z.object({
id: z.string(),
}),
z.unknown(),
) as unknown as z.ZodType<AgentMessage & { id: string }>
) as unknown as z.ZodType<ChatMessage>
export type ChatMessage = AgentMessage & { id: string }
export type ChatMessage = (
| AgentMessage
| {
role: 'custom'
customType: string
content?: unknown
display?: boolean
details?: unknown
timestamp?: number
}
| {
role: 'thinking_level_change'
content: string
timestamp?: number
}
) & { id: string }
+148
View File
@@ -0,0 +1,148 @@
import type { ShumaiMessageContext } from './chat'
/**
* Escapes special XML characters in attribute and text values to prevent
* XML malformation and prompt injection.
*/
export function escapeXmlAttr(str: string): string {
return str
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&apos;')
}
function formatAttr(name: string, value: string | undefined): string {
if (value === undefined || value === null) return ''
return ` ${name}="${escapeXmlAttr(value)}"`
}
/**
* Pure, deterministic serializer that converts a ShumaiMessageContext
* object into a standardized, order-stable <context> XML block.
*
* Adheres strictly to the following invariants:
* 1. Tag sequence: <user>, <current_asset>, <position>, <annotation>, <attached_files>, <referenced_assets>
* 2. Attribute sequence on every tag follows fixed, invariant order.
* 3. Arrays (attachedFiles, referencedAssets) sorted by id ascending.
* 4. Floats formatted with .toFixed(2), integers rounded.
* 5. String values escaped via escapeXmlAttr.
* 6. Exact 2-space indentation and LF newlines.
*/
export function serializeContextToXml(context?: ShumaiMessageContext | null): string {
if (!context) return ''
const lines: string[] = []
// 1. <user ... />
if (context.user) {
let userAttrs = ''
if (context.user.id !== undefined) userAttrs += formatAttr('id', context.user.id)
if (context.user.name !== undefined) userAttrs += formatAttr('name', context.user.name)
if (context.user.role !== undefined) userAttrs += formatAttr('role', context.user.role)
if (userAttrs) {
lines.push(` <user${userAttrs} />`)
}
}
// 2. <current_asset ...> ... </current_asset>
if (context.currentAsset) {
const ca = context.currentAsset
let assetAttrs = ''
if (ca.id !== undefined) assetAttrs += formatAttr('id', ca.id)
if (ca.name !== undefined) assetAttrs += formatAttr('name', ca.name)
if (ca.type !== undefined) assetAttrs += formatAttr('type', ca.type)
if (ca.mediaType !== undefined) assetAttrs += formatAttr('media_type', ca.mediaType)
if (ca.mimeType !== undefined) assetAttrs += formatAttr('mime_type', ca.mimeType)
if (ca.parentId !== undefined) assetAttrs += formatAttr('parent_id', ca.parentId)
if (ca.path !== undefined) assetAttrs += formatAttr('path', ca.path)
if (ca.durationSeconds !== undefined) {
assetAttrs += ` duration_seconds="${ca.durationSeconds.toFixed(2)}"`
}
if (ca.totalFrames !== undefined) {
assetAttrs += ` total_frames="${Math.round(ca.totalFrames)}"`
}
if (ca.totalPages !== undefined) {
assetAttrs += ` total_pages="${Math.round(ca.totalPages)}"`
}
if (ca.navigated !== undefined) {
assetAttrs += ` navigated="${String(ca.navigated)}"`
}
if (ca.ancestors && ca.ancestors.length > 0) {
lines.push(` <current_asset${assetAttrs}>`)
lines.push(' <ancestors>')
for (const anc of ca.ancestors) {
let ancAttrs = ''
if (anc.id !== undefined) ancAttrs += formatAttr('id', anc.id)
if (anc.name !== undefined) ancAttrs += formatAttr('name', anc.name)
lines.push(` <folder${ancAttrs} />`)
}
lines.push(' </ancestors>')
lines.push(' </current_asset>')
} else {
lines.push(` <current_asset${assetAttrs} />`)
}
}
// 3. <position ... />
if (context.position) {
if (context.position.type === 'time') {
lines.push(` <position type="time" seconds="${context.position.seconds.toFixed(2)}" />`)
} else if (context.position.type === 'page') {
lines.push(` <position type="page" page="${Math.round(context.position.page)}" />`)
}
}
// 4. <annotation />
if (context.annotation) {
lines.push(' <annotation />')
}
// 5. <attached_files> ... </attached_files>
if (context.attachedFiles && context.attachedFiles.length > 0) {
const sortedFiles = [...context.attachedFiles].sort((a, b) => a.id.localeCompare(b.id))
lines.push(' <attached_files>')
for (const file of sortedFiles) {
let fileAttrs = ''
if (file.id !== undefined) fileAttrs += formatAttr('id', file.id)
if (file.name !== undefined) fileAttrs += formatAttr('name', file.name)
if (file.type !== undefined) fileAttrs += formatAttr('type', file.type)
if (file.mediaType !== undefined) fileAttrs += formatAttr('media_type', file.mediaType)
if (file.mimeType !== undefined) fileAttrs += formatAttr('mime_type', file.mimeType)
if (file.path !== undefined) fileAttrs += formatAttr('path', file.path)
lines.push(` <file${fileAttrs} />`)
}
lines.push(' </attached_files>')
}
// 6. <referenced_assets> ... </referenced_assets>
if (context.referencedAssets && context.referencedAssets.length > 0) {
const sortedAssets = [...context.referencedAssets].sort((a, b) => a.id.localeCompare(b.id))
lines.push(' <referenced_assets>')
for (const item of sortedAssets) {
if (item.type === 'folder') {
let folderAttrs = ''
if (item.id !== undefined) folderAttrs += formatAttr('id', item.id)
if (item.name !== undefined) folderAttrs += formatAttr('name', item.name)
if (item.path !== undefined) folderAttrs += formatAttr('path', item.path)
lines.push(` <folder${folderAttrs} />`)
} else {
let assetAttrs = ''
if (item.id !== undefined) assetAttrs += formatAttr('id', item.id)
if (item.name !== undefined) assetAttrs += formatAttr('name', item.name)
if (item.type !== undefined) assetAttrs += formatAttr('type', item.type)
if (item.mediaType !== undefined) assetAttrs += formatAttr('media_type', item.mediaType)
if (item.mimeType !== undefined) assetAttrs += formatAttr('mime_type', item.mimeType)
if (item.path !== undefined) assetAttrs += formatAttr('path', item.path)
lines.push(` <asset${assetAttrs} />`)
}
}
lines.push(' </referenced_assets>')
}
if (lines.length === 0) return ''
return `<context>\n${lines.join('\n')}\n</context>`
}
+2
View File
@@ -24,3 +24,5 @@ export * from './auditLog'
export * from './watermark'
export * from './quota'
export * from './kanban'
export * from './recents'
export * from './context'
+2 -1
View File
@@ -1,6 +1,7 @@
import { z } from 'zod'
import { UserType } from '@shumai/db/enums'
import { paginationPageInfoSchema, paginationParamsSchema } from './pagination'
import { assetTypeFilterSchema } from './asset'
export const createProjectRequestSchema = z.object({
name: z.string(),
@@ -58,7 +59,7 @@ export type ProjectUserInfo = z.infer<typeof projectUserInfoSchema>
export const recentlyDeletedRequestSchema = z
.object({
assetType: z.string(),
assetType: assetTypeFilterSchema.optional().default('all'),
sort: z.enum(['createdAt', 'name', 'size']).optional(),
order: z.enum(['asc', 'desc']).optional(),
})
+10
View File
@@ -0,0 +1,10 @@
import { z } from 'zod'
import { paginationParamsSchema } from './pagination'
export const recordRecentViewRequestSchema = z.object({
assetId: z.string(),
})
export type RecordRecentViewRequest = z.infer<typeof recordRecentViewRequestSchema>
export const listRecentsRequestSchema = paginationParamsSchema
export type ListRecentsRequest = z.infer<typeof listRecentsRequestSchema>
+10
View File
@@ -74,11 +74,21 @@ export const VideoTranscodeStrategy = {
export type VideoTranscodeStrategy =
(typeof VideoTranscodeStrategy)[keyof typeof VideoTranscodeStrategy]
export const HardwareAcceleration = {
off: 'off',
auto: 'auto',
} as const
export type HardwareAcceleration = (typeof HardwareAcceleration)[keyof typeof HardwareAcceleration]
export const updateTeamSettingsRequestSchema = z.union([
z.object({
key: z.literal('transcode.videoStrategy'),
value: z.nativeEnum(VideoTranscodeStrategy),
}),
z.object({
key: z.literal('transcode.hardwareAcceleration'),
value: z.nativeEnum(HardwareAcceleration),
}),
])
export type UpdateTeamSettingsRequest = z.infer<typeof updateTeamSettingsRequestSchema>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/e2e",
"version": "0.3.10",
"version": "0.4.1",
"private": true,
"type": "module",
"dependencies": {
@@ -1,146 +0,0 @@
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest'
import { prisma } from '@shumai/db'
import { setupTestDbHooks } from '@shumai/db/test'
import { workflowService, TaskQueueAgent } from '@shumai/workflow-core'
import { initAgentWorkflows } from '@shumai/agent'
import { s3Service } from '@shumai/core/src/s3/s3'
import { fileURLToPath } from 'url'
import * as path from 'path'
const currentDir = path.dirname(fileURLToPath(import.meta.url))
const agentWorkflowsPath = path.resolve(currentDir, '../../../apps/agent/src/workflows.ts')
describe.each(['local', 'temporal'] as const)(
'Workflow E2E - agentToolCall (executor: %s)',
(mode) => {
setupTestDbHooks()
let agentWorkerPromise: Promise<void> | null = null
beforeAll(async () => {
process.env.S3_BUCKET = 'shumai-e2e-test-bucket-toolcall'
process.env.GEMINI_API_KEY = 'dummy-key'
workflowService.setExecutorType(mode)
initAgentWorkflows()
if (mode === 'temporal') {
console.log('Starting background worker for tool call Temporal E2E tests...')
agentWorkerPromise = workflowService.startWorkers(TaskQueueAgent, {
workflowsPath: agentWorkflowsPath,
})
await new Promise((resolve) => setTimeout(resolve, 2000))
} else {
console.log('Starting local workflow service polling...')
workflowService.start()
}
})
afterAll(async () => {
if (mode === 'temporal') {
console.log('Shutting down Temporal workers...')
await workflowService.shutdownWorkers()
await Promise.all([agentWorkerPromise].filter(Boolean))
}
workflowService.close()
vi.restoreAllMocks()
try {
console.log('Cleaning up local E2E storage files...')
await s3Service.deletePrefix('shumai-e2e-test-bucket-toolcall', '')
} catch (err) {
console.error('Failed to clean up E2E storage folder:', err)
}
})
it('should run agentToolCall workflow and execute list_assets successfully', async () => {
// 1. Seed Database
const team = await prisma.team.create({
data: { name: 'E2E Tool Call Team' },
})
const project = await prisma.project.create({
data: { name: 'E2E Tool Call Project', teamId: team.id },
})
const regularUser = await prisma.user.create({
data: {
name: 'Regular Editor User',
email: 'editor@example.com',
type: 'human',
},
})
// Setup team member with owner/editor role and team scope
await prisma.teamMember.create({
data: {
teamId: team.id,
userId: regularUser.id,
role: 'editor',
scope: 'team',
},
})
// Create a folder asset (parent)
const parentFolder = await prisma.asset.create({
data: {
name: 'TestParentFolder',
type: 'folder',
status: 'processed',
projectId: project.id,
},
})
// Create a child file asset inside the parent folder
const childFile = await prisma.asset.create({
data: {
name: 'TestChildFile.png',
type: 'file',
status: 'uploaded',
mediaType: 'image/png',
projectId: project.id,
parentId: parentFolder.id,
},
})
// 2. Create Workflow Task
const task = await prisma.workflowTask.create({
data: {
type: 'agent_tool_call',
status: 'pending',
assetId: parentFolder.id,
projectId: project.id,
teamId: team.id,
payload: {
projectId: project.id,
agentToolCall: {
toolName: 'list_assets',
args: {
parent: parentFolder.id,
page: 1,
pageSize: 20,
type: 'all',
},
userId: regularUser.id,
},
},
},
})
// 3. Wait for workflow to complete
console.log(`Submitted E2E Tool Call Workflow Task. ID: ${task.id}. Awaiting completion...`)
const completedTask = await workflowService.executeWait(task, 45000)
// 4. Verification
expect(completedTask.status).toBe('completed')
// Verify task output contains the list of files, and childFile.id is present in assets
const output = completedTask.output as unknown as { assets: { id: string }[] }
expect(output).toBeDefined()
expect(output.assets).toBeDefined()
expect(output.assets.length).toBeGreaterThan(0)
const assetIds = output.assets.map((a) => a.id)
expect(assetIds).toContain(childFile.id)
}, 50000)
},
)
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/tableprinter",
"version": "0.3.10",
"version": "0.4.1",
"private": true,
"type": "module",
"main": "./src/index.ts",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/transcode",
"version": "0.3.10",
"version": "0.4.1",
"private": true,
"type": "module",
"main": "./src/index.ts",
@@ -172,6 +172,7 @@ describe('Transcode Activities', () => {
originalHeight: 1080,
duration: 10,
bitRate: 1000,
videoBitRate: 850000,
frameRate: 30,
totalFrames: 300,
hasAudio: true,
@@ -193,6 +194,7 @@ describe('Transcode Activities', () => {
expect(transcodeService.getVideoInfo).toHaveBeenCalledWith('/tmp/v.mp4')
expect(result.duration).toBe(10)
expect(result.metadata?.originalWidth).toBe(1920)
expect(result.metadata?.videoBitRate).toBe(850000)
expect(result.metadata?.videoCodec).toBe('Advanced Video Coding')
expect(result.metadata?.audioCodec).toBe('MPEG-4 Audio')
expect(result.metadata?.audioChannels).toBe(2)
@@ -590,9 +592,17 @@ describe('Transcode Activities', () => {
videoSpec: { resolution: '720p', width: 1280, height: 720 },
duration: 10,
originalFps: 30,
hardwareAcceleration: 'auto',
sourceVideoBitrate: 600_000,
})
expect(transcodeService.transcodeVideo).toHaveBeenCalled()
expect(transcodeService.transcodeVideo).toHaveBeenCalledWith(
expect.objectContaining({
inputFile: '/tmp/v.mp4',
hardwareAcceleration: 'auto',
sourceVideoBitrate: 600_000,
}),
)
})
it('should call transcodeService.takeScreenshots', async () => {
@@ -104,6 +104,7 @@ export async function getMediaInfoActivity(params: {
originalHeight: info.originalHeight,
duration: info.duration,
bitRate: info.bitRate,
videoBitRate: info.videoBitRate,
frameRate: info.frameRate,
totalFrames: info.totalFrames,
startTimecode: info.startTimecode || '00:00:00:00',
@@ -220,6 +221,8 @@ export interface VideoActivityParams {
videoSpec: PrismaJson.VideoTranscode
duration: number
originalFps: number
hardwareAcceleration?: PrismaJson.HardwareAcceleration
sourceVideoBitrate?: number
}
export async function transcodeVideoActivity(
@@ -262,6 +265,8 @@ export async function transcodeVideoActivity(
height: params.videoSpec.height,
frameRate: targetFps || undefined,
disableAudio,
hardwareAcceleration: params.hardwareAcceleration,
sourceVideoBitrate: params.sourceVideoBitrate,
})
const stat = fs.statSync(outputFile)

Some files were not shown because too many files have changed in this diff Show More