Compare commits

...
36 Commits
Author SHA1 Message Date
yiling f0bdccf713 Release v0.6.2 2026-10-29 20:29:50 +08:00
yiling 5b7fc04b02 docs: document MCP OAuth support and simplify unreleased changelog 2026-10-29 17:52:45 +08:00
Yiling-J 687b5a79d8 fix(core): strip trailing slashes when normalizing auth and MCP resource URLs (#506)
* fix(core): strip trailing slashes when normalizing auth and MCP resource URLs

* docs: document BETTER_AUTH_URL in README and quickstart guides

* docs: prioritize AWS_ENDPOINT_URL_S3 and clarify applicability to local storage

* docs: refine AWS_ENDPOINT_URL_S3 guidance for local storage deployments
2026-10-29 17:24:31 +08:00
Yiling-J baf30730af feat(mcp): add OAuth 2.1 support (#505)
* feat(mcp): add OAuth 2.1 support with dynamic client registration

* feat(api): alias bare oauth-authorization-server discovery endpoint

* fix(auth): preserve user session on OAuth sign-in redirect to consent
2026-10-29 15:39:37 +08:00
yiling 96539207d0 update readme 2026-10-28 11:41:28 +08:00
yiling 43f95a2fa2 update cn compose 2026-10-28 11:38:07 +08:00
yiling 0f92a5377f update readme 2026-10-28 10:30:13 +08:00
Yiling-J 4e3e17a547 docs: simplify AGENTS.md developer guide (#501) 2026-10-27 15:26:42 +08:00
Yiling-J b3cae4f2b0 feat: move MCP to /mcp and add teammate operations (#500)
* feat(operations): move MCP to /mcp and add search, comment, metadata, version, and upload operations

- Serve the MCP server at /mcp instead of /api/mcp
- Add search_assets, copy_assets, get_folder_instructions, list_comments,
  create_comment, resolve_comment, list_metadata_fields,
  update_asset_metadata, create_version_stack, list_versions, and
  remove_version on the agent, MCP, and CLI
- Add create_file and create_version (agent, MCP) with Creation Context
  metadata, and complete_upload (MCP) for presigned two-step uploads
- Replace the native agent create_file/create_version tools with
  Operation-backed ones
- Route the comment-complete, metadata, copy, version stack, and
  AGENTS.md read REST endpoints through their Operations

* docs(readme): add built-in MCP server and CLI to features list
2026-10-27 14:37:26 +08:00
Yiling-J 50fbd97953 feat: expose read_asset and download_asset on MCP and the CLI (#499)
* feat(asset-read): expose read_asset on MCP and the CLI

Enable the mcp and cli surfaces for read_asset and get_asset_render.

- MCP: add per-Operation tool extensions. The read presenter attaches up
  to 8 images (2 MB each) inline, lists image links, supports
  inlineImages: false, and tells the model to call get_asset_render when
  a render is pending. Storage keys are stripped from the result.
- CLI: generated commands can flatten object inputs into prefixed flags
  (cli.flatten) and omit fields (cli.omit); add per-command extensions.
  New `read` and `render` commands print image links, download them with
  --out, and support --no-wait with a printed `render <taskId>` hint.
- Round frame timestamps in labels to 3 decimals.

* fix(mcp): make tool input schemas portable to single-type dialects

Nullable inputs were emitted as `type: ["number", "null"]` (or a `null`
anyOf branch), which clients that map tool schemas onto an OpenAPI-style
subset (e.g. Gemini function declarations) may reject.

- Make read_asset's startPage, endPage, and degree optional instead of
  nullable.
- Move null handling into a shared dropNullOptionals helper in
  @shumai/operations that also strips nulls inside nested config
  objects. The agent uses it, and the MCP server applies it before the
  SDK validates arguments, so models that send null keep working.
- Test that no Operation input schema (and no listed MCP tool) uses a
  nullable type.

* feat(asset-download): share download_asset across agent, MCP and CLI

Turn the agent-only download_asset tool into an Operation on all three
surfaces.

- download_asset takes up to 50 file or version stack IDs and returns
  presigned links. proxy (default true) picks the web preview when there
  is one, as the agent always did; proxy: false returns the original.
  Folders are rejected. Read is checked on every ID before anything runs.
- Agent: an extension saves the files into the .pi sandbox and keeps the
  agent-only storage key mode (e.g. frames from read_asset). Agent tool
  extensions gain description, parameterOverrides and intercept.
- CLI: `shumai-cli download <assetId...> [--out <dir>] [--original]`
  streams files to disk without overwriting existing names.
- read_asset's unsupported-type error now names the right way to
  download on each surface (download_asset, or `shumai-cli download`).
- Add the Download Asset toggle to agent settings.
2026-10-27 08:09:11 +08:00
Yiling-J 155fb95a0e feat(asset-read): rewrite read_asset as a reader registry and Operations (#498)
Replace the monolithic agent read_asset tool with a reader registry in
@shumai/core/src/asset-read (model3d, image, video, document) behind a
shared pipeline that handles access checks, version stacks, annotations,
render tasks, and waiting.

- Add read_asset and get_asset_render Operations (agent surface only).
  Renders that outlast the caller's wait budget return "pending" with the
  workflow task ID; the read request is stored on the task payload so
  get_asset_render works across restarts and instances (requester only).
- Add workflowService.waitFor and presign expiry support.
- Keep agent output compatible via an agent tool extension (s3KeyOnly,
  image blocks, session image details); autofill keeps its team-scoped tool.
- Cap video frames at 20 per call; add the get_asset_render agent toggle.
2026-10-27 08:09:10 +08:00
Yiling-J e44938cb8f feat(cli): generate shumai-cli commands from Operations with commander (#496)
Rebuild the CLI on commander. Commands for every cli-surface Operation
(project ls, ls, mkdir, rename, move/mv, delete/rm) are generated from
@shumai/operations: positionals, options, choices, numeric parsing and
help text come from the Zod input schema. They call POST /api/ops/:name
with x-shumai-client: cli.

Existing invocations keep working. Adds --json, ls --type/--first/
--after, typo suggestions, and generated help. upload and create-version
stay hand-written. Drops the unused @shumai/core dependency.
2026-10-27 08:09:10 +08:00
Yiling-J 4d61786799 feat(mcp): serve Operations over MCP and a generic /api/ops endpoint (#495)
Add a stateless Streamable HTTP MCP server at /api/mcp that exposes every
mcp-surface Operation with its input/output schemas and annotations, and
POST /api/ops/:name for the CLI. Both require an API token (session
cookies are rejected), run Operations as the token's user, honor demo
read-only mode, and record via mcp/cli/api in audit logs.

Also make list_projects toggleable in agent settings and document MCP
client setup.
2026-10-27 08:09:09 +08:00
Yiling-J 76057ccd21 feat(operations): add shared Operation layer for agent capabilities (#494)
Introduce @shumai/operations (pure definitions: Zod schemas, metadata,
CLI hints) and @shumai/core/src/operations (implementOperation and the
runOperation pipeline: validate, authorize, prepare, execute, validate
output, audit).

Migrate list_assets, create_folder, rename_asset, move_assets and
delete_asset to Operations, and add list_projects. The agent now builds
these tools from the registry, and the folder create/rename, file
rename and reparent routes call the same Operations.

Audit logs gain a nullable via column recording the surface. A lint
rule keeps the Prisma client out of Operation implementations.
2026-10-27 08:09:09 +08:00
Yiling-J 47ee794ae4 fix(agent): enforce access checks in read_thread and before file uploads (#493)
read_thread returned any comment thread by ID. It now requires Read on
the thread's asset for the acting user, and confines system agents
without a user to their own team.

create_file and create_version uploaded to storage before checking Edit
permission, leaving orphaned objects on denied calls. The permission
check now runs first.
2026-10-26 11:14:37 +08:00
Yiling-J 22486b893b feat(api-token): store API tokens as SHA-256 hashes (#492)
New tokens are 32 random bytes with a shumai_ prefix and are returned
only once at creation. The list endpoint returns a 4-character hint
instead of the plaintext. A migration hashes existing tokens in place so
they keep authenticating.
2026-10-26 11:08:46 +08:00
yiling c2af7494ec Release v0.6.1 2026-10-24 13:21:50 +08:00
yiling b7d2748b00 docs(changelog): add bun 1.4.4 upgrade to unreleased changes 2026-10-24 12:02:22 +08:00
Yiling-J 3467c0d92b chore(docker): update Aliyun compose images and document transcode worker scaling in README_CN (#491) 2026-10-24 11:51:37 +08:00
Yiling-J 22fede0290 fix(webui): prevent clipping of long text overlay and date picker in cards (#490)
* fix(webui): prevent clipping of long text overlay and date picker in cards

* docs: update DeepWiki badge url in README and README_CN

* fix(webui): preserve expanded overlay height and textarea style in LongTextField

* fix(webui): add bottom padding to file list to prevent screen clipping of expanded fields

* fix(webui): expand directly into edit mode on single click for LongTextField

* fix(webui): prevent file selection when interacting with metadata fields in cards and list rows
2026-10-24 11:40:47 +08:00
Yiling-J d87fe43b0f feat(dashboard): add workflow tasks monitoring and stopping to team dashboard (#489)
* feat(dashboard): add workflow tasks monitoring and stopping to team dashboard

* fix(asset): retain workflow tasks on asset purge and mark active tasks as failed

* style(webui): add edge padding to audit logs and workflow tasks tables

* fix(workflow): atomically update asset status to failed when task is stopped

* fix(workflow): propagate cancellation errors, guard concurrent task stop, and localize UI

* docs(changelog): keep only added log for workflow tasks dashboard

* test(provider): mock upstream catalog api calls using saved fixtures

* feat(dashboard): show file name, size, and project name in workflow tasks list
2026-10-23 16:44:52 +08:00
Yiling-J 7a0ffca629 Add feedback invitation to README
Added a feedback section to encourage user engagement.
2026-10-22 20:39:56 +08:00
Yiling-J 5cf6d31794 chore(deps): upgrade bun to 1.4.4 and migrate to bun fmt (#488)
- Upgrade Bun to 1.4.4 across Dockerfiles, CI workflows, and release configurations.
- Update @types/bun and bun-types.
- Remove eslint-plugin-prettier and update format script to use native bun fmt.
- Configure .prettierignore to exclude packages/webui/public and minified files.
2026-10-22 20:25:54 +08:00
Yiling-J 0d5fe48a3a docs(docker): add guide for scaling transcoding workers horizontally (#486) 2026-10-21 12:45:09 +08:00
Yiling-J 19eed521ae fix(webui): prevent unwanted redirects to login on reset-password page (#487)
* fix(webui): allow reset-password route with token when stale auth exists

* fix(webui): prevent 401 redirect to login on reset-password page
2026-10-21 12:12:25 +08:00
yiling e05a23bcc2 Release v0.6.0 2026-10-20 20:02:34 +08:00
Yiling-J d957ab2339 fix(webui): fix loading skeleton layout mismatches and keep left carousel visible (#485)
* fix(webui): fix loading skeleton layout mismatches and keep left carousel visible

* fix(webui): update mobile file list skeleton to match card layout

* fix(webui): blur video poster before playback with instant cut on play

* docs: consolidate webui changelog entries into single line
2026-10-20 17:39:40 +08:00
Yiling-J 1fcd7245ea fix(transcode): ensure durable file exchange and crash recovery across workflow steps (#484)
* fix(transcode): ensure durable file exchange and crash recovery across workflow steps

* fix(transcode): recognize AWS SDK NoSuchKey by name and add workflow E2E recovery test
2026-10-20 11:29:22 +08:00
Yiling-J 176b7f0eab feat(workflow): migrate workflow engine from temporal to dbos (#481)
* feat(workflow): migrate workflow engine from temporal to dbos

Replace Temporal and LocalExecutor with DBOS Transact (@dbos-inc/dbos-sdk) as the unified workflow engine. Background tasks, media transcoding, and AI agent workflows now execute with durable steps and task queues directly against PostgreSQL, eliminating the need for an external Temporal cluster and separate polling executors.

* fix(workflow): submit tasks via DBOSClient to allow enqueueing from steps

Enqueuing workflows using DBOS.enqueueWorkflowWithOptions threw a
DBOSInvalidWorkflowTransitionError when triggered from within a running
step or activity (e.g. creating embedding or autofill tasks during
video transcoding).

Use DBOSClient to submit and cancel workflow tasks directly against the
system database, detaching execution from the ambient workflow/step
context.

* feat(web): support SHUMAI_WORKERS environment variable

* fix(workflow): ensure CLI tasks are enqueued to DBOS and run DBOS migrations in global setup

- Initialize workflows and wait for pending DBOS submissions in shumai regenerate-embeddings CLI
- Remove no-op submit bypass and enqueue tasks via DBOSClient in producer and CLI contexts
- Add DBOS migration runner in test global setup to avoid concurrent migration deadlocks across test forks
- Update changelog and add regression tests

* fix(workflow): ensure unique per-instance executor identity for worker replicas

- Derive unique per-instance DBOS executor IDs across worker replicas

- Support SHUMAI_WORKER_ID, DBOS__VMID, and POD_NAME (Kubernetes Downward API)

- Disambiguate multi-replica bare metal/container deployments with host, PID, and instance suffix

- Prevent startup recovery from re-enqueueing workflows actively executed by other live workers

- Add multi-instance startup recovery tests and update deployment documentation

* fix(workflow): only register listened queues and update concurrency on change

- Only register queues that the executor instance actively listens to

- Use always_update conflict resolution so environment variable changes take effect on restart

- Prevent dedicated workers from overwriting unmanaged queue concurrency configurations

- Add tests verifying concurrency updates and queue isolation across worker roles

* refactor(workflow): simplify activities to use defineStep and direct calls (#482)

* refactor(workflow): simplify activities to use defineStep and direct calls

- Wrap activities using defineStep from @shumai/workflow-core
- Remove obsolete getActivities, registerActivities, dynamic activity proxies, and workerQueue arguments
- Remove executor.ts and registry.ts, consolidating workflow registration into workflow.ts
- Call activities directly across transcode and agent workflows
- Update all corresponding workflow tests and developer guide documentation

* fix(workflow): properly detect DBOSWorkflowCancelledError in runOnCancel fallback

- DBOSWorkflowCancelledError in DBOS SDK does not set name, inheriting 'Error'
- Implement isDbosWorkflowCancelledError checking instanceof, constructor.name, and dbosErrorCode
- Update unit tests to verify real DBOS SDK cancellation error instances

* docs(workflow): update documentation and readme for dbos migration

- Rename docs/configuration/temporal.mdx to docs/configuration/distributed.mdx
- Document DBOS-based distributed worker architecture and task queues
- Remove obsolete docker-compose/temporal/
- Update environment variables documentation in docs/configuration/env-variables.mdx
- Update references in README.md, README_CN.md, docs/docs.json, and related guides

* feat(deploy): implement KEDA ScaledJob and scale-to-zero On-Demand transcoding (#483)

* feat(deploy): add shumai-transcode docker image and k8s autoscaling example with garage s3

* docs(k8s): document port-forwarding and in-cluster s3 domain mapping

* feat(storage): support public s3 endpoint for browser uploads and update k8s example

* fix(k8s): configure s3 bucket cors rules in garage initialization

* fix(k8s): increase transcode worker memory limit to 4Gi for 4K video encoding

* feat(deploy): add AWS EKS deployment with Graviton3 Spot nodegroups and autoscaling

* docs(deploy): redesign EKS documentation, rename k8s to eks, and add scalable deployment feature

* docs: rephrase DBOS feature bullet to Durable Workflows via DBOS

* docs(eks): upgrade default instances to Graviton5 c9g.large and c9g.xlarge

* feat(eks): use On-Demand for general nodegroup and add spot capacity diversification

* docs(eks): fix Architecture diagram to locate all transcode worker pods in Transcode Compute Pool

* feat(deploy): implement KEDA ScaledJob and scale-to-zero On-Demand transcoding

* feat(transcode): support idle-timeout auto-drain for KEDA scaled jobs

* fix(deploy): fix EKS deployment manifests and documentation based on cluster verification
2026-10-19 15:35:08 +08:00
yiling f7ed3bafdf Release v0.5.3 2026-10-16 22:50:47 +08:00
Yiling-J 9f76e61e23 Add documentation for LiteRT-LM Embedding Server setup
Updated documentation for LiteRT-LM Embedding Server setup and other features.
2026-10-16 22:42:07 +08:00
Yiling-J 7c297895e5 feat(embedding): add compose tiers, docs, and regenerate-embeddings CLI (#480)
* feat(embedding): update compose tiers, docs, and add regenerate-embeddings CLI

- Add Lite, Embedding, and Full Docker Compose configurations (and Aliyun mirrors)
- Set CONCURRENCY_AGENT to 1 for compose files containing embedding-server
- Update README and README_CN with compose options, recommended RAM, and semantic search links
- Add LiteRT-LM Embedding Server setup guide in docs/using-shumai/embedding-server.mdx
- Add shumai regenerate-embeddings CLI command and EmbeddingService to regenerate embeddings across teams
- Add comprehensive test coverage for EmbeddingService

* fix(docker): remove basic auth for turntable-renderer in full compose

* fix(agent): lock and disable embedding agent when ENABLE_EMBEDDING_AGENT is false

Ensure that when ENABLE_EMBEDDING_AGENT is set to 'false', existing embedding agents are automatically disabled on startup, marked as read-only, and blocked from manual API modifications or creations. Additionally guard background task creation and semantic search when the environment variable disables embedding agents.

* test(upload): remove flaky status assertion on workflow tasks
2026-10-16 21:20:25 +08:00
Yiling-J 0f318b4050 feat(search): render results in responsive card grid with sprite preview and new-tab navigation (#479)
* feat(search): render results in responsive card grid with sprite preview and new-tab navigation

* fix(search): align semantic matched duration badge style with standard duration badge

* fix(webui): use pointer cursor instead of crosshair cursor for sprite scrubber on hover
2026-10-16 10:42:32 +08:00
Yiling-J 1a46f63160 fix(agent): adaptively set video embedding frame count based on aspect ratio (#477)
* fix(agent): adaptively set video embedding frame count based on aspect ratio

Adjust sampled video frame counts between 15 and 14 based on the video's aspect ratio. Standard aspect ratios (1:1, 4:3, 3:4, 16:9, 9:16, 21:9) stay within the 2048 token signature bucket when using 15 frames, while non-standard or custom aspect ratios use 14 frames to guarantee that sequence length never exceeds 2048 tokens, preventing out-of-memory errors on the embedding server.

* feat(agent): persist video chunk embeddings incrementally and resume on retry (#478)
2026-10-16 08:36:51 +08:00
Yiling-J 6cc90bf973 feat(search): generate query embeddings directly for semantic search (#476)
* feat(search): generate query embeddings directly for semantic search

* fix(search): resolve embedding provider from env, redact query logs, and preserve case in cache
2026-10-15 20:49:45 +08:00
Yiling-J b7271777e0 feat(agent): support gemma-embedding-2-openai provider (#475)
* feat(agent): support gemma-embedding-2-openai provider

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

* refactor(agent): remove unused legacy generateEmbeddingActivity

* chore(agent): align sharp version to 0.35.4

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

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

* fix(transcode,agent): populate buffer entries in Bun.Archive and validate frame sizes
2026-10-15 15:49:24 +08:00
431 changed files with 52470 additions and 16762 deletions
+4 -4
View File
@@ -24,7 +24,7 @@ jobs:
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.2
bun-version: 1.4.4
- name: Install dependencies
run: bun install
@@ -81,7 +81,7 @@ jobs:
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.2
bun-version: 1.4.4
- name: Install dependencies
run: bun install
@@ -126,7 +126,7 @@ jobs:
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.2
bun-version: 1.4.4
- name: Install dependencies
run: bun install
@@ -163,7 +163,7 @@ jobs:
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.2
bun-version: 1.4.4
- name: Install dependencies
run: bun install
+1 -1
View File
@@ -36,7 +36,7 @@ jobs:
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.2
bun-version: 1.4.4
- name: Setup Node.js
uses: actions/setup-node@v6
+28
View File
@@ -74,3 +74,31 @@ jobs:
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Extract metadata for Docker (Transcode Worker)
- name: Extract metadata for Docker (Transcode Worker)
id: meta-transcode
uses: docker/metadata-action@v5
with:
images: |
shumaione/shumai-transcode
crpi-000nkafzu6xvpwsc.cn-hongkong.personal.cr.aliyuncs.com/shumai-one/shumai-transcode
tags: |
type=semver,pattern={{version}}
type=ref,event=branch,enable=${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && !inputs.pr && !inputs.tag) }}
type=raw,value=pr-${{ inputs.pr }},enable=${{ github.event_name == 'workflow_dispatch' && inputs.pr != '' && inputs.tag == '' }}
type=raw,value=${{ inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' && inputs.tag != '' }}
labels: |
org.opencontainers.image.revision=${{ steps.checkout.outputs.commit }}
# Build and push Docker image (Transcode Worker)
- name: Build and push Docker image (Transcode Worker)
uses: docker/build-push-action@v7
with:
platforms: linux/amd64,linux/arm64
context: .
file: ./Dockerfile.transcode
push: true
provenance: false
tags: ${{ steps.meta-transcode.outputs.tags }}
labels: ${{ steps.meta-transcode.outputs.labels }}
+2
View File
@@ -25,3 +25,5 @@ code_quality.md
# Paraglide JS
packages/webui/paraglide
runner-package.json
+3
View File
@@ -9,3 +9,6 @@ packages/webui/paraglide
*.md
**/*.md
docs/changelog.mdx
packages/webui/public
**/*.min.*
+67 -413
View File
@@ -10,14 +10,11 @@ Before starting any task, create and switch to a new feature branch:
git checkout -b <branch-name>
```
Complete the task on that branch.
After finishing the work and verifying that all checks pass:
1. Update `CHANGELOG.md` under `## [Unreleased]` for user-facing changes (see [Changelog Guidelines](#changelog-guidelines)).
2. Stage and commit your changes.
3. Push the branch to `origin`.
4. Open a pull request using the GitHub CLI.
2. Stage and commit your changes following [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) (`<type>[optional scope]: <description>` in imperative mood, e.g., `feat(auth): add OAuth login support`, `fix:`, `docs:`, `refactor:`, `test:`, `chore:`, and `!` or `BREAKING CHANGE:` for breaking changes).
3. Push the branch to `origin` and open a pull request using the GitHub CLI:
```bash
git add .
@@ -26,55 +23,15 @@ git push origin <branch-name>
gh pr create --title "<pull-request-title>" --body "<pull-request-body>"
```
---
## Commit Messages
We follow the Conventional Commits specification.
Commit messages MUST be formatted as:
```text
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
```
Example:
```text
feat(auth): add OAuth login support
```
The commit contains the following structural elements, to communicate intent to the consumers of your library:
1. `fix:` a commit of the type `fix` patches a bug in your codebase.
2. `feat:` a commit of the type `feat` introduces a new feature to the codebase.
3. `BREAKING CHANGE:` a footer or `!` after the type/scope introduces a breaking API change.
4. Additional types are allowed (for example: `docs:`, `refactor:`, `test:`, `chore:`).
Write commit messages in the imperative mood and keep descriptions concise and specific.
Reference:
https://www.conventionalcommits.org/en/v1.0.0/#summary
---
## Changelog Guidelines
We maintain `CHANGELOG.md` following [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
We maintain `CHANGELOG.md` following [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Before opening a pull request, add an entry under `## [Unreleased]` for any user-facing changes:
Before opening a pull request, add an entry under `## [Unreleased]` for any user-facing changes:
- **End-User Friendly**: Make entries easy to understand for end users. For new features, explain what they actually do in plain language without heavy technical jargon. For bug fixes, describe what the bug was in a friendly, relatable way rather than focusing on internal code mechanics, file paths, or private symbols.
- **End-User Friendly**: Write in plain language for end users without heavy technical jargon, internal file paths, or private symbols.
- **Formatting**: `- **<scope>**: <Description>` (e.g. `- **asset**: Fix an issue where moving a video to trash while it was still transcoding could cause it to lose its trashed status`).
- **No PR Numbers**: Do not include PR numbers or links; the release pipeline automatically appends the detailed PR list.
- **No PR Numbers**: Do not include PR numbers or links; the release pipeline appends them automatically.
- **Internal Changes**: Routine refactors, test additions, or internal chores without external behavior changes may omit changelog updates.
---
## Pull Request Template
```md
@@ -106,7 +63,7 @@ Add any additional context, caveats, or follow-up work.
## Submission Rules
- **Strict Requirement**: A submission is considered complete **only** when there is a single final code state in which **all** of the following pass **simultaneously**:
- **Strict Requirement**: A submission is complete **only** when there is a single final code state in which **all** of the following pass **simultaneously** (do not submit intermediate states where some checks fail):
- `bun run lint`
- `bun run format`
- `bun run typecheck`
@@ -114,392 +71,89 @@ Add any additional context, caveats, or follow-up work.
- `bun run test:e2e:app`
- `bun run test:e2e:webui`
- `bun run test:e2e:workflow`
- **Backend Testing Mandate**: Every backend feature, service method, workflow, and activity MUST be accompanied by comprehensive tests. Logic-heavy code without corresponding test coverage is considered incomplete.
- Fixes must be iterated until **no check causes any other check to fail**.
- **Type Safety**: The use of explicit `any` is strictly forbidden and will result in lint errors. You should use `unknown` instead when the type is not known. If you absolutely must use `any` due to a limitation (e.g. interacting with an untyped 3rd party library), you must add an eslint-disable comment (e.g., `// eslint-disable-next-line @typescript-eslint/no-explicit-any`) and include a comment directly above it clearly explaining _why_ we cannot be type-safe here.
- Do **not** submit intermediate states where some checks pass and others fail, even temporarily.
- **Cleanup Requirement**: Remove all verification related files (scripts, screenshots, `verification/` folder) before submit.
## Backend Architecture
The backend is built with:
- **Runtime**: Bun
- **Framework**: Hono
- **ORM**: Prisma (with Pgvector18)
- **Database**: Pgvector18
- **Backend Testing Mandate**: Every backend feature, service method, workflow, and activity MUST have comprehensive tests.
- **Type Safety**: Explicit `any` is strictly forbidden. Use `unknown` when the type is unknown. If `any` is unavoidable (e.g., untyped 3rd-party library), add `// eslint-disable-next-line @typescript-eslint/no-explicit-any` with a comment directly above explaining why.
- **Cleanup Requirement**: Remove all temporary verification files, scripts, screenshots, and the `verification/` folder before submitting.
## Workspace Architecture
The project is a monorepo managed by **Bun Workspaces**. It follows a strictly decoupled architecture where each domain or layer is its own package:
The project is a Bun Workspaces monorepo (Bun runtime, Hono API, Prisma + Pgvector18 DB, React + Tailwind CSS + Shadcn UI frontend):
- **WebUI (`packages/webui`)**: React-based frontend.
- **API (`packages/api`)**: Hono-based HTTP entry point. Handles requests and calls Core services.
- **Core (`packages/core`)**: Business logic, services, and infrastructure utilities.
- **Database (`packages/db`)**: Prisma client, schema, and migrations.
- **DTOs (`packages/dtos`)**: Shared type definitions and Zod schemas used by both API and WebUI.
- **Workers**: Specialized packages for background task execution:
- `@shumai/workflow-core`: Common workflow engine logic.
- `@shumai/agent`: AI agent workflows and activities.
- `@shumai/transcode`: Media processing workflows and activities.
- **`packages/webui`**: React frontend (`bun run dev` runs on port 3000).
- **`packages/api`**: Hono HTTP entry point and MCP server.
- **`packages/core`**: Business logic, services, operations, and asset readers.
- **`packages/db`**: Prisma client, schema, and migrations.
- **`packages/dtos`**: Shared Zod schemas and TypeScript types (do not append `Dto` suffix to type names).
- **`packages/operations`**: Shared Operation definitions (`@shumai/operations`) used by agent tools, MCP, and `apps/cli`.
- **Workers**: `@shumai/workflow-core` (DBOS engine), `@shumai/agent` (AI agent workflows/activities), and `@shumai/transcode` (media workflows/activities).
### Layered Communication Rules
### Layered Communication & Code Patterns
1. **API Layer** calls **Core Layer**. Do not access the database directly in the API layer.
2. **Core Layer** calls **Database Layer** and other Core services.
3. **DTO Layer** is imported by all layers to ensure end-to-end type safety.
4. **No Direct DB Leak**: Do not return Prisma objects directly from the API; always map them to DTOs.
1. **API → Core → DB**: API routes (`packages/api/src/`) call Core services (`packages/core/src/`), which call `@shumai/db`. Never access `prisma` directly in the API layer, and never return raw Prisma objects from API routes (always map to DTOs).
2. **Services**: Define service logic as instance methods on a class and export a singleton instance (check existing services in `packages/core/src/`).
3. **Hono Routes**: Always chain `.get()` / `.post()` on a Hono instance using `zValidator` and export the chained route as default to preserve Hono RPC type inference (check `packages/api/src/`).
4. **Operations First**: If an Operation exists for an action, API routes must call it via `runOperation` instead of re-implementing permission checks and audit logging. UI-only routes keep calling services directly.
5. **Dependencies & Imports**:
- Declare runtime `dependencies` in each package's local `package.json` (`workspace:*` for internal packages). Keep root `package.json` strictly for shared `devDependencies` and scripts.
- Never edit `package.json` manually to add dependencies; run `bun add <package> --filter <workspace>` from the root without an explicit version.
- Use absolute workspace imports across packages (e.g., `@shumai/db`, `@shumai/core/src/...`). When adding a new package, add its path mappings to the root `tsconfig.json`.
## Dependency Management
## Operations & Asset Readers
We follow Bun's monorepo conventions for dependency management:
### Operations
1. **Self-Contained Packages**: Every workspace package MUST declare its own runtime `dependencies` in its local `package.json`. Do not rely on dependencies being available via the root.
2. **Shared DevDependencies**: Common development tools (e.g., `typescript`, `eslint`, `vitest`, `prettier`, `prisma`) MUST be declared in the root `package.json` to ensure version consistency across the workspace.
3. **Local DevDependencies**: Tools specific to a single package (e.g., `@vitejs/plugin-react` for `webui`) should be declared in that package's local `package.json`.
4. **Workspace Imports**: Use `workspace:*` for internal package dependencies.
5. **Clean Root**: The root `package.json` must not contain runtime `dependencies`. It is reserved for shared `devDependencies` and workspace-wide `scripts`.
6. **Adding Packages**: Never edit `package.json` manually to add new dependencies. Always use `bun add` (e.g., `bun add <package> --filter <workspace>`) from the root without specifying an explicit version, letting Bun resolve the correct version.
An **Operation** is defined once and exposed across built-in agent tools, the MCP server, and `shumai-cli`. Check existing definitions in `packages/operations/src/` and implementations in `packages/core/src/operations/`.
## TypeScript Configuration
- **Definition (`packages/operations/src/**`)**: Keep free of server dependencies (no `@shumai/core` or `@shumai/db`). Every Zod input/output field must have `.describe()`. Object input fields must be listed in `cli.flatten` or `cli.omit`.
- **Implementation (`packages/core/src/operations/**`)**: Use `implementOperation(definition, { authz, prepare?, execute, audit? })`.
- `authz` returns all required permissions (checked before any side effect).
- `execute` calls Core services only (**importing `prisma` in Operations is forbidden by lint**).
- `audit` resolves team/project from the affected asset, never trusting caller input.
- Outputs must be DTOs matching the output schema.
- **Register & Run**: Register in both `packages/operations/src/registry.ts` and `packages/core/src/operations/registry.ts`. Execute only via `runOperation(op, { userId, via, agentId? }, input)`.
- **Surface Extensions**: For surface-specific parameters or rendering, check `packages/agent/src/operation-extensions/`, `packages/api/src/mcp-extensions/`, and `apps/cli/src/operations/extensions/`.
We use a root-level `tsconfig.json` to manage path mappings for the entire workspace. This ensures that imports across packages resolve correctly during typechecking and in the IDE.
### Asset Readers
1. **Path Mappings**: All workspace packages MUST have an entry in the `paths` object in the root `tsconfig.json`.
```json
"paths": {
"@shumai/core": ["packages/core/src/index.ts"],
"@shumai/core/src/*": ["packages/core/src/*"]
}
```
2. **Package tsconfig**: Each package should have its own `tsconfig.json` that extends the root configuration and defines its specific `include`/`exclude` rules.
3. **Cross-Package Resolution**: When adding a new package, you MUST update the root `tsconfig.json` path mappings to ensure it can be imported by other packages.
`read_asset` is backed by readers in `packages/core/src/asset-read/readers/` registered in `packages/core/src/asset-read/registry.ts` (order matters: first matching reader wins). To add or modify a reader, check existing readers in `packages/core/src/asset-read/readers/` and option schemas in `packages/operations/src/asset/read-asset.ts`. Use `badRequest(...)` for invalid input and return storage keys in `ReadResult`.
### Service Layer Patterns
## Frontend Rules (`packages/webui`)
- **Instance Methods**: Define service logic as instance methods on a class, not static methods.
- **Singleton Export**: Export a singleton instance of the service class.
```typescript
export class MyService {
async doSomething() { ... }
}
export const myService = new MyService()
```
- **Usage**: Import and use the exported instance.
```typescript
import { myService } from '@shumai/core/src/services/myService'
await myService.doSomething()
```
- **System Colors**: Prefer semantic design tokens (`bg-background`, `text-foreground`, `text-muted-foreground`, etc.) over hardcoded Tailwind colors for light/dark theme support.
- **Route Code-Splitting**: Split all routes into `[route].tsx` (route definition and loaders) and `[route].lazy.tsx` (UI component and heavy imports).
- **Radix / Shadcn UI**: Set `modal={false}` on `<DropdownMenu>` when triggering a `Dialog` or `AlertDialog` from inside it to prevent focus-trap UI freezes. Use `ScrollArea` (`@/ui/components/ui/scroll-area`) for scrollable containers.
- **Pagination & Infinite Scroll**: Use `useInfiniteQuery` + `react-intersection-observer` with default `limit: 20` and the API's `total` field. Backend list APIs use `paginateQuery` from `packages/core/src/pagination.ts` (default `limit: 20`).
- **Internationalization (i18n)**: Hardcoded UI text is strictly forbidden. Add `snake_case` keys to both `packages/webui/messages/en.json` and `packages/webui/messages/zh.json`, run `bun run i18n:compile` (or `bun run i18n:watch`), and import `m` from `@/ui/paraglide/messages.js`.
### Hono API Definitions
## Database & Prisma (`packages/db`)
- **Route Chaining**: Always define API routes using method chaining on a Hono instance. This ensures that the type definitions for inputs and outputs are correctly inferred and preserved in the exported type.
- **Export Pattern**: Export the chained route instance as the default export.
```typescript
const app = new Hono()
const route = app
.get('/', ...)
.post('/', ...)
export default route
```
- **Type Safety**: Use `zValidator` for request validation (query, json, form) to ensure full end-to-end type safety with the Hono RPC client.
- **Schema & Config**: Schema at `packages/db/prisma/schema.prisma`, config at `prisma.config.ts`, generated client at `packages/db/src/generated/prisma`.
- **ULIDs & Sorting**: All models (except key-value stores like `Setting`) must use `@default(ulid())`. Do not manually generate DB IDs in application code. Order all list queries by `orderBy: { id: 'desc' }` (do not sort by unindexed `createdAt`).
- **Strict JSON Typing**: Annotate `Json` columns with `/// [TypeName]` in `schema.prisma` and define the type under the global `PrismaJson` namespace in `packages/db/src/prisma-json-types.ts`. Use type guards/narrowing instead of `as any`.
- **Migrations**:
- Commands: `bun --bun run prisma migrate dev`, `bun --bun run prisma migrate deploy`, `bun --bun run prisma generate`.
- Never hand-write DDL migration files; always generate them via `prisma migrate dev` (use `--create-only` for custom data migration SQL).
- **Never run `prisma migrate reset --force`** automatically. If migrations are out of sync or require a reset, stop and ask the user.
## Frontend Architecture
## DBOS Workflows & Activities
The frontend is built with:
Check existing workflows and activities in `packages/agent/src/{workflows,activities}`, `packages/transcode/src/{workflows,activities}`, and `packages/workflow-core/src/`.
- **Runtime**: Bun (Bundler & Runner)
- **Framework**: React
- **Styling**: Tailwind CSS + Shadcn UI (Components)
### UI Rules
- **Prefer System Colors**: Always prefer using semantic system color design tokens (e.g., `bg-background`, `text-foreground`, `text-sidebar-primary`, `text-muted-foreground`, etc.) over hardcoded color utilities (e.g., `bg-blue-50`, `text-emerald-600`, `bg-emerald-500`). This ensures seamless compatibility with light and dark themes.
### Route Code-Splitting
To optimize initial bundle size, all routes must be code-split into `[route].tsx` (lightweight route definition and loaders) and `[route].lazy.tsx` (UI component and heavy imports).
### Development
- **Run Dev**: `bun run dev` (Runs on port 3000)
## Testing
We use **Vitest** for testing (via `bun run test`). **Do not use `bun test`** as it uses Bun's native test runner which is not compatible with this project's test suite.
### Bug Fixes
- **Mandatory Reproduction**: When fixing a backend bug, you MUST first write a test case that reproduces the bug (demonstrates the failure) before applying the fix. This ensures the bug is truly understood and prevents future regressions.
### Test Maintenance Rule
- **Do not delete tests** unless the feature or code being tested is permanently removed from the codebase.
- When refactoring code, you must also refactor the corresponding tests to ensure they pass with the new implementation.
- This ensures we maintain regression coverage and do not silently break features.
### Service Tests
- Located in `packages/core/src/**/*.test.ts`.
- For comprehensive testing against a real database instance, we use `Testcontainers` alongside a `PrismaTestingHelper` which wraps each test within an automatic PostgreSQL transaction rollback boundary.
- All service tests must use `setupTestDbHooks()` from `@shumai/db` to initialize the database boundaries for each test suite inside the `describe` block. This automatically registers `beforeEach` and `afterEach` hooks to manage transaction state.
- Import `prisma` from `@shumai/db` directly to interact with the database in tests. The testing helper automatically proxies it.
```typescript
import { describe, it, expect } from 'vitest'
import { prisma, setupTestDbHooks } from '@shumai/db'
import { teamService } from '@shumai/core/src/team/team'
describe('TeamService', () => {
setupTestDbHooks()
it('works with db', async () => {
const user = await prisma.user.create({
data: { name: 'Test User', password: 'pw' },
})
const team = await teamService.ensureDefaultTeam()
expect(team).toBeDefined()
expect(team.name).toBe('Default Team')
})
})
```
The `bunfig.toml` is configured to run `setup-tests.ts` automatically as a preload step. This initializes the `Testcontainers` PostgreSQL instance and applies migrations before the tests begin running.
### API Tests
- Located in `packages/api/src/**/*.test.ts`.
- Mock the Service layer using `vi.spyOn(service, 'method')` or `vi.mock('@shumai/core/src/team/team')`.
- Verify that the API calls the Service methods correctly.
```typescript
import { describe, it, expect, vi } from 'vitest'
import { teamService } from '@shumai/core/src/team/team'
import app from './team'
describe('Team API', () => {
it('calls service', async () => {
const mockEnsureDefaultTeam = vi
.spyOn(teamService, 'ensureDefaultTeam')
.mockResolvedValue({ id: '1', name: 'Default Team' } as any)
// ... test logic ...
expect(mockEnsureDefaultTeam).toHaveBeenCalled()
mockEnsureDefaultTeam.mockRestore()
})
})
```
### Workflow E2E Tests
- Located in `packages/e2e/workflow/**/*.test.ts`.
- Run via `bun run test:e2e:workflow` (which executes tests against both `local` and `temporal` executors dynamically).
- **Mandatory test coverage**: When creating or updating workflows or activities, you MUST create or update the corresponding E2E tests.
- **Mocking**: Mock ONLY AI API calls. Do not mock S3, databases, or media/transcode extraction services.
- Mock the AI response by spying on `AgentHarness.prototype.prompt`:
### Web App E2E Tests
- Located in `apps/web/e2e/**/*.spec.ts`, organized by domain under `tests/<domain>/` (e.g. `auth`, `project`).
- Run via `bun run test:e2e:app`.
- **Fixtures**: Use the `owner`, `project`, and `file` fixtures for setup — they seed data through API calls/DB (no slow UI setup). You can add more fixtures if necessary.
- **Documentation**: Every test case MUST be documented in [`apps/web/e2e/README.md`](apps/web/e2e/README.md). Add or update the corresponding entry in the README whenever you add, rename, or remove a spec.
## Prisma Configuration & Migrations
- Schema: `packages/db/prisma/schema.prisma`
- Generated Client: `packages/db/src/generated/prisma`
- Config: `prisma.config.ts` (Required for Prisma 7+)
### Strict JSON Typing
We use `prisma-json-types-generator` to enforce strict type-safety for Prisma `Json` columns, rather than typing them as generic `JsonValue`.
- **Defining Types**: In `packages/db/prisma/schema.prisma`, annotate the JSON column with a triple-slash comment specifying the type name from `packages/db/src/prisma-json-types.ts`:
```prisma
model WorkflowTask {
/// [WorkflowTaskPayload]
payload Json?
}
```
- **Declaring Types**: All typed JSON shapes must be defined in `packages/db/src/prisma-json-types.ts` under the global `PrismaJson` namespace:
```typescript
declare global {
namespace PrismaJson {
export type WorkflowTaskPayload = Record<string, unknown> | TaskSpec | AiTaskPayload
}
}
```
- **Usage**: When accessing these columns on the Prisma client (e.g. `task.payload`), the field will automatically be typed as the declared shape (e.g., `PrismaJson.WorkflowTaskPayload | null`).
- **Accessing Properties**: When working with union types or custom structures in the JSON payload, use proper narrowing or type guards instead of casting to `any`. Direct `as any` casting should be avoided.
### Migration Workflow
- Development: Use `bun --bun run prisma migrate dev` to create and apply migrations during development.
- Production: Use `bun --bun run prisma migrate deploy` to apply pending migrations in production environments.
- **No Manual DDL Creation**: Never hand-write **schema (DDL) migration** files or directories. Always generate them with Prisma CLI (`bun --bun run prisma migrate dev --create-only` to create a template, then edit it if needed, or `bun --bun run prisma migrate dev` to apply) so Prisma correctly tracks migration metadata and checksums.
- **Data Migrations Are Allowed**: Pure **data migration** SQL (no schema change) may be written by hand, but it MUST live inside a migration generated via `bun --bun run prisma migrate dev --create-only` so it is tracked and applied automatically.
- **No Automatic Dev DB Reset**: Do not run `prisma migrate reset --force` or commands that force-reset the database automatically. If migrations become out of sync or a reset is required, stop executing, report the situation to the user, and present suggested manual cleanup/reset steps for the user to execute.
### Commands
- Generate Client: `bun --bun run prisma generate`
- Apply Migrations (Dev): `bun --bun run prisma migrate dev`
- Deploy Migrations (Prod): `bun --bun run prisma migrate deploy`
## ID Generation & Sorting
- **ULID Default**: All models (except key-value stores like `Setting`) must use `@default(ulid())` for the `id` field in `schema.prisma`.
```prisma
model Example {
id String @id @default(ulid())
}
```
- **No Manual Assignment**: Do not manually generate or assign ULIDs in application code (e.g., `packages/core/src/*.ts`) for creating database records. Let Prisma handle it via the schema default.
- Exception: File names generated by `FileService` may still use `ulid()` internally, but this is separate from the database ID.
- **Sorting**: All list APIs must order results by `id` descending (`orderBy: { id: 'desc' }`) to ensure consistent, time-based sorting (since ULIDs are sortable). Do not sort by `createdAt` as it is not indexed.
## Infinite Scroll & Pagination
- **Frontend**: For paginated APIs (which contain `pageInfo` and `total` fields), the UI MUST use an auto infinite scroll style design using `useInfiniteQuery` from `@tanstack/react-query` and `react-intersection-observer`. Use the `total` count from the API response instead of counting the results locally.
- The default `limit` should be **20**.
- **Backend**:
- Most list APIs support cursor pagination using opaque tokens (via `hyrumtoken` logic) using the `paginateQuery` helper function.
- Pass `PaginationParams` containing `first` (limit) and `after` (cursor).
- The default `limit` should be **20**.
- Always use the `paginateQuery` helper function from `packages/core/src/pagination.ts` for consistent cursor pagination.
## Temporal Workflow & Activities
We use a custom workflow engine that supports both **Local** (polling-based) and **Temporal** (production-grade) execution.
### Architecture
1. **Workflows**: Orchestrate multiple activities. They must be deterministic and compatible with Temporal's V8 isolate. Defined in worker packages (e.g., `@shumai/agent/src/workflows`, `@shumai/transcode/src/workflows`).
2. **Activities**: Perform the actual work (DB updates, API calls, media processing). Grouped by domain in worker packages (e.g., `@shumai/agent/src/activities`, `@shumai/transcode/src/activities`).
3. **Executors**:
- `LocalExecutor` (in `@shumai/workflow-core`): Polls the database for `pending` tasks and executes them directly.
- `TemporalExecutor` (in `@shumai/workflow-core`): Submits tasks to a Temporal cluster.
4. **Automatic Submission**: New `WorkflowTask` records are automatically submitted to the `WorkflowService` via a Prisma Client Extension defined in `@shumai/db`.
### Dynamic Registration
To avoid circular dependencies, workflows and activities are dynamically registered onto the `LocalExecutor` registry at bootstrap time via initializer functions (e.g., `initAgentWorkflows()`, `initTranscodeWorkflows()`).
### Non-Retryable Error Handling
To prevent Temporal from indefinitely retrying fatal, expected business validation failures (e.g., missing records, invalid configurations, missing parameters), **never throw standard `Error` objects from workflow or activity logic.** Instead, throw a non-retryable `ApplicationFailure`.
**Mandatory Requirement**: You **MUST** set `nonRetryable: true` in the options object passed to `ApplicationFailure.create`. Standard errors or `ApplicationFailure` objects without `nonRetryable: true` will cause Temporal to retry the activity or workflow indefinitely.
- **Workflow Boundary**: In workflows, import `ApplicationFailure` from `@temporalio/workflow`:
```typescript
import { ApplicationFailure } from '@temporalio/workflow'
throw ApplicationFailure.create({ message: 'agentId missing in payload', nonRetryable: true })
```
- **Activity Boundary**: In activities, import `ApplicationFailure` from `@temporalio/activity`:
```typescript
import { ApplicationFailure } from '@temporalio/activity'
throw ApplicationFailure.create({
message: 'no autofill agent found for team',
nonRetryable: true,
})
```
### Temporal Workflow Patterns
- **Definition**: Define workflows as exported async functions.
```typescript
export async function myWorkflow(task: WorkflowTask): Promise<void> {
const { activityA, activityB } = getActivities()
await activityA({ ... })
await activityB({ ... })
}
```
- **Environment Compatibility**: Always use `getActivities()` from `@shumai/workflow-core` to ensure the code works in both Local and Temporal environments.
- **Activity Access**: Activities should be accessed via `getActivities()` within a workflow. Do not call services directly inside a workflow function to maintain Temporal compatibility.
- **Queue Redirection**: Production Temporal workers use worker-specific unique queues for data locality (e.g., local disk access) and consistent state.
- Every workflow MUST first call `getAgentWorkerQueueActivity` or `getTranscodeWorkerQueueActivity` via the shared domain queue (e.g., `TaskQueueAgent` or `TaskQueueTranscode`) to obtain the specific queue name for that worker instance.
- ALL subsequent activities (including shared DB activities like updating task status) MUST be executed on that specific discovered queue.
- The shared domain worker ONLY registers the queue discovery activities. All other activities (shared and domain-specific) are registered on the specific worker.
### Activity Patterns
- **Implementation**: Activities _can_ and _should_ call other services (e.g., `aiService`, `transcodeService`) or interact with the database directly. Database (Prisma) queries or updates are allowed in all activity types (e.g., agent or transcode) for simplicity.
## Import conventions
- When importing across workspace packages, always use absolute workspace imports (e.g. `import { prisma } from '@shumai/db'`, `import { teamService } from '@shumai/core/src/team/team'`).
- **DTO Naming**: Do not append the `Dto` suffix to types or interfaces (e.g. use `JoinRequest` instead of `JoinRequestDto`).
## Radix UI / Shadcn UI Patterns
- **Modal Overlays**: When triggering a dialog (e.g., `Dialog`, `AlertDialog`) from inside a `DropdownMenu`, you must set `modal={false}` on the `<DropdownMenu>` component. Failing to do so will cause the UI to freeze due to conflicting focus management between the two modal components.
- **Scrollable Content**: Always use the Shadcn `ScrollArea` component (`@/ui/components/ui/scroll-area`) for scrollable content containers to ensure consistent custom scrollbar UI across the application.
- **Patterns**: Workflows are exported async functions registered at bootstrap (`initAgentWorkflows`, `initTranscodeWorkflows`) and auto-enqueued when `WorkflowTask` records are created. Wrap activity functions with `defineStep` from `@shumai/workflow-core` (activities may call services or query `prisma` directly).
- **Non-Retryable Errors**: Never throw standard `Error` objects for fatal validation or business failures in workflows/activities. Always throw `ApplicationFailure.create({ message: '...', nonRetryable: true })` from `@shumai/workflow-core`.
- **Durable Step File Exchange**: Save intermediate files passed across steps to S3, fetch them in consuming steps via `ensureLocalMediaFile` (never assume local `/tmp` persists across steps), and clean up temporary S3 files in a `finally` block.
## Logging
We use **pino** for logging. Always use **structured logging** to ensure logs are easily searchable and machine-readable.
Use structured **pino** logging via `import { logger } from '@shumai/core/src/logger'`. Pass metadata object first and message string second: `logger.info({ userId, projectId }, 'Project deleted')`.
- **Import**: `import { logger } from '@shumai/core/src/logger'`
- **Usage**: Pass an object as the first argument containing the metadata, and a string as the second argument for the descriptive message.
```typescript
logger.info({ userId: user.id, projectId }, 'Project deleted successfully')
```
- **Levels**: Use appropriate levels: `debug`, `info`, `warn`, `error`.
## Testing
## Internationalization (i18n)
Use **Vitest** via `bun run test` (**never** use `bun test`).
All user-facing text in the WebUI (`packages/webui`) MUST be internationalized using **Paraglide JS**. Hardcoded text in UI components is strictly forbidden.
### Message Definition
1. Define your English message strings in [packages/webui/messages/en.json](packages/webui/messages/en.json).
2. Define the corresponding Chinese translation strings in [packages/webui/messages/zh.json](packages/webui/messages/zh.json).
3. Keys should use `snake_case`.
Example (`en.json`):
```json
{
"my_key": "My English Text"
}
```
### Compilation
When you add or update translation keys, you must compile them to regenerate the type-safe functions:
```bash
# Compile once (generates type-safe TS/JS functions on disk)
bun run i18n:compile
# Watch and recompile on change during development
bun run i18n:watch
```
### Usage in Components
Import the compiled message namespace `m` and call it as a function:
```typescript
import { m } from '@/ui/paraglide/messages.js'
export function MyComponent() {
return (
<div>
<h1>{m.my_key()}</h1>
</div>
)
}
```
Always use the absolute workspace alias path `@/ui/paraglide/messages.js` (or `runtime.js` for runtime features) when importing Paraglide outputs.
- **Bug Fixes**: Always write a test case that reproduces the bug (demonstrates failure) before applying a backend fix.
- **Test Maintenance**: Never delete tests unless the tested feature is permanently removed; update existing tests when refactoring.
- **Service & Operation Tests (`packages/core/src/**/*.test.ts`)**: Call `setupTestDbHooks()` from `@shumai/db` inside `describe` for per-test PostgreSQL transaction rollback, and use `prisma` from `@shumai/db`. Every Operation requires real-DB tests covering success, permission denial (no side effects), and audit entries.
- **API Tests (`packages/api/src/**/*.test.ts`)**: Mock Core services using `vi.spyOn` or `vi.mock`.
- **Workflow E2E Tests (`packages/e2e/workflow/**/*.test.ts`)**: Run via `bun run test:e2e:workflow`. Mandatory when adding/updating workflows or activities. Mock **only** AI API calls (spy on `AgentHarness.prototype.prompt`); do not mock S3, DB, or media/transcode services.
- **Web App E2E Tests (`apps/web/e2e/**/*.spec.ts`)**: Run via `bun run test:e2e:app`. Use `owner`, `project`, and `file` fixtures for setup, and document every added, renamed, or removed spec in `apps/web/e2e/README.md`.
+60
View File
@@ -12,6 +12,66 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
### Changed
## [0.6.2] - 2026-10-29
### Added
* **mcp**: Add a built-in MCP server supporting OAuth 2.1 and API tokens, allowing external AI agents (such as Claude Code, Cursor, or Kiro) to browse projects, manage and upload files, inspect media contents (images, video frames, PDF pages, 3D models, and text), search assets, manage review comments, update metadata, and organize version stacks
* **cli**: Add `shumai-cli` commands to download files (`download`), view and render media contents (`read`, `render`), search and copy files (`search`, `copy`), manage review comments (`comment`), view and update metadata (`field ls`, `meta set`), organize version stacks (`version`), and view folder instructions (`instructions`)
* **agent**: The built-in agent can now list accessible projects, search files by name, meaning, or metadata, read and post review comments, update metadata, copy files, stack and unstack versions, and read folder instructions (`AGENTS.md`), with configurable permissions per agent
### Fixed
### Changed
## [0.6.1] - 2026-10-24
### Added
* **dashboard**: Add Workflow Tasks section to the Team Dashboard allowing team owners to monitor background workflow jobs, inspect execution payloads and outputs, and stop in-flight tasks
### Fixed
* **metadata**: Fix an issue where clicking to edit a metadata field on a card or list row inadvertently selected the file, and prevent expanded text overlays or date pickers from being clipped by container borders
### Changed
* **deps**: Upgrade Bun to 1.4.4
## [0.6.0] - 2026-10-20
### Added
* **deploy**: Add dedicated `shumaione/shumai-transcode` Docker image and a complete AWS EKS deployment example (`eks/`) featuring KEDA queue-driven autoscaling, idle-timeout auto-drain worker mode, and Scale-to-Zero On-Demand Graviton5 instances for media processing
* **storage**: Support configuring a separate public endpoint (`AWS_PUBLIC_ENDPOINT_URL_S3`) for browser-facing presigned URLs while preserving internal cluster endpoints for backend workers
### Fixed
* **transcode**: Fix an issue where PDF, 3D model, and image background transcode workflows could fail with missing temporary file errors if a worker restarted or recovered midway through processing
* **webui**: Improve file list and detail loading with matching skeleton layouts, a persistent sidebar carousel to eliminate layout shift, and smoothed video poster previews
### Changed
* **workflow**: Migrate the background workflow engine to DBOS, unifying all-in-one and dedicated worker deployments using the existing PostgreSQL database without requiring a separate Temporal cluster
## [0.5.3] - 2026-10-16
### Added
* **cli**: Add administrative `shumai regenerate-embeddings` command to regenerate multimodal vector embeddings for all existing media files across active teams
* **docker**: Provide three Docker Compose deployment tiers (Lite, with Embedding Server, and Full) with recommended memory specifications
* **agent**: Save video chunk embeddings incrementally to the database as each chunk finishes, preserving completed progress on failure and resuming from where it left off on retry
* **agent**: Add support for local LiteRT-LM Gemma Embedding 2 (`gemma-embedding-2-openai`) provider and environment-enforced read-only embedding agents with automatic 768-dimensional vector search indexing
### Fixed
### Changed
* **search**: Display search results in a responsive card grid with interactive hover video sprite scrubbing, semantic match chunk time range previews, and new-tab opening on click
* **search**: Significantly improve semantic search response times by generating query text embeddings directly with in-memory caching instead of dispatching background tasks
## [0.5.2] - 2026-10-13
### Added
+6 -4
View File
@@ -1,6 +1,6 @@
#syntax=docker/dockerfile:1.7-labs
# Stage 1: Builder
FROM oven/bun:1.4.2 AS builder
FROM oven/bun:1.4.4 AS builder
WORKDIR /app
@@ -28,7 +28,7 @@ RUN bun run build.ts
RUN bun run scripts/extract-runtime-deps.ts
# Stage 2: Runner
FROM oven/bun:1.4.2 AS runner
FROM oven/bun:1.4.4 AS runner
# Install system dependencies and Jellyfin-FFmpeg (with VA-API support)
RUN apt-get update && apt-get install -y --no-install-recommends \
@@ -94,9 +94,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")
# Expose "bun index.js" as "shumai" CLI command (and worker commands "shumai-transcode", "shumai-agent")
RUN printf '#!/bin/sh\nexec bun /app/index.js "$@"\n' > /usr/local/bin/shumai \
&& chmod +x /usr/local/bin/shumai \
&& printf '#!/bin/sh\nexec bun /app/transcode-worker.js "$@"\n' > /usr/local/bin/shumai-transcode \
&& printf '#!/bin/sh\nexec bun /app/agent-worker.js "$@"\n' > /usr/local/bin/shumai-agent \
&& chmod +x /usr/local/bin/shumai /usr/local/bin/shumai-transcode /usr/local/bin/shumai-agent \
&& ln -s /usr/local/bin/shumai /usr/local/bin/shuami
ENTRYPOINT ["docker-entrypoint.sh"]
+80
View File
@@ -0,0 +1,80 @@
#syntax=docker/dockerfile:1.7-labs
# Stage 1: Builder
FROM oven/bun:1.4.4 AS builder
WORKDIR /app
# Copy package files
COPY package.json bun.lock ./
COPY --parents packages/*/package.json ./
COPY --parents apps/*/package.json ./
COPY patches/ ./patches/
# Install dependencies (including devDependencies for build tools)
RUN bun install --frozen-lockfile
# Copy source code
COPY . .
# Build transcode worker bundle
RUN bun run build.ts transcode
# Generate runner-package.json for the runner stage
RUN bun run scripts/extract-runtime-deps.ts
# Stage 2: Runner
FROM oven/bun:1.4.4 AS runner
# Install transcoding system dependencies and Jellyfin-FFmpeg (with VA-API/hardware acceleration support)
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
gosu \
poppler-utils \
imagemagick \
fonts-noto-cjk \
libraw-bin \
libimage-exiftool-perl \
&& . /etc/os-release \
&& TARGETARCH=$(dpkg --print-architecture) \
&& FFMPEG_VERSION="8.1.2-5" \
&& curl -fsSL -o /tmp/jellyfin-ffmpeg.deb "https://github.com/jellyfin/jellyfin-ffmpeg/releases/download/v${FFMPEG_VERSION}/jellyfin-ffmpeg8_${FFMPEG_VERSION}-${VERSION_CODENAME}_${TARGETARCH}.deb" \
&& apt-get install -y --no-install-recommends /tmp/jellyfin-ffmpeg.deb \
&& rm -f /tmp/jellyfin-ffmpeg.deb \
&& ldconfig /usr/lib/jellyfin-ffmpeg/lib \
&& ln -sf /usr/lib/jellyfin-ffmpeg/ffmpeg /usr/local/bin/ffmpeg \
&& ln -sf /usr/lib/jellyfin-ffmpeg/ffprobe /usr/local/bin/ffprobe \
&& ln -sf /usr/lib/jellyfin-ffmpeg/ffmpeg /usr/bin/ffmpeg \
&& ln -sf /usr/lib/jellyfin-ffmpeg/ffprobe /usr/bin/ffprobe \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Set up working directory and make it owned by the bun user, ensure video/render group access
RUN usermod -a -G video,render bun 2>/dev/null || true \
&& mkdir -p /app/data \
&& chown -R bun:bun /app
# Switch to the non-root bun user
USER bun
WORKDIR /app
# Install runtime dependencies with exact matching versions extracted from the builder stage
COPY --chown=bun:bun --from=builder /app/runner-package.json ./package.json
RUN bun install
# Copy build artifacts
COPY --chown=bun:bun --from=builder /app/dist ./
# Switch back to root at the end so the container runs the entrypoint as root
USER root
COPY scripts/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Expose "bun transcode-worker.js" as "shumai-transcode" CLI command
RUN printf '#!/bin/sh\nexec bun /app/transcode-worker.js "$@"\n' > /usr/local/bin/shumai-transcode \
&& chmod +x /usr/local/bin/shumai-transcode
ENTRYPOINT ["docker-entrypoint.sh"]
# Default command: start transcode worker
CMD ["shumai-transcode"]
+95 -200
View File
@@ -12,7 +12,7 @@
<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>
<a target="_blank" href="https://deepwiki.com/shumaiOne/shumai"><img alt="Ask DeepWiki" src="https://deepwiki.com/badge.svg" /></a>
<a target="_blank" href="https://deepwiki.com/shumaiOne/shumai"><img alt="Ask DeepWiki" src="https://img.shields.io/badge/Ask-DeepWiki-6E56CF" /></a>
</p>
<p align="center">
@@ -29,13 +29,16 @@ Shumai is an open-source Frame.io alternative built for creative teams to collab
* **Frame-by-Frame Annotations & Comments**: Leave precise feedback with frame-specific drawing tools and timestamped comments on both video and image assets.
* **Secure Sharing & Collections**: Create private share links and curated media collections for clients, stakeholders, and collaborators.
* **Granular Access Control**: Manage workspace permissions with team-level and project-level role-based access control.
* **Distributed Transcoding via Temporal**: Offload resource-intensive video transcoding to a background worker pool orchestrated by Temporal.
* **Durable Workflows via DBOS**: Run background tasks and AI agent workflows orchestrated reliably by DBOS on PostgreSQL with automatic recovery and fault tolerance.
* **Scalable Deployment on Docker or Kubernetes**: Horizontally autoscale video transcoding on multiple instances. See [EKS Deployment Example](eks/README.md).
* **Custom Asset Metadata**: Define dynamic metadata fields tailored to your production pipeline.
* **Share Link Watermarking**: Protect shared media with customizable text and image watermarks, and save watermark as reusable templates.
* **Wide File Format Support**: Preview common creative file formats, including images (with PSD support), videos, audio, and documents, while allowing any file type to be uploaded and stored.
* **3D Asset Turntable Previews**: Generate interactive 3D model turntable previews and videos for formats like GLB, FBX, OBJ, STL, USD, and DAE using [turntable-renderer](https://docs.shumai.one/using-shumai/3d-asset-support).
* **Office & Document PDF Proxying via Gotenberg**: Convert Word, PowerPoint, Excel, Markdown, HTML, and CSV documents to high-quality PDF proxies for in-browser previewing using [Gotenberg](https://docs.shumai.one/using-shumai/gotenberg).
* **Semantic Search**: Find assets by visual or conceptual meaning using vector embeddings. See [documentation](https://docs.shumai.one/using-shumai/semantic-search).
* **NLE Export & Premiere Pro Plugin (Experimental)**: Export timestamped review comments to your favorite non-linear editor (Premiere Pro XML, DaVinci Resolve EDL, Final Cut Pro, Avid Media Composer) or use the experimental Premiere Pro UXP plugin to import media assets and auto-sync comments directly to sequence timeline markers. See [documentation](https://docs.shumai.one/using-shumai/nle-and-premiere).
* **Built-in MCP Server & CLI**: Connect external AI agents to Shumai via `/mcp` or manage projects, assets, comments, and metadata from the terminal with `shumai-cli`.
But Shumai goes beyond being a Frame.io alternative. With modern models like GPT-Image-2 and Seedance 2.5, AI can already handle a surprising amount of creative work. That means you can create or update videos and images from a simple prompt without having to jump back into Photoshop, Premiere or Houdini. That is why Shumai includes a powerful agent system:
@@ -47,7 +50,6 @@ But Shumai goes beyond being a Frame.io alternative. With modern models like GPT
* **Model Context Protocol (MCP)**: Connect agents to external tools and APIs through remote MCP servers, with OAuth authentication and per-agent MCP access.
* **Isolated Sandbox Execution**: Run agent-submitted scripts safely in a sandboxed environment.
* **AI Metadata Autofill**: Automatically fill in custom metadata for new assets.
* **Semantic Search**: Find assets by visual or conceptual meaning using vector embeddings (Gemini Embedding 2).
* **Resource Quotas**: Set usage limits on AI tokens, costs, and tool execution per member, role, or team-wide, with real-time tracking.
Here is a short demo video showing what the Shumai agent can do:
@@ -69,11 +71,13 @@ The ultimate goal is an **agentic Kanban**, where agents and team members can wo
> * **For Images:** Shumai generates a high-quality WebP proxy at the exact same resolution as your original file for optimized viewing.
> * **For Videos:** It generates at least one proxy video (depending on your transcoding settings), alongside a sprite image and a small preview video (capped at 1600 frames) to enable fast timeline scrubbing and lightning-quick previews.
---
Have feedback or ideas? [Share them with us](https://github.com/shumaiOne/shumai/issues/328), and if you find Shumai useful, please give us a ⭐ or recommend Shumai to someone who might find it useful, it really helps!
## Installation
Below is a quickstart guide for running Shumai with local storage. For advanced configuration options (including S3-compatible storage and Temporal workflow orchestration), see our [Documentation](https://docs.shumai.one/getting-started/overview).
Below is a quickstart guide for running Shumai with local storage. For advanced configuration options (including S3-compatible storage and distributed worker orchestration), see our [Documentation](https://docs.shumai.one/getting-started/overview).
### Option 1: Docker Compose
@@ -83,17 +87,39 @@ Docker Compose is the fastest way to get Shumai running. You do not need to clon
```bash
mkdir shumai && cd shumai
```
2. Download the `docker-compose.yaml` file:
```bash
curl -o docker-compose.yaml https://raw.githubusercontent.com/shumaiOne/shumai/main/docker-compose/local/docker-compose.yaml
```
2. Download your preferred `docker-compose.yaml` configuration based on your needs and available RAM:
* **Lite (Suggested RAM: 2 GB+)**: Minimal deployment containing Shumai and PostgreSQL database.
```bash
curl -o docker-compose.yaml https://raw.githubusercontent.com/shumaiOne/shumai/main/docker-compose/local/docker-compose.yaml
```
* **With Embedding Server (Suggested RAM: 4 GB+)**: Adds local multimodal semantic search powered by `shumaiOne/embedding-server` (`EmbeddingGemma 2 740M`).
```bash
curl -o docker-compose.yaml https://raw.githubusercontent.com/shumaiOne/shumai/main/docker-compose/local/docker-compose.embedding.yaml
```
* **Full (Suggested RAM: 8 GB+)**: All-in-one setup including `embedding-server`, `turntable-renderer` (3D previews), and `Gotenberg` (document PDF proxying).
```bash
curl -o docker-compose.yaml https://raw.githubusercontent.com/shumaiOne/shumai/main/docker-compose/local/docker-compose.full.yaml
```
> [!NOTE]
> By default, the standard `docker-compose.yaml` uses CPU software transcoding. If your server has a GPU (NVIDIA NVENC, Intel QuickSync, AMD/Intel VA-API, or Rockchip RKMPP) and you want to enable GPU hardware acceleration, check the [Hardware Transcoding Guide](https://docs.shumai.one/configuration/hardware-transcoding).
3. Configure environment variables (optional):
> By default, the Docker Compose setups use CPU software transcoding. If your server has a GPU (NVIDIA NVENC, Intel QuickSync, AMD/Intel VA-API, or Rockchip RKMPP) and you want to enable GPU hardware acceleration, check the [Hardware Transcoding Guide](https://docs.shumai.one/configuration/hardware-transcoding).
3. Configure environment variables:
* `SHUMAI_SERVER_PORT` controls the port the Shumai server listens on. The default is `3000`.
* By default, Shumai uses the bundled local storage service in this Docker Compose setup. To use an external S3-compatible storage instead, configure the environment variables for your S3 provider. Here are examples for AWS S3 and Cloudflare R2:
* `BETTER_AUTH_URL`: The public base URL of your Shumai server (e.g., `https://shumai.example.com` or `http://12.34.56.78:3000`). This is required for remote servers and production deployments.
* `AWS_ENDPOINT_URL_S3`: By default, `AWS_ENDPOINT_URL_S3` is set to `http://localhost:{SHUMAI_SERVER_PORT}`. When you use local storage (the default storage backend with `STORAGE_BACKEND: local`) and expose Shumai on a remote server, custom domain, or custom host/port combination, set `AWS_ENDPOINT_URL_S3` to the external URL that client browsers will use to upload and download files.
For example, if you change the port mapping in `docker-compose.yaml` from `3000:3000` to `12345:3000` and deploy on a server with IP address `12.34.56.78`, set:
```yaml
AWS_ENDPOINT_URL_S3: http://12.34.56.78:12345
```
This value must be reachable from client browsers and should include the externally exposed port.
* `SHUMAI_SERVER_PORT`: Controls the port the Shumai server listens on. The default is `3000`.
* **External S3 Storage**: By default, Shumai uses the bundled local storage service in this Docker Compose setup. To use an external S3-compatible storage instead, configure the environment variables for your S3 provider. Here are examples for AWS S3 and Cloudflare R2:
**AWS S3 Example:**
```yaml
@@ -113,206 +139,46 @@ Docker Compose is the fastest way to get Shumai running. You do not need to clon
S3_SECRET_ACCESS_KEY: your-secret-access-key
AWS_ENDPOINT_URL_S3: https://<account-id>.r2.cloudflarestorage.com
```
* By default, `AWS_ENDPOINT_URL_S3` is set to: `http://localhost:{SHUMAI_SERVER_PORT}`, if you use local storage and expose Shumai on a custom host/port combination, set `AWS_ENDPOINT_URL_S3` to the external URL that browsers will use to upload files.
For example, if you change the port mapping in `docker-compose.yaml` from `3000:3000` to `12345:3000` and deploy on a server with IP address `12.34.56.78`, set:
```
AWS_ENDPOINT_URL_S3: http://12.34.56.78:12345
```
This value must be reachable from client browsers and should include the externally exposed port.
5. Start the services in detached mode:
4. Start the services in detached mode:
```bash
docker compose up -d
```
6. Open your browser and access Shumai at `http://localhost:3000` (or `http://<your-server-ip>:3000` for remote deployments).
5. Open your browser and access Shumai at `http://localhost:3000` (or `http://<your-server-ip>:3000` for remote deployments).
### Option 2: Install via NPM / Package Manager
#### **Scaling Transcode Workers (Parallel Processing)**
Shumai is published as `@shumai-one/shumai` on NPM. This option allows you to run Shumai globally or locally.
By default, the Docker Compose deployment transcodes videos one-by-one. This is by design, as video transcoding is compute-intensive and can saturate available CPU or GPU resources.
#### Step 1: Start PostgreSQL with pgvector
However, when uploading large batches (e.g., 100+ videos at once) or massive raw camera files that take hours to process and block subsequent uploads, you can scale transcoding throughput across additional machines. Each machine still processes tasks sequentially, but adding more worker instances increases overall parallel capacity.
Shumai requires PostgreSQL with the `pgvector` extension. Start a pre-configured database container using Docker:
Shumai makes this seamless with a dedicated [`shumaione/shumai-transcode`](https://hub.docker.com/r/shumaione/shumai-transcode) Docker image:
```bash
docker run --name shumai_postgres \
-e POSTGRES_USER=shumai \
-e POSTGRES_PASSWORD=shumai_password \
-e POSTGRES_DB=shumai_db \
-p 5432:5432 \
-d pgvector/pgvector:pg18
```
1. **Connect**: Launch a temporary machine and ensure network access to your PostgreSQL database and storage backend (e.g., S3 or shared storage).
2. **Start the worker**: Run the container with matching database and storage credentials:
#### Step 2: Create a workspace folder
```bash
docker run -d --name shumai_transcode_worker \
-e DATABASE_URL="postgres://shumai:shumai_password@<postgres-host>:5432/shumai_db?sslmode=disable" \
-e STORAGE_BACKEND="s3" \
-e S3_BUCKET="your-bucket-name" \
-e AWS_ENDPOINT_URL_S3="https://s3.us-east-1.amazonaws.com" \
-e S3_ACCESS_KEY_ID="your-access-key-id" \
-e S3_SECRET_ACCESS_KEY="your-secret-access-key" \
shumaione/shumai-transcode:latest
```
Create a dedicated directory to store your environment configuration and media files (which are saved in a `./data` directory by default):
The worker will automatically attach to the task queue and begin processing pending transcode jobs in parallel with your primary instance.
```bash
mkdir shumai && cd shumai
```
3. **Stop anytime**: Once the transcoding backlog finishes (or whenever you no longer need the extra compute), simply stop or remove the worker:
#### Step 3: Install Platform-Specific Dependencies
```bash
docker stop shumai_transcode_worker
```
#### Linux
There is no downtime or impact on the main Shumai application.
Shumai requires the following system packages on Linux:
- **`ffmpeg`** – Used for media transcoding and metadata extraction.
- **`poppler`** (`poppler-utils`) – Used for PDF page image extraction and PDF sprite preview generation (`pdftoppm`).
- **`imagemagick`** – Used for PSD format transcoding and color profile conversion to sRGB.
- **`dcraw_emu`** (`libraw` / `libraw-bin`) – Used for camera RAW format image decoding and preview generation.
- **`bubblewrap`**, **`socat`**, and **`ripgrep`** – Required by the AI agent sandbox (`anthropic-experimental/sandbox-runtime`) for process isolation, networking, and workspace search.
Install all required packages with one command:
> Ubuntu/Debian
```bash
sudo apt install -y ffmpeg poppler-utils imagemagick bubblewrap socat ripgrep libraw-bin
```
> Fedora
```bash
sudo dnf install -y ffmpeg poppler-utils ImageMagick bubblewrap socat ripgrep LibRaw
```
> Arch Linux
```bash
sudo pacman -S --noconfirm ffmpeg poppler imagemagick bubblewrap socat ripgrep libraw
```
> [!NOTE]
> **Ubuntu 24.04+** restricts unprivileged user namespaces by default. This prevents `anthropic-experimental/sandbox-runtime` from using `bubblewrap` for sandbox isolation.
>
> To temporarily allow user namespaces:
>
> ```bash
> sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
> ```
>
> Alternatively, configure an AppArmor profile that grants the required `userns` permission to the relevant binaries.
---
#### macOS
Shumai requires:
- **`ffmpeg`** – Used for media transcoding and metadata extraction.
- **`poppler`** – Used for PDF page image extraction and PDF sprite preview generation (`pdftoppm`).
- **`imagemagick`** – Used for PSD format transcoding and color profile conversion to sRGB.
- **`dcraw_emu`** (`libraw`) – Used for camera RAW format image decoding and preview generation.
- **`ripgrep`** – Required by the AI agent sandbox (`anthropic-experimental/sandbox-runtime`).
Install the required packages with Homebrew:
```bash
brew install ffmpeg poppler imagemagick ripgrep libraw
```
---
#### Windows (alpha)
> [!WARNING]
> Windows support in anthropic-experimental/sandbox-runtime is **alpha and the design is in flux**.
>
> The current implementation provides:
> - Network egress filtering via the **Windows Filtering Platform (WFP)**.
> - File read/write denial via **ACL stamping**.
>
> However, it is **not a security boundary against a deliberately adversarial sandboxed process**.
>
> The sandbox implementation will be substantially revised in a future release, where sandboxed processes will run under a dedicated sandbox user account.
Shumai requires:
- **`ffmpeg`** – Used for media transcoding and metadata extraction.
- **`imagemagick`** – Used for PSD format transcoding and color profile conversion to sRGB.
Install required packages using your preferred package manager:
**winget**
```powershell
winget install Gyan.FFmpeg ImageMagick.ImageMagick
```
**Chocolatey**
```powershell
choco install ffmpeg imagemagick
```
#### Step 4: Install Shumai globally
Install Shumai globally using your preferred package manager:
```bash
# NPM
npm install -g @shumai-one/shumai
# PNPM
pnpm add -g @shumai-one/shumai
# Bun
bun add -g @shumai-one/shumai
```
#### Step 5: Configure Environment Variables
Create a `.env` file in your workspace folder (`shumai/`) and add the following configuration:
```env
DATABASE_URL=postgresql://shumai:shumai_password@localhost:5432/shumai_db?schema=public
BETTER_AUTH_SECRET=ySxs7DxzHDZBbeeHNPEwBuspYwipBqz5Gk5XdBjNhWw=
STORAGE_BACKEND=local
SHUMAI_SERVER_PORT=3000
AWS_ENDPOINT_URL_S3=http://localhost:3000
# Optional: base URL for MCP OAuth redirects (defaults to BETTER_AUTH_URL)
MCP_OAUTH_REDIRECT_BASE_URL=http://localhost:3000
```
> [!NOTE]
> `SHUMAI_SERVER_PORT` sets the port the server starts on, while `AWS_ENDPOINT_URL_S3` is used by the browser to build file upload URLs.
> If deploying on a remote server (e.g. `http://123.456.7.8`) with a mapped port (e.g. `12345:3000` in docker-compose), set `AWS_ENDPOINT_URL_S3` to `http://123.456.7.8:12345`.
> `MCP_OAUTH_REDIRECT_BASE_URL` is only needed when MCP servers use OAuth: the authorization redirect URI defaults to `{BETTER_AUTH_URL}/api/mcp/oauth/callback`; set it to an externally reachable URL if the app is served behind a proxy.
#### Step 6: Run Shumai
> [!IMPORTANT]
> **For Bun Users:** Since the published package binaries contain a `#!/usr/bin/env node` shebang, running the global command directly (e.g., `shumai`) will execute under Node.js. If you installed with Bun and want to run under the Bun runtime, you must prefix all commands with `bun run --bun` (e.g., `bun run --bun shumai`, `bun run --bun shumai -d`, `bun run --bun shumai stop`).
Start the application from your workspace folder:
```bash
shumai
```
Alternatively, you can run and manage Shumai in daemon mode:
- **Start in daemon mode**:
```bash
shumai -d
```
- **Stop Shumai**:
```bash
shumai stop
```
- **Restart Shumai**:
```bash
shumai restart
```
- **Show/tail logs**:
```bash
shumai logs
```
On startup, Shumai will automatically run database migrations and start the web server at `http://localhost:3000`.
---
### Option 3: Run from Source (Development)
### Option 2: Run from Source (Development)
To set up Shumai locally for development:
@@ -322,8 +188,24 @@ To set up Shumai locally for development:
cd shumai
bun install
```
2. Start the `pgvector` database container (as described in **Option 2, Step 1**).
3. Create a `.env` file at the root of the workspace using the configuration from **Option 2, Step 5**.
2. Start the `pgvector` database container:
```bash
docker run --name shumai_postgres \
-e POSTGRES_USER=shumai \
-e POSTGRES_PASSWORD=shumai_password \
-e POSTGRES_DB=shumai_db \
-p 5432:5432 \
-d pgvector/pgvector:pg18
```
3. Create a `.env` file at the root of the workspace:
```env
DATABASE_URL=postgresql://shumai:shumai_password@localhost:5432/shumai_db?schema=public
BETTER_AUTH_SECRET=ySxs7DxzHDZBbeeHNPEwBuspYwipBqz5Gk5XdBjNhWw=
BETTER_AUTH_URL=http://localhost:3000
STORAGE_BACKEND=local
SHUMAI_SERVER_PORT=3000
AWS_ENDPOINT_URL_S3=http://localhost:3000
```
4. Generate i18n translation files:
```bash
bun run i18n:compile
@@ -339,6 +221,9 @@ To set up Shumai locally for development:
bun run dev
```
> [!NOTE]
> Looking to install Shumai globally via NPM or your package manager? See our [NPM Installation Guide](https://docs.shumai.one/getting-started/quickstart).
---
## Command Line Interface (CLI)
@@ -346,3 +231,13 @@ To set up Shumai locally for development:
Shumai provides a Command Line Interface (CLI) tool to manage projects, folders, and assets, upload files/folders, and create new versions directly from your terminal.
For more details on installation and usage, see the [CLI Readme](apps/cli/README.md).
## MCP Server
Shumai includes a built-in MCP server at `/mcp`, so external agents such as Claude Code, Cursor, or Kiro can browse and organize your projects with OAuth or an API token. See the [MCP server guide](docs/developer/mcp-server.mdx) for setup.
---
## Community
Thanks to [LINUX DO](https://linux.do/) for providing a community for open-source discussions and feedback.
+147 -265
View File
@@ -5,47 +5,50 @@
<h1 align="center">Shumai</h1>
<p align="center">
<strong>为创意工作打造的开源协作平台。</strong>
<strong>开源版 阅流 / 分秒帧 - 专为创意与视频团队打造的审片与管理平台。</strong>
</p>
<p align="center">
<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>
<a target="_blank" href="https://deepwiki.com/shumaiOne/shumai"><img alt="Ask DeepWiki" src="https://deepwiki.com/badge.svg" /></a>
<a target="_blank" href="https://deepwiki.com/shumaiOne/shumai"><img alt="Ask DeepWiki" src="https://img.shields.io/badge/Ask-DeepWiki-6E56CF" /></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>
<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)
## 功能
Shumai 是一个开源的 Frame.io 替代方案,专为创意团队打造,让大家能更轻松地协作、审片和分享素材:
Shumai 是一个专为广告,短剧,漫剧等各类创意团队打造的开源协作管理平台,功能上类似阅流和分秒帧,提供了协作、审片和分享等各种功能:
* **支持 S3 和本地存储**:你可以把创意素材安全地存到本地文件系统,或者任意兼容 S3 的存储服务里,比如 AWS S3、Cloudflare R2、MinIO 等。
* **逐帧标注和评论**:支持按帧进行精确反馈,可以直接在视频和图片素材上画重点、写评论,还能留下时间戳。
* **安全分享和合集管理**:可以生成私密分享链接,也能整理成精选合集,方便给客户、同事和合作方查看。
* **支持 S3 和本地存储**:你可以把创意素材安全地存放在本地硬盘或者任意兼容 S3 的存储服务里,比如 阿里云 OSS 或 MinIO 等。
* **帧级别标注和评论**:支持按帧进行精确反馈,同时支持直接在视频上进行标注,让团队成员能更精确地Get到你的想法。
* **安全的分享**:可以生成私密分享链接,同时还支持给分享的图片/视频添加自定义水印,并将水印配置保存为模板以便重复使用。方便给客户、同事和合作方查看。
* **细粒度权限控制**:支持按团队、项目设置角色权限,方便管理不同成员的访问范围。
* **基于 Temporal 的分布式转码**:把吃资源的视频转码任务交给后台 worker 池处理,由 Temporal 统一调度。
* **基于 DBOS 的持久化工作流**:视频转码任务由 DBOS 统一持久化编排与调度,具备自动恢复和容错能力。
* **Docker/K8s 弹性扩缩容部署**:支持在多个实例上横向自动扩缩容视频转码工作负载。详见 [EKS 部署示例](eks/README.md)。
* **自定义素材元数据**:可以按你的制作流程,自由定义动态元数据字段。
* **分享链接水印**:通过可自定义的文字和图片水印保护共享媒体,并将水印配置保存为模板以便重复使用。
* **丰富的文件格式支持**:支持预览常见创意文件格式,包括图片(支持 PSD)、视频、音频和文档,同时可上传和存储任意类型的文件。
* **基于转盘渲染服务的 3D 资产预览**:通过集成 [turntable-renderer](https://docs.shumai.one/using-shumai/3d-asset-support) 支持为 GLB、FBX、OBJ、STL、USD 和 DAE 等 3D 模型生成高质量的交互式转盘预览与视频。
* **基于 Gotenberg 的文档 PDF 转码代理**:通过集成 [Gotenberg](https://docs.shumai.one/using-shumai/gotenberg) 支持将 Word、PowerPoint、Excel、Markdown、HTML 和 CSV 文档高质量转换为 PDF 代理文件进行在线预览。
* **非编剪辑导出与 Premiere 插件(实验性)**:支持将时间戳审阅评论导出至常用非编软件(Premiere Pro XML、DaVinci Resolve EDL、Final Cut Pro、Avid Media Composer),或使用实验性的 Premiere Pro 原生 UXP 插件导入媒体素材并将评论自动同步为时间轴标记。详见[相关文档](https://docs.shumai.one/using-shumai/nle-and-premiere)。
* **3D 素材预览**:通过集成 [turntable-renderer](https://docs.shumai.one/using-shumai/3d-asset-support) 支持给 GLB、FBX、OBJ、STL、USD 和 DAE 等 3D 模型生成高质量的交互式转盘预览。
* **Office 与文档在线预览**:通过集成 [Gotenberg](https://docs.shumai.one/using-shumai/gotenberg),自动将 Word、PPT、Excel、Markdown、HTML 和 CSV 高质量转换为 PDF,直接在浏览器里丝滑预览。
* **语义搜索**:支持按画面内容或概念含义搜索素材,详见[相关文档](https://docs.shumai.one/using-shumai/semantic-search)。
* **非编剪辑导出与 Premiere 插件(测试版)**:支持将时间戳审阅评论导出至常用非编软件(Premiere Pro XML、DaVinci Resolve EDL、Final Cut Pro、Avid Media Composer),或使用实验性的 Premiere Pro 原生 UXP 插件导入媒体素材并将评论自动同步为时间轴标记。详见[相关文档](https://docs.shumai.one/using-shumai/nle-and-premiere)。
* **内置 MCP 服务端与 CLI 工具**:支持通过 `/mcp` 将外部 AI Agent 接入 Shumai,或使用 `shumai-cli` 在终端中管理项目、素材、评论与元数据。
但 Shumai 不仅仅只满足于 Frame.io 的开源替代。随着 GPT-Image-2、Seedance 2.5 这类强大模型的问世,AI已经生成产品级的图片/视频。很多时候,你只要给一句提示词,就能直接生成或修改图片和视频,而不用再打开 Photoshop、Premiere 或者 Houdini。也正因为这样,Shumai 才把 AI Agent 做成了核心能力:
Shumai 不仅仅只满足于「阅流」和「分秒帧」的开源替代。随着 GPT-Image-2、Seedance 2.5 这类强大视频/图片生成模型的问世,AI已经能够生成产品级的创意素材。只需要一句提示词,AI就能直接生成或修改图片和视频,而不用再打开 Photoshop、Premiere 或者 Houdini。因此Shumai也添加了Agent相关功能:
* **Agent 就像团队成员**:你可以在素材评论区里直接用 `@` 提到 AI Agent,像拉一个真实同事进来一起看稿一样。
> **AI 功能完全可选。** 你完全可以把 Shumai 当作纯粹的开源版「阅流 / 分秒帧」来用;如果团队不需要 AI,直接忽略即可。
* **Agent 是你的团队成员**:你可以在素材评论区里直接用 `@` 提到 AI Agent,像拉一个真实同事进来一起看稿一样。
* **Agent 也能当你的私聊助手**:你可以单独和它聊天,让它帮你查东西、做任务。
* **自定义技能和工具**:你可以给 Agent 接上自己的脚本、工具和自动化能力。
* **Model Context Protocol (MCP) 支持**:通过远程 MCP 服务端为 Agent 接入外部工具与 API,支持 OAuth 鉴权与按 Agent 独立分配访问权限。
* **自定义技能和工具**:你可以给 Agent 添加自己的脚本、工具和自动化能力。
* **接入外部 MCP 工具 (Model Context Protocol)**:通过远程 MCP 服务端为 Agent 接入外部工具与 API,支持 OAuth 鉴权与按 Agent 独立分配访问权限。
* **沙箱隔离执行**:Agent 生成的脚本会在隔离环境里运行,更安全。
* **AI 自动补全元数据**:新素材上传后,系统可以自动帮你补一些元数据。
* **语义搜索**:支持按画面内容或语义找素材,底层用的是向量 embedding(Gemini Embedding 2)。
* **AI 自动打标与补全元数据**:新素材上传后,AI 可根据画面内容自动识别并填写自定义元数据字段,省去手动归档打标的麻烦。
* **资源配额**:支持按成员、角色或全团队对 AI Token、成本和工具调用设置使用上限与实时用量监控。
下面是一个简短的 demo 视频,展示了 Shumai Agent 能做什么:
@@ -65,15 +68,17 @@ Shumai 也将项目管理融入了创意工作流程。 内置的看板可以帮
> * **图片:** 会生成一份与原图分辨率完全一致的高质量 WebP 转码版本,在保证画质的同时提升浏览性能。
> * **视频:** 会根据转码配置生成至少一个代理视频,同时生成雪碧图(Sprite)和一段最长 1600 帧的低分辨率转码视频,用于实现快速拖动时间轴和即时视频预览。
如果你有任何反馈或想法,欢迎在 [Issue #329](https://github.com/shumaiOne/shumai/issues/329) 中和我们交流。如果 Shumai 对你有帮助,希望能给我们点个 ⭐,或者安利给身边做视频/创意的朋友。
---
## 安装指南
以下是使用本地存储运行 Shumai 的快速上手指南。如需了解高级配置(包括 S3 兼容存储配置、Temporal 工作流编排等),请参阅我们的[官方文档](https://docs.shumai.one/getting-started/overview)。
以下是使用本地存储的快速安装指南。如需了解高级配置(包括 S3 兼容存储配置、分布式 worker 编排等),请参阅我们的[官方文档](https://docs.shumai.one/getting-started/overview)。
### 方案一:使用 Docker Compose(推荐)
<details>
<summary>复制这个提示词,让agent帮你安装</summary>
```
@@ -91,56 +96,67 @@ https://gh-proxy.com/https://raw.githubusercontent.com/shumaiOne/shumai/main/REA
```
</details>
使用 Docker Compose 是运行 Shumai 最快的方式。您无需克隆仓库,也不需要手动安装依赖包。请确保电脑上已安装 [Docker](https://docs.docker.com/get-docker/) 和 [Docker Compose](https://docs.docker.com/compose/install/),然后按照以下步骤操作:
使用 Docker Compose 是运行 Shumai 最快的方式。你无需克隆仓库,也不需要手动安装依赖包。请确保电脑上已安装 [Docker](https://docs.docker.com/get-docker/) 和 [Docker Compose](https://docs.docker.com/compose/install/),然后按照以下步骤操作:
1. 创建并进入一个新目录,用于存放配置文件和数据卷:
1. 创建一个新文件夹,用于存放配置文件和数据:
```bash
mkdir shumai && cd shumai
```
2. 下载 `docker-compose.yaml` 配置文件:
```bash
curl -o docker-compose.yaml https://raw.githubusercontent.com/shumaiOne/shumai/main/docker-compose/local/docker-compose-aliyun.yaml
```
2. 根据你的需求和机器可用内存,下载对应的 `docker-compose.yaml` 配置文件(注意所有镜像都是阿里云源,想要使用dockerhub源请参考不带aliyun的compose文件):
* **轻量版(建议内存:2 GB+)**:包含 Shumai 核心应用与 PostgreSQL 数据库。
```bash
curl -o docker-compose.yaml https://raw.githubusercontent.com/shumaiOne/shumai/main/docker-compose/local/docker-compose-aliyun.yaml
```
* **集成语义搜索版(建议内存:4 GB+)**:新增基于 `shumaiOne/embedding-server` (`EmbeddingGemma 2 740M`) 的本地多模态语义搜索能力。
```bash
curl -o docker-compose.yaml https://raw.githubusercontent.com/shumaiOne/shumai/main/docker-compose/local/docker-compose-aliyun.embedding.yaml
```
* **完整版(建议内存:8 GB+)**:一站式全功能版本,包含 `embedding-server`、`turntable-renderer`(3D 模型交互转盘预览)与 `Gotenberg`(文档与表格 PDF 代理转码)。
```bash
curl -o docker-compose.yaml https://raw.githubusercontent.com/shumaiOne/shumai/main/docker-compose/local/docker-compose-aliyun.full.yaml
```
> [!NOTE]
> 默认的 Docker Compose 配置使用基于 CPU 的软件转码。如果您的服务器配备了支持的显卡(NVIDIA NVENC、Intel QuickSync、AMD/Intel VA-API 或 Rockchip RKMPP)并需要开启 GPU 硬件加速转码,请参考 [硬件加速转码配置文档](https://docs.shumai.one/configuration/hardware-transcoding)。
> 默认的 Docker Compose 配置使用基于 CPU 的软件转码。如果你的服务器支持硬件加速(NVIDIA NVENC、Intel QuickSync、AMD/Intel VA-API 或 Rockchip RKMPP),请参考 [硬件加速转码配置文档](https://docs.shumai.one/configuration/hardware-transcoding)。
3. 配置环境变量(可选):
* `SHUMAI_SERVER_PORT` 用于控制 Shumai 服务监听的端口,默认值为 `3000`。
* 默认情况下,该 Docker Compose 部署会自动启用集成的本地存储。若想切换至外部 S3 兼容存储,请在 `environment` 中配置 S3 提供商的环境变量。以下是 AWS S3 和 Cloudflare R2 的配置示例:
3. 配置环境变量:
* `BETTER_AUTH_URL`:Shumai 服务的外部公开访问地址(例如 `https://shumai.example.com` 或 `http://12.34.56.78:3000`)。在远程服务器或生产环境中部署时必须配置该变量。
* `AWS_ENDPOINT_URL_S3`:默认情况下指向 `http://localhost:{SHUMAI_SERVER_PORT}`。当你使用本地存储(即默认配置 `STORAGE_BACKEND: local`)并在远程服务器、自定义域名或自定义端口上公开访问 Shumai 时,请将 `AWS_ENDPOINT_URL_S3` 设置为客户端浏览器上传和下载文件所使用的外部 URL。
**AWS S3 示例:**
```yaml
STORAGE_BACKEND: s3
S3_BUCKET: your-bucket-name
S3_ACCESS_KEY_ID: your-access-key-id
S3_SECRET_ACCESS_KEY: your-secret-access-key
AWS_ENDPOINT_URL_S3: https://s3.us-east-1.amazonaws.com
```
例如,如果你将 `docker-compose.yaml` 中的端口映射从 `3000:3000` 修改为了 `12345:3000`,且服务部署在 IP 为 `12.34.56.78` 的服务器上,请进行如下设置:
**Cloudflare R2 示例:**
```yaml
STORAGE_BACKEND: s3
S3_BUCKET: your-bucket-name
S3_REGION: auto
S3_ACCESS_KEY_ID: your-access-key-id
S3_SECRET_ACCESS_KEY: your-secret-access-key
AWS_ENDPOINT_URL_S3: https://<account-id>.r2.cloudflarestorage.com
```
```yaml
AWS_ENDPOINT_URL_S3: http://12.34.56.78:12345
```
此地址必须能够从客户端浏览器正常访问,且必须包含对外暴露的实际端口号。
* `SHUMAI_SERVER_PORT` 用于控制 Shumai 服务监听的端口,默认值为 `3000`。
* **外部 S3 存储**:默认情况下,该 Docker Compose 部署会自动启用集成的本地存储。若想切换至外部 S3 兼容存储,请在 `environment` 中配置 S3 提供商的环境变量。以下是 AWS S3 和 Cloudflare R2 的配置示例:
* 默认情况下 `AWS_ENDPOINT_URL_S3` 指向 `http://localhost:{SHUMAI_SERVER_PORT}`。如果您使用本地存储,但希望在自定义的主机名或端口上公开访问 Shumai,请务必将 `AWS_ENDPOINT_URL_S3` 修改为浏览器访问该服务时所使用的外部 URL。
例如,如果您将 `docker-compose.yaml` 中的端口映射从 `3000:3000` 修改为了 `12345:3000`,且服务部署在 IP 为 `12.34.56.78` 的服务器上,请进行如下设置:
```
AWS_ENDPOINT_URL_S3: http://12.34.56.78:12345
**AWS S3 示例:**
```yaml
STORAGE_BACKEND: s3
S3_BUCKET: your-bucket-name
S3_ACCESS_KEY_ID: your-access-key-id
S3_SECRET_ACCESS_KEY: your-secret-access-key
AWS_ENDPOINT_URL_S3: https://s3.us-east-1.amazonaws.com
```
```
此地址必须能够从客户端浏览器正常访问,且必须包含对外暴露的实际端口号。
**Cloudflare R2 示例:**
```yaml
STORAGE_BACKEND: s3
S3_BUCKET: your-bucket-name
S3_REGION: auto
S3_ACCESS_KEY_ID: your-access-key-id
S3_SECRET_ACCESS_KEY: your-secret-access-key
AWS_ENDPOINT_URL_S3: https://<account-id>.r2.cloudflarestorage.com
```
4. 在后台启动所有服务:
@@ -150,235 +166,91 @@ https://gh-proxy.com/https://raw.githubusercontent.com/shumaiOne/shumai/main/REA
```
5. 打开浏览器,访问 `http://localhost:3000` 即可开始使用(若是远程部署,请访问 `http://<您的服务器IP>:3000`)。
5. 打开浏览器,访问 `http://localhost:3000` 即可开始使用(若是远程部署,请访问 `http://<你的服务器IP>:3000`)。
### 方案二:通过 NPM / 包管理器安装
#### **扩展转码 Worker(并行处理)**
通过 NPM 上的 `@shumai-one/shumai` 进行安装。
默认情况下,Docker Compose 部署会按顺序逐个处理视频转码任务。这是出于系统设计考虑,因为视频转码属于计算密集型任务,容易耗尽可用的 CPU 或 GPU 资源。
#### 第一步:启动带 pgvector 支持的 PostgreSQL
但在批量上传(例如一次性上传 100+ 个视频)或处理需要耗费数小时的大型原始视频素材时,长时间的转码任务可能会阻塞后续文件的处理。此时,你可以通过增加额外的机器来横向扩展转码吞吐量。每台机器依然按顺序执行任务,但增加 worker 实例能够显著提升整体的并行处理能力。
Shumai 依赖支持 `pgvector` 扩展的 PostgreSQL 数据库。您可以使用 Docker 快速启动一个预配置好的数据库容器:
Shumai 提供了独立的转码 Worker 镜像(支持 Docker Hub 与阿里云镜像源):
```bash
docker run --name shumai_postgres \
-e POSTGRES_USER=shumai \
-e POSTGRES_PASSWORD=shumai_password \
-e POSTGRES_DB=shumai_db \
-p 5432:5432 \
-d docker.m.daocloud.io/pgvector/pgvector:pg18
1. **连接准备**:启动一台临时机器,确保其能够正常访问你的 PostgreSQL 数据库和存储。
2. **启动 Worker**:配置相同的数据库与存储连接凭据并运行容器:
```
**阿里云镜像(国内推荐):**
```bash
docker run -d --name shumai_transcode_worker \
-e DATABASE_URL="postgres://shumai:shumai_password@<postgres-host>:5432/shumai_db?sslmode=disable" \
-e STORAGE_BACKEND="s3" \
-e S3_BUCKET="your-bucket-name" \
-e AWS_ENDPOINT_URL_S3="https://s3.us-east-1.amazonaws.com" \
-e S3_ACCESS_KEY_ID="your-access-key-id" \
-e S3_SECRET_ACCESS_KEY="your-secret-access-key" \
crpi-000nkafzu6xvpwsc.cn-hongkong.personal.cr.aliyuncs.com/shumai-one/shumai-transcode:latest
```
#### 第二步:创建工作区目录
Worker 启动后会自动接入任务队列,并与主实例并行消费并处理积压的转码任务。
创建一个专属目录用来存放环境配置和媒体文件(媒体文件默认会保存在 `./data` 目录下):
3. **随时停止**:当转码队列处理完毕(或不再需要额外的算力)时,只需停止或移除 Worker 容器:
```bash
mkdir shumai && cd shumai
```bash
docker stop shumai_transcode_worker
```
```
主 Shumai 服务的运行不会受到任何影响,不需要停机。
#### 步骤 3:安装平台依赖
### 方案二:源码编译运行(开发环境)
#### Linux
在 Linux 上运行 Shumai 需要安装以下系统依赖:
- **`ffmpeg`** —— 用于媒体转码和元数据提取。
- **`poppler`** (`poppler-utils`) —— 用于 PDF 页面图像提取和 PDF 雪碧图预览生成 (`pdftoppm`)。
- **`imagemagick`** —— 用于 PSD 格式图像转码和 sRGB 色彩空间转换。
- **`dcraw_emu`** (`libraw` / `libraw-bin`) —— 用于相机 RAW 格式图像解码和预览图生成。
- **`bubblewrap`**、**`socat`** 和 **`ripgrep`** —— AI Agent 沙箱(`anthropic-experimental/sandbox-runtime`)所需,用于进程隔离、网络通信和工作区搜索。
可以使用以下命令一次性安装所有依赖:
> Ubuntu/Debian
```bash
sudo apt install -y ffmpeg poppler-utils imagemagick bubblewrap socat ripgrep libraw-bin
```
> Fedora
```bash
sudo dnf install -y ffmpeg poppler-utils ImageMagick bubblewrap socat ripgrep LibRaw
```
> Arch Linux
```bash
sudo pacman -S --noconfirm ffmpeg poppler imagemagick bubblewrap socat ripgrep libraw
```
> [!NOTE]
> **Ubuntu 24.04+** 默认限制非特权用户创建 User Namespace,这会导致 `anthropic-experimental/sandbox-runtime` 无法使用 `bubblewrap` 提供沙箱隔离。
>
> 如需临时启用 User Namespace,请执行:
>
> ```bash
> sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
> ```
>
> 或者,配置 AppArmor Profile,为相关可执行文件授予所需的 `userns`权限。
---
#### macOS
在 macOS 上运行 Shumai 需要:
- **`ffmpeg`** —— 用于媒体转码和元数据提取。
- **`poppler`** —— 用于 PDF 页面图像提取和 PDF 雪碧图预览生成 (`pdftoppm`)。
- **`imagemagick`** —— 用于 PSD 格式图像转码和 sRGB 色彩空间转换。
- **`dcraw_emu`** (`libraw`) —— 用于相机 RAW 格式图像解码和预览图生成。
- **`ripgrep`** —— AI Agent 沙箱(`anthropic-experimental/sandbox-runtime`)所需。
使用 Homebrew 安装所需依赖:
```bash
brew install ffmpeg poppler imagemagick ripgrep libraw
```
---
#### Windows(Alpha)
> [!WARNING]
> anthropic-experimental/sandbox-runtime 的 Windows 支持目前仍处于 **Alpha** 阶段,整体设计仍在持续调整中。
>
> 当前实现提供了以下能力:
> - 通过 **Windows Filtering Platform (WFP)** 实现网络出口(egress)过滤。
> - 通过 **ACL Stamping** 实现文件读写权限限制。
>
> **但这并不能作为针对恶意沙箱进程的安全边界(security boundary)**。
>
> 未来版本将对沙箱机制进行重大调整,届时沙箱进程将运行在独立的沙箱用户账户下。
在 Windows 上运行 Shumai 需要:
- **`ffmpeg`** —— 用于媒体转码和元数据提取。
- **`imagemagick`** —— 用于 PSD 格式图像转码和 sRGB 色彩空间转换。
使用你偏好的包管理器安装所需依赖:
**winget**
```powershell
winget install Gyan.FFmpeg ImageMagick.ImageMagick
```
**Chocolatey**
```powershell
choco install ffmpeg imagemagick
```
#### 第四步:全局安装 Shumai
使用您常用的包管理器进行全局安装:
```bash
# 使用 NPM
npm install -g @shumai-one/shumai
# 使用 PNPM
pnpm add -g @shumai-one/shumai
# 使用 Bun
bun add -g @shumai-one/shumai
```
#### 第五步:配置环境配置
在刚才创建的工作区目录(`shumai/`)下新建一个 `.env` 文件,并填入以下配置:
```env
DATABASE_URL=postgresql://shumai:shumai_password@localhost:5432/shumai_db?schema=public
BETTER_AUTH_SECRET=ySxs7DxzHDZBbeeHNPEwBuspYwipBqz5Gk5XdBjNhWw=
STORAGE_BACKEND=local
SHUMAI_SERVER_PORT=3000
AWS_ENDPOINT_URL_S3=http://localhost:3000
```
> [!NOTE]
> `SHUMAI_SERVER_PORT` 用于设置 Web 服务的启动端口,而 `AWS_ENDPOINT_URL_S3` 供浏览器端构建文件上传链接。
> 如果您部署在远程服务器(如 `http://123.456.7.8`)并且做了端口映射(如 Docker 中的 `12345:3000`),请将 `AWS_ENDPOINT_URL_S3` 设置为 `http://123.456.7.8:12345`。
#### 第六步:启动 Shumai
> [!IMPORTANT]
> **Bun 用户特别提示:** 由于发布的包二进制文件包含 `#!/usr/bin/env node` 头部声明(Shebang),直接在终端执行全局命令(例如 `shumai`)默认会通过 Node.js 运行。如果您是用 Bun 安装的并且希望调用 Bun 运行时,请在所有命令前加上 `bun run --bun` 前缀(例如:`bun run --bun shumai`、`bun run --bun shumai -d`、`bun run --bun shumai stop`)。
在您的工作区目录下执行以下命令启动应用:
```bash
shumai
```
您也可以让 Shumai 在后台以守护进程(Daemon)模式运行和管理:
* **后台模式启动**:
```bash
shumai -d
```
* **停止服务**:
```bash
shumai stop
```
* **重启服务**:
```bash
shumai restart
```
* **查看并跟踪实时日志**:
```bash
shumai logs
```
启动时,Shumai 会自动执行数据库迁移(Migration)并在 `http://localhost:3000` 拉起 Web 服务。
---
### 方案三:源码编译运行(开发环境)
如果您希望在本地参与 Shumai 的开发,请按以下步骤配置开发环境:
如果你希望在本地参与 Shumai 的开发,请按以下步骤配置开发环境:
1. 克隆代码仓库并安装依赖项:
```bash
git clone [https://github.com/shumaiOne/shumai.git](https://github.com/shumaiOne/shumai.git)
cd shumai
bun install
```bash
git clone https://github.com/shumaiOne/shumai.git
cd shumai
bun install
```
```
2. 启动 `pgvector` 数据库容器:
```bash
docker run --name shumai_postgres \
-e POSTGRES_USER=shumai \
-e POSTGRES_PASSWORD=shumai_password \
-e POSTGRES_DB=shumai_db \
-p 5432:5432 \
-d docker.m.daocloud.io/pgvector/pgvector:pg18
```
3. 在项目根目录下创建一个 `.env` 文件,填入以下基础配置:
```env
DATABASE_URL=postgresql://shumai:shumai_password@localhost:5432/shumai_db?schema=public
BETTER_AUTH_SECRET=ySxs7DxzHDZBbeeHNPEwBuspYwipBqz5Gk5XdBjNhWw=
BETTER_AUTH_URL=http://localhost:3000
STORAGE_BACKEND=local
SHUMAI_SERVER_PORT=3000
AWS_ENDPOINT_URL_S3=http://localhost:3000
```
2. 启动 `pgvector` 数据库容器(参考**方案二中的第一步**)。
3. 参照**方案二中的第五步**,在项目根目录下创建一个 `.env` 文件。
4. 生成多语言国际化(i18n)代码:
```bash
bun run i18n:compile
```
> [!TIP]
> 在前端开发过程中,可以在单独的终端窗口中运行 `bun run i18n:watch`,在修改 `packages/webui/messages/` 下的翻译文案时自动重新编译。
```bash
bun run i18n:compile
```
> [!TIP]
> 在前端开发过程中,可以在单独的终端窗口中运行 `bun run i18n:watch`,在修改 `packages/webui/messages/` 下的翻译文案时自动重新编译。
5. 执行数据库结构迁移:
```bash
bun run db:migrate
```
```bash
bun run db:migrate
```
6. 启动本地开发服务器:
```bash
bun run dev
```
```bash
bun run dev
```
> [!NOTE]
> 如需通过 NPM 或包管理器全局安装运行 Shumai,请参考[官方 NPM 安装指南](https://docs.shumai.one/getting-started/quickstart)。
@@ -386,6 +258,16 @@ bun run dev
## 命令行工具 (CLI)
Shumai 自带一个功能完备的命令行工具(CLI),支持您直接在终端里高效管理项目、文件夹、资产,批量上传文件/目录,以及快速创建新版本。
Shumai 自带一个功能完备的命令行工具(CLI),支持你直接在终端里高效管理项目、文件夹、素材,批量上传文件/目录,以及快速创建新版本。
关于 CLI 的安装与详细使用指南,请参阅 [CLI Readme](https://www.google.com/search?q=apps/cli/README.md)。
关于 CLI 的安装与详细使用指南,请参阅 [CLI Readme](apps/cli/README.md)。
## MCP 服务器
Shumai 内置 MCP 服务器(地址为 `/mcp`),Claude Code、Cursor、Kiro 等外部智能体可以使用 API 令牌连接,浏览并整理你的项目。配置方法请参阅 [MCP 服务器指南](docs/developer/mcp-server.mdx)。
---
## 社区
感谢 [LINUX DO](https://linux.do/) 提供开源交流社区,欢迎佬友交流使用体验与改进建议。
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/agent-app",
"version": "0.5.2",
"version": "0.6.2",
"private": true,
"type": "module",
"bin": {
+1 -10
View File
@@ -21,16 +21,7 @@ async function run() {
console.log('🚀 Starting Agent Worker...')
const options: { workflowBundle?: unknown; workflowsPath?: string } = {}
if (process.env.NODE_ENV === 'production') {
// @ts-ignore: Bun temporal plugin macro
const { default: workflowBundle } = await import('./workflows.ts:::workflow')
options.workflowBundle = workflowBundle
} else {
options.workflowsPath = new URL('./workflows.ts', import.meta.url).pathname
}
await workflowService.startWorkers(TaskQueueAgent, options)
await workflowService.startWorkers(TaskQueueAgent)
}
handleDaemonCommands('shumai-agent', run).catch((err) => {
-4
View File
@@ -1,4 +0,0 @@
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/query-embedding-for-search'
+130 -4
View File
@@ -2,13 +2,13 @@
A Command Line Interface (CLI) tool for interacting with your Shumai instance.
The CLI allows you to view projects, list folder contents, create folders, upload files and directories, and create new versions of existing files directly from the terminal.
The CLI allows you to view projects, list folder contents, create folders, upload files and directories, create new versions of existing files, and look at images, video frames, and document pages directly from the terminal.
---
## Installation
The CLI package is bundled inside the Shumai workspace.
The CLI package is bundled inside the Shumai workspace. The published npm package (`@shumai-one/shumai-cli`) requires Node.js 22.12 or later.
### Environment Setup
@@ -18,7 +18,8 @@ Before using the CLI, you must set the following environment variables to authen
# The endpoint of your Shumai API server (e.g. http://localhost:3000)
export SHUMAI_API_SERVER="http://localhost:3000"
# Your personal API Token (Generate this in the WebUI via Settings -> Developer tab)
# Your personal API Token (Generate this in the WebUI via Settings -> API Tokens tab).
# The token is shown only once when it is created, so copy it right away.
export SHUMAI_API_KEY="your-developer-api-token"
# Optional: Enable asset deletion capability (disabled by default for safety)
@@ -38,6 +39,14 @@ Run `shumai-cli` or query specific commands:
shumai-cli <command> [arguments] [options]
```
Run `shumai-cli --help` to list all commands, and `shumai-cli <command> --help` for a command's arguments and options.
### Global Options
- `--json`: Print the raw JSON result instead of human-friendly text, for scripts and tools like `jq`. Example: `shumai-cli ls -p <parentId> --json | jq '.data[].id'`.
When the output is piped instead of shown in a terminal, tables are printed as tab-separated values without headers.
### Commands
#### 1. List Projects
@@ -50,7 +59,7 @@ shumai-cli project ls
#### 2. List Directory Contents
List direct children (folders and files) of a parent folder.
List direct children (folders and files) of a parent folder. Folders are listed first.
```bash
shumai-cli ls -p <parentId>
@@ -58,6 +67,9 @@ shumai-cli ls -p <parentId>
- **Options:**
- `-p`, `--parent <id>`: The parent folder ID (required).
- `--type <type>`: Only list `file`, `folder`, or `all` (default).
- `--first <n>`: Maximum number of items to list (default and maximum: 200).
- `--after <cursor>`: Continue a long listing. When more items exist, `ls` prints the cursor to pass here.
#### 3. Create a New Folder
@@ -123,6 +135,116 @@ shumai-cli delete <assetId>
shumai-cli rm <assetId>
```
#### 9. Read an Asset
Look at a file: an image, video frames, PDF pages, a 3D model view, or the text of a text file. Prints a summary and a link to each image (links are valid for about an hour), or the file's text.
```bash
# An image, or the 4-view overview of a 3D model
shumai-cli read <assetId>
# 5 evenly spaced frames between 0s and 30s of a video, downloaded into ./frames
shumai-cli read <assetId> --video-start 0 --video-end 30 --video-count 5 --out frames
# Pages 1 to 3 of a PDF, or the text of a text file
shumai-cli read <assetId> --doc-mode pages --doc-start-page 1 --doc-end-page 3
shumai-cli read <assetId> --doc-mode text
# A 3D model at 90°
shumai-cli read <assetId> --degree 90
```
- **Options:**
- `--video-start <s>`, `--video-end <s>`, `--video-count <n>`: Video frames to extract (up to 20).
- `--doc-mode <pages|text>`, `--doc-start-page <n>`, `--doc-end-page <n>`: PDF pages to render (up to 20), or `text` to read a text file.
- `--degree <deg>`: 3D model angle (0, 15, 30, ..., 345).
- `--annotation-id <id>`: Draw a comment's markup on the image, frame, or page.
- `-o`, `--out <dir>`: Download the images into a folder and print their paths. With `--json`, each image also gets a `path`.
- `--max-wait-seconds <s>`, `--no-wait`: Rendering frames or pages can take a while. `read` waits up to 2 minutes; use these to wait less or return right away. If the render isn't done, `read` prints the `render` command to run next.
#### 10. Get a Render
Get the result of a `read` that was still rendering. Takes the same `--out`, `--max-wait-seconds`, and `--no-wait` options as `read`.
```bash
shumai-cli render <taskId> --out frames
```
#### 11. Download Files
Download up to 50 files at once. By default it saves the web preview version when there is one (for example the transcoded video or the web image), which is smaller; use `--original` for the uploaded file. A version stack downloads its latest version. Folders aren't supported: download the files inside them. Files keep their names; if a name is taken, the new file gets a number, like `clip (2).mp4`.
```bash
shumai-cli download <assetId...> --out ./downloads
shumai-cli download <assetId> --original
```
- **Options:**
- `-o`, `--out <dir>`: Folder to save the files in (default: the current folder). With `--json`, each file also gets a `path`.
- `--original`: Download the original uploaded files instead of the web previews.
#### 12. Search Files
Search a folder and all of its subfolders by name, or by meaning with `--semantic` (when AI search is enabled for the team).
```bash
shumai-cli search <query> -p <folderId>
shumai-cli search "a calm beach at sunset" -p <folderId> --semantic
```
- **Options:**
- `-p`, `--parent <id>`: The folder to search in (required).
- `--type <file|folder>`: Search files (default) or folders.
- `--first <n>`, `--after <cursor>`: Page through many results.
#### 13. Copy Assets
Copy files or folders into another folder of the same team. Prints the IDs of the copies.
```bash
shumai-cli copy <assetId...> -p <parentId> [--with-comments]
# or using the short alias:
shumai-cli cp <assetId...> -p <parentId>
```
#### 14. Comments
```bash
# List the comments on a file, with their replies
shumai-cli comment ls <assetId>
# Comment on a file, optionally at a timecode (seconds), or reply to a comment
shumai-cli comment add <assetId> "The logo is too small" --at 12.5
shumai-cli comment add <assetId> "Fixed in v2" --reply-to <commentId>
# Mark a comment as resolved, or unresolved again
shumai-cli comment resolve <commentId>
shumai-cli comment resolve <commentId> --reopen
```
#### 15. Metadata
```bash
# List a project's metadata fields and their choices
shumai-cli field ls <projectId>
# Set metadata values on a file, as JSON keyed by field key (select fields take an option id)
shumai-cli meta set <assetId> --values '{"status": "approved", "rating": 4}'
```
#### 16. Version Stacks
```bash
# Stack files in the same folder as versions; the first file is the latest
shumai-cli version stack <fileId...>
# List the versions in a stack, latest first
shumai-cli version ls <stackId>
# Take a version out of its stack (the file is kept)
shumai-cli version unstack <versionId>
```
#### 17. Folder Instructions
Show a folder's instructions for AI agents (its AGENTS.md).
```bash
shumai-cli instructions <folderId>
```
---
## Development
@@ -132,3 +254,7 @@ To run the CLI in development mode inside the repository source code:
```bash
bun run apps/cli/src/index.ts project ls
```
### Adding Commands
Most commands are generated from the shared Operation definitions in `packages/operations` (see "Operations" in `AGENTS.md`). An Operation with the `cli` surface and a `cli` spec becomes a command automatically, with arguments, options, and help text derived from its input schema (key/value inputs such as `meta set --values` take a JSON object). It is also available to Shumai's built-in agent and MCP server. Behavior that needs the local machine, such as downloading files, goes in a CLI extension in `src/operations/extensions/` (extra options, input mapping, and output). Only commands that stream local files (`upload`, `create-version`) are written by hand in `src/program.ts`; the `create_file`, `create_version`, and `complete_upload` Operations are for the agent and MCP only.
+5 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/cli",
"version": "0.5.2",
"version": "0.6.2",
"private": true,
"type": "module",
"bin": {
@@ -8,10 +8,12 @@
},
"dependencies": {
"@shumai/api": "workspace:*",
"@shumai/core": "workspace:*",
"@shumai/dtos": "workspace:*",
"@shumai/operations": "workspace:*",
"@shumai/tableprinter": "workspace:*",
"commander": "15.0.0",
"hono": "4.13.5",
"ulid": "3.0.2"
"ulid": "3.0.2",
"zod": "4.5.4"
}
}
+14 -2
View File
@@ -1,7 +1,13 @@
import { hc } from 'hono/client'
import type { AppType } from '@shumai/api'
export function getClient() {
export interface CliConfig {
apiServer: string
apiKey: string
}
/** Reads the server URL and API token from the environment, exiting with guidance if missing. */
export function getCliConfig(): CliConfig {
const apiKey = process.env.SHUMAI_API_KEY
const apiServer = process.env.SHUMAI_API_SERVER
@@ -12,11 +18,17 @@ export function getClient() {
if (!apiKey) {
console.error(
'Error: SHUMAI_API_KEY environment variable is not set. Please generate a token in the Settings -> Developer tab.',
'Error: SHUMAI_API_KEY environment variable is not set. Please generate a token in the Settings -> API Tokens tab.',
)
process.exit(1)
}
return { apiServer: apiServer.replace(/\/+$/, ''), apiKey }
}
/** Typed REST client, used by commands that are not Operations yet (upload, create-version). */
export function getClient() {
const { apiServer, apiKey } = getCliConfig()
return hc<AppType>(apiServer, {
headers: {
Authorization: `Bearer ${apiKey}`,
+1 -261
View File
@@ -1,13 +1,7 @@
import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest'
import { projectLs } from './project'
import { ls } from './ls'
import { mkdir } from './mkdir'
import { getClient } from '../client'
import { upload } from './upload'
import { createVersion } from './create-version'
import { rename } from './rename'
import { move } from './move'
import { deleteAsset } from './delete'
import fs from 'node:fs'
import http from 'node:http'
@@ -21,7 +15,7 @@ vi.mock('node:http', () => ({
},
}))
describe('CLI Commands', () => {
describe('CLI upload commands', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let logSpy: any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -103,72 +97,6 @@ describe('CLI Commands', () => {
}
})
describe('project ls', () => {
it('prints list of projects correctly', async () => {
mockClient.api.projects.$get.mockResolvedValue({
ok: true,
json: async () => ({
data: [
{ id: 'p1', name: 'Proj 1', rootFolder: 'root1' },
{ id: 'p2', name: 'Proj 2', rootFolder: 'root2' },
],
}),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any)
await projectLs()
expect(mockClient.api.projects.$get).toHaveBeenCalledWith({
query: { first: '200' },
})
expect(writeSpy).toHaveBeenCalledWith(expect.stringContaining('Proj 1'))
expect(writeSpy).toHaveBeenCalledWith(expect.stringContaining('Proj 2'))
})
})
describe('ls', () => {
it('queries folders and files and displays table', async () => {
mockClient.api.folders[':folderId'].children.$get
.mockResolvedValueOnce({
ok: true,
json: async () => ({
data: [{ id: 'subfolder1', name: 'Sub 1', type: 'folder', sizeByte: 0 }],
}),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any)
.mockResolvedValueOnce({
ok: true,
json: async () => ({
data: [{ id: 'file1', name: 'doc.pdf', type: 'file', sizeByte: 1024 }],
}),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any)
await ls('parentId123')
expect(mockClient.api.folders[':folderId'].children.$get).toHaveBeenCalledTimes(2)
expect(writeSpy).toHaveBeenCalledWith(expect.stringContaining('Sub 1'))
expect(writeSpy).toHaveBeenCalledWith(expect.stringContaining('doc.pdf'))
})
})
describe('mkdir', () => {
it('calls POST /folders and prints the folder ID', async () => {
mockClient.api.folders.$post.mockResolvedValue({
ok: true,
json: async () => ({ id: 'new_folder_ulid' }),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any)
await mkdir('NewFolder', 'parent_ulid')
expect(mockClient.api.folders.$post).toHaveBeenCalledWith({
json: { name: 'NewFolder', parentId: 'parent_ulid' },
})
expect(logSpy).toHaveBeenCalledWith('Created folder with ID: new_folder_ulid')
})
})
describe('upload', () => {
it('uploads a file successfully and confirms the task', async () => {
const tempFile = 'temp-test-file.txt'
@@ -383,192 +311,4 @@ describe('CLI Commands', () => {
}
})
})
describe('rename', () => {
it('exits with error when assetId or newName is missing', async () => {
await expect(rename('', 'new-name')).rejects.toThrow('process.exit(1)')
expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining('Asset ID is required'))
await expect(rename('asset-1', '')).rejects.toThrow('process.exit(1)')
expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining('New name is required'))
})
it('renames a folder when asset type is folder', async () => {
mockClient.api.folders[':folderId'].$get.mockResolvedValue({
ok: true,
json: async () => ({ id: 'f-1', type: 'folder' }),
} as unknown as Response)
mockClient.api.folders[':folderId'].$put.mockResolvedValue({
ok: true,
json: async () => ({ id: 'f-1', name: 'Renamed Folder' }),
} as unknown as Response)
await rename('f-1', 'Renamed Folder')
expect(mockClient.api.folders[':folderId'].$put).toHaveBeenCalledWith({
param: { folderId: 'f-1' },
json: { name: 'Renamed Folder' },
})
expect(logSpy).toHaveBeenCalledWith('Renamed asset f-1 to "Renamed Folder"')
})
it('renames a file when asset type is file', async () => {
mockClient.api.folders[':folderId'].$get.mockResolvedValue({
ok: true,
json: async () => ({ id: 'file-1', type: 'file' }),
} as unknown as Response)
mockClient.api.files[':fileId'].$put.mockResolvedValue({
ok: true,
json: async () => ({ id: 'file-1', name: 'new.mp4' }),
} as unknown as Response)
await rename('file-1', 'new.mp4')
expect(mockClient.api.files[':fileId'].$put).toHaveBeenCalledWith({
param: { fileId: 'file-1' },
json: { name: 'new.mp4' },
})
expect(logSpy).toHaveBeenCalledWith('Renamed asset file-1 to "new.mp4"')
})
it('exits with error when asset fetch fails', async () => {
mockClient.api.folders[':folderId'].$get.mockResolvedValue({
ok: false,
json: async () => ({ error: 'Asset not found' }),
} as unknown as Response)
await expect(rename('unknown-id', 'name')).rejects.toThrow('process.exit(1)')
expect(errorSpy).toHaveBeenCalledWith('Error: Asset not found')
})
})
describe('move', () => {
it('exits with error when assetIds or parentId is missing', async () => {
await expect(move([], 'parent-1')).rejects.toThrow('process.exit(1)')
expect(errorSpy).toHaveBeenCalledWith(
expect.stringContaining('At least one asset ID is required'),
)
await expect(move(['a-1'], '')).rejects.toThrow('process.exit(1)')
expect(errorSpy).toHaveBeenCalledWith(
expect.stringContaining('Option -p/--parent <parentId> is required'),
)
})
it('successfully moves assets', async () => {
mockClient.api.folders[':folderId'].$get.mockResolvedValue({
ok: true,
json: async () => ({ id: 'parent-1', projectId: 'proj-1' }),
} as unknown as Response)
mockClient.api.projects[':projectId'].reparent.$post.mockResolvedValue({
ok: true,
} as unknown as Response)
await move(['a-1', 'a-2'], 'parent-1')
expect(mockClient.api.projects[':projectId'].reparent.$post).toHaveBeenCalledWith({
param: { projectId: 'proj-1' },
json: {
assetIds: ['a-1', 'a-2'],
newParentId: 'parent-1',
},
})
expect(logSpy).toHaveBeenCalledWith('Moved 2 asset(s) to parent parent-1')
})
it('exits with error when destination parent is not found', async () => {
mockClient.api.folders[':folderId'].$get.mockResolvedValue({
ok: false,
json: async () => ({ error: 'Folder not found' }),
} as unknown as Response)
await expect(move(['a-1'], 'missing-parent')).rejects.toThrow('process.exit(1)')
expect(errorSpy).toHaveBeenCalledWith('Error: Folder not found')
})
})
describe('deleteAsset', () => {
it('exits with error when SHUMAI_ALLOW_DELETE is not set or not true', async () => {
delete process.env.SHUMAI_ALLOW_DELETE
await expect(deleteAsset(['a-1'])).rejects.toThrow('process.exit(1)')
expect(errorSpy).toHaveBeenCalledWith(
'Error: Asset deletion is disabled in this environment.',
)
})
it('exits with error when assetIds is empty', async () => {
process.env.SHUMAI_ALLOW_DELETE = 'true'
await expect(deleteAsset([])).rejects.toThrow('process.exit(1)')
expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining('Asset ID is required'))
})
it('exits with error when more than one asset ID is passed', async () => {
process.env.SHUMAI_ALLOW_DELETE = 'true'
await expect(deleteAsset(['a-1', 'a-2'])).rejects.toThrow('process.exit(1)')
expect(errorSpy).toHaveBeenCalledWith('Error: Can only delete one asset at a time.')
})
it('exits with error when asset is not found', async () => {
process.env.SHUMAI_ALLOW_DELETE = 'true'
mockClient.api.folders[':folderId'].$get.mockResolvedValue({
ok: false,
json: async () => ({ error: 'Asset not found' }),
} as unknown as Response)
await expect(deleteAsset(['a-1'])).rejects.toThrow('process.exit(1)')
expect(errorSpy).toHaveBeenCalledWith('Error: Asset not found')
})
it('successfully deletes a file when SHUMAI_ALLOW_DELETE is true', async () => {
process.env.SHUMAI_ALLOW_DELETE = 'true'
mockClient.api.folders[':folderId'].$get.mockResolvedValue({
ok: true,
json: async () => ({ id: 'a-1', type: 'file' }),
} as unknown as Response)
mockClient.api.files.$delete.mockResolvedValue({
ok: true,
} as unknown as Response)
await deleteAsset(['a-1'])
expect(mockClient.api.files.$delete).toHaveBeenCalledWith({
json: { ids: ['a-1'] },
})
expect(mockClient.api.folders.$delete).not.toHaveBeenCalled()
expect(logSpy).toHaveBeenCalledWith('Deleted asset a-1')
})
it('successfully deletes a folder when SHUMAI_ALLOW_DELETE is 1', async () => {
process.env.SHUMAI_ALLOW_DELETE = '1'
mockClient.api.folders[':folderId'].$get.mockResolvedValue({
ok: true,
json: async () => ({ id: 'folder-1', type: 'folder' }),
} as unknown as Response)
mockClient.api.folders.$delete.mockResolvedValue({
ok: true,
} as unknown as Response)
await deleteAsset(['folder-1'])
expect(mockClient.api.folders.$delete).toHaveBeenCalledWith({
json: { ids: ['folder-1'] },
})
expect(logSpy).toHaveBeenCalledWith('Deleted asset folder-1')
})
it('exits with error when delete API returns an error', async () => {
process.env.SHUMAI_ALLOW_DELETE = 'true'
mockClient.api.folders[':folderId'].$get.mockResolvedValue({
ok: true,
json: async () => ({ id: 'a-1', type: 'file' }),
} as unknown as Response)
mockClient.api.files.$delete.mockResolvedValue({
ok: false,
json: async () => ({ error: 'Failed to delete' }),
} as unknown as Response)
await expect(deleteAsset(['a-1'])).rejects.toThrow('process.exit(1)')
expect(errorSpy).toHaveBeenCalledWith('Error: Failed to delete')
})
})
})
-62
View File
@@ -1,62 +0,0 @@
import { getClient } from '../client'
export async function deleteAsset(assetIds: string[]) {
const isAllowed =
process.env.SHUMAI_ALLOW_DELETE === 'true' || process.env.SHUMAI_ALLOW_DELETE === '1'
if (!isAllowed) {
console.error('Error: Asset deletion is disabled in this environment.')
process.exit(1)
}
if (!assetIds || assetIds.length === 0) {
console.error('Error: Asset ID is required. Usage: shumai-cli delete <assetId>')
process.exit(1)
}
if (assetIds.length > 1) {
console.error('Error: Can only delete one asset at a time.')
process.exit(1)
}
const assetId = assetIds[0]
const client = getClient()
try {
// Inspect asset to determine whether it is a folder or file
const getRes = await client.api.folders[':folderId'].$get({
param: { folderId: assetId },
})
if (!getRes.ok) {
const err = (await getRes.json().catch(() => ({ error: 'Asset not found' }))) as {
error?: string
}
console.error(`Error: ${err.error || 'Asset not found'}`)
process.exit(1)
}
const asset = await getRes.json()
const isFolder = asset.type === 'folder'
const res = isFolder
? await client.api.folders.$delete({
json: { ids: [assetId] },
})
: await client.api.files.$delete({
json: { ids: [assetId] },
})
if (!res.ok) {
const err = (await res.json().catch(() => ({ error: 'Failed to delete asset' }))) as {
error?: string
}
console.error(`Error: ${err.error || 'Failed to delete asset'}`)
process.exit(1)
}
console.log(`Deleted asset ${assetId}`)
} catch (err) {
console.error('Error connecting to API server:', err instanceof Error ? err.message : err)
process.exit(1)
}
}
-87
View File
@@ -1,87 +0,0 @@
import { newTablePrinter, withTruncate } from '@shumai/tableprinter'
import type { AssetInfo } from '@shumai/dtos'
import { getClient } from '../client'
function formatSize(bytes: number): string {
if (bytes === 0) return '-'
const k = 1024
const sizes = ['B', 'KB', 'MB', 'GB', 'TB']
const i = Math.floor(Math.log(bytes) / Math.log(k))
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
}
export async function ls(parentId: string) {
if (!parentId) {
console.error('Error: Parent ID (-p/--parent) is required.')
process.exit(1)
}
const client = getClient()
try {
const [foldersRes, filesRes] = await Promise.all([
client.api.folders[':folderId'].children.$get({
param: { folderId: parentId },
query: { assetType: 'folder', first: '200' },
}),
client.api.folders[':folderId'].children.$get({
param: { folderId: parentId },
query: { assetType: 'file', first: '200' },
}),
])
if (!foldersRes.ok) {
const err = (await foldersRes.json().catch(() => ({ error: 'Unknown error' }))) as {
error?: string
}
console.error(`Error: ${err.error || 'Failed to list folders'}`)
process.exit(1)
}
if (!filesRes.ok) {
const err = (await filesRes.json().catch(() => ({ error: 'Unknown error' }))) as {
error?: string
}
console.error(`Error: ${err.error || 'Failed to list files'}`)
process.exit(1)
}
const foldersData = await foldersRes.json()
const filesData = await filesRes.json()
const folders = foldersData.data || []
const files = filesData.data || []
const items = [
...folders.map((f: AssetInfo) => ({ ...f, typeDisplay: 'folder' as const })),
...files.map((f: AssetInfo) => ({ ...f, typeDisplay: 'file' as const })),
]
if (items.length === 0) {
console.log('No assets found in this folder.')
return
}
const isTty = process.stdout.isTTY
const maxWidth = process.stdout.columns || 80
const tp = newTablePrinter(process.stdout, isTty, maxWidth)
tp.addHeader(['ID', 'Name', 'Type', 'Size'])
for (const item of items) {
tp.addField(item.id || '', withTruncate(null))
tp.addField(item.name || '')
tp.addField(item.typeDisplay, withTruncate(null))
tp.addField(
item.typeDisplay === 'folder' ? '-' : formatSize(item.sizeByte || 0),
withTruncate(null),
)
tp.endRow()
}
tp.render()
} catch (err) {
console.error('Error connecting to API server:', err instanceof Error ? err.message : err)
process.exit(1)
}
}
-32
View File
@@ -1,32 +0,0 @@
import { getClient } from '../client'
export async function mkdir(name: string, parentId: string) {
if (!name) {
console.error('Error: Folder name is required.')
process.exit(1)
}
if (!parentId) {
console.error('Error: Parent ID (-p/--parent) is required.')
process.exit(1)
}
const client = getClient()
try {
const res = await client.api.folders.$post({
json: { name, parentId },
})
if (!res.ok) {
const err = (await res.json().catch(() => ({ error: 'Unknown error' }))) as { error?: string }
console.error(`Error: ${err.error || 'Failed to create folder'}`)
process.exit(1)
}
const created = await res.json()
console.log(`Created folder with ID: ${created.id}`)
} catch (err) {
console.error('Error connecting to API server:', err instanceof Error ? err.message : err)
process.exit(1)
}
}
-59
View File
@@ -1,59 +0,0 @@
import { getClient } from '../client'
export async function move(assetIds: string[], parentId: string) {
if (!assetIds || assetIds.length === 0) {
console.error(
'Error: At least one asset ID is required. Usage: shumai-cli move <assetId...> -p <parentId>',
)
process.exit(1)
}
if (!parentId) {
console.error('Error: Option -p/--parent <parentId> is required.')
process.exit(1)
}
const client = getClient()
try {
// Fetch destination folder to get its projectId
const parentRes = await client.api.folders[':folderId'].$get({
param: { folderId: parentId },
})
if (!parentRes.ok) {
const err = (await parentRes.json().catch(() => ({ error: 'Parent folder not found' }))) as {
error?: string
}
console.error(`Error: ${err.error || 'Parent folder not found'}`)
process.exit(1)
}
const parentInfo = await parentRes.json()
const projectId = parentInfo.projectId
if (!projectId) {
console.error('Error: Destination parent folder is not associated with a project.')
process.exit(1)
}
const res = await client.api.projects[':projectId'].reparent.$post({
param: { projectId },
json: {
assetIds,
newParentId: parentId,
},
})
if (!res.ok) {
const err = (await res.json().catch(() => ({ error: 'Failed to move assets' }))) as {
error?: string
}
console.error(`Error: ${err.error || 'Failed to move assets'}`)
process.exit(1)
}
console.log(`Moved ${assetIds.length} asset(s) to parent ${parentId}`)
} catch (err) {
console.error('Error connecting to API server:', err instanceof Error ? err.message : err)
process.exit(1)
}
}
-42
View File
@@ -1,42 +0,0 @@
import { newTablePrinter } from '@shumai/tableprinter'
import { getClient } from '../client'
export async function projectLs() {
const client = getClient()
try {
const res = await client.api.projects.$get({
query: { first: '200' },
})
if (!res.ok) {
const err = (await res.json().catch(() => ({ error: 'Unknown error' }))) as { error?: string }
console.error(`Error: ${err.error || 'Failed to list projects'}`)
process.exit(1)
}
const { data: projects } = await res.json()
if (projects.length === 0) {
console.log('No projects found.')
return
}
const isTty = process.stdout.isTTY
const maxWidth = process.stdout.columns || 80
const tp = newTablePrinter(process.stdout, isTty, maxWidth)
tp.addHeader(['ID', 'Name', 'Root Folder ID'])
for (const p of projects) {
tp.addField(p.id || '')
tp.addField(p.name || '')
tp.addField(p.rootFolder || '')
tp.endRow()
}
tp.render()
} catch (err) {
console.error('Error connecting to API server:', err instanceof Error ? err.message : err)
process.exit(1)
}
}
-55
View File
@@ -1,55 +0,0 @@
import { getClient } from '../client'
export async function rename(assetId: string, newName: string) {
if (!assetId) {
console.error('Error: Asset ID is required. Usage: shumai-cli rename <assetId> <newName>')
process.exit(1)
}
if (!newName) {
console.error('Error: New name is required. Usage: shumai-cli rename <assetId> <newName>')
process.exit(1)
}
const client = getClient()
try {
// Determine whether asset is a folder or a file
const getRes = await client.api.folders[':folderId'].$get({
param: { folderId: assetId },
})
if (!getRes.ok) {
const err = (await getRes.json().catch(() => ({ error: 'Asset not found' }))) as {
error?: string
}
console.error(`Error: ${err.error || 'Asset not found'}`)
process.exit(1)
}
const asset = await getRes.json()
const isFolder = asset.type === 'folder'
const updateRes = isFolder
? await client.api.folders[':folderId'].$put({
param: { folderId: assetId },
json: { name: newName },
})
: await client.api.files[':fileId'].$put({
param: { fileId: assetId },
json: { name: newName },
})
if (!updateRes.ok) {
const err = (await updateRes.json().catch(() => ({ error: 'Failed to rename asset' }))) as {
error?: string
}
console.error(`Error: ${err.error || 'Failed to rename asset'}`)
process.exit(1)
}
console.log(`Renamed asset ${assetId} to "${newName}"`)
} catch (err) {
console.error('Error connecting to API server:', err instanceof Error ? err.message : err)
process.exit(1)
}
}
+7 -138
View File
@@ -1,140 +1,9 @@
import { projectLs } from './commands/project'
import { ls } from './commands/ls'
import { mkdir } from './commands/mkdir'
import { upload } from './commands/upload'
import { createVersion } from './commands/create-version'
import { rename } from './commands/rename'
import { move } from './commands/move'
import { deleteAsset } from './commands/delete'
import { formatCliError } from './operations/errors'
import { createProgram } from './program'
function printHelp() {
console.log(`
Usage: shumai-cli <command> [arguments] [options]
Commands:
project ls List all projects (returns id, name, root folder id)
ls -p <parentId> List direct children of a parent folder (returns id, name, type, size)
mkdir <name> -p <parentId> Create a new folder in a parent folder
upload <path> -p <parentId> Upload a local file or folder to a parent folder
create-version <path> -p <id> Create a new version of an existing file or version stack
rename <assetId> <newName> Rename an existing file or folder
move <assetIds...> -p <target> Move one or more assets to a destination parent folder (alias: mv)
delete <assetId> Delete a single file or folder (alias: rm)
Options:
-p, --parent <id> The parent folder/asset ID (required for ls, mkdir, upload, create-version, move)
-h, --help Show help details
`)
}
async function main() {
const args = process.argv.slice(2)
if (args.length === 0 || args.includes('-h') || args.includes('--help')) {
printHelp()
process.exit(0)
}
const cmd = args[0]
let parentId = ''
const parentIdx = args.findIndex((a) => a === '-p' || a === '--parent')
if (parentIdx !== -1 && parentIdx + 1 < args.length) {
parentId = args[parentIdx + 1]
}
const cleanArgs: string[] = []
for (let i = 0; i < args.length; i++) {
if (args[i] === '-p' || args[i] === '--parent') {
i++
} else {
cleanArgs.push(args[i])
}
}
if (cmd === 'project' && cleanArgs[1] === 'ls') {
await projectLs()
} else if (cmd === 'ls') {
if (!parentId) {
console.error('Error: Option -p/--parent <parentId> is required.')
process.exit(1)
}
await ls(parentId)
} else if (cmd === 'mkdir') {
const name = cleanArgs[1]
if (!name) {
console.error(
'Error: Folder name is required. Usage: shumai-cli mkdir <folderName> -p <parentId>',
)
process.exit(1)
}
if (!parentId) {
console.error('Error: Option -p/--parent <parentId> is required.')
process.exit(1)
}
await mkdir(name, parentId)
} else if (cmd === 'upload') {
const localPath = cleanArgs[1]
if (!localPath) {
console.error(
'Error: File/folder path is required. Usage: shumai-cli upload <localPath> -p <parentId>',
)
process.exit(1)
}
if (!parentId) {
console.error('Error: Option -p/--parent <parentId> is required.')
process.exit(1)
}
await upload(localPath, parentId)
} else if (cmd === 'create-version') {
const localPath = cleanArgs[1]
if (!localPath) {
console.error(
'Error: Local file path is required. Usage: shumai-cli create-version <localPath> -p <parentAssetId>',
)
process.exit(1)
}
if (!parentId) {
console.error('Error: Option -p/--parent <parentAssetId> is required.')
process.exit(1)
}
await createVersion(localPath, parentId)
} else if (cmd === 'rename') {
const assetId = cleanArgs[1]
const newName = cleanArgs[2]
if (!assetId || !newName) {
console.error(
'Error: Asset ID and new name are required. Usage: shumai-cli rename <assetId> <newName>',
)
process.exit(1)
}
await rename(assetId, newName)
} else if (cmd === 'move' || cmd === 'mv') {
const assetIds = cleanArgs.slice(1)
if (assetIds.length === 0) {
console.error(
'Error: At least one asset ID is required. Usage: shumai-cli move <assetId...> -p <parentId>',
)
process.exit(1)
}
if (!parentId) {
console.error('Error: Option -p/--parent <parentId> is required.')
process.exit(1)
}
await move(assetIds, parentId)
} else if (cmd === 'delete' || cmd === 'rm') {
const assetIds = cleanArgs.slice(1)
if (assetIds.length === 0) {
console.error('Error: Asset ID is required. Usage: shumai-cli delete <assetId>')
process.exit(1)
}
await deleteAsset(assetIds)
} else {
console.error(`Error: Unknown command "${cmd}". Run "shumai-cli --help" for usage.`)
createProgram()
.parseAsync(process.argv)
.catch((err: unknown) => {
console.error(formatCliError(err))
process.exit(1)
}
}
main().catch((err) => {
console.error('Unexpected error:', err)
process.exit(1)
})
})
@@ -0,0 +1,78 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { createFolder, listProjects } from '@shumai/operations'
import { callOperation } from './call-operation'
import { CliError } from './errors'
describe('callOperation', () => {
const env = { ...process.env }
const fetchMock = vi.fn<typeof fetch>()
beforeEach(() => {
process.env.SHUMAI_API_SERVER = 'http://shumai.test/'
process.env.SHUMAI_API_KEY = 'shumai_token'
vi.stubGlobal('fetch', fetchMock)
})
afterEach(() => {
process.env = { ...env }
vi.unstubAllGlobals()
fetchMock.mockReset()
})
const json = (body: unknown, status = 200) =>
new Response(JSON.stringify(body), {
status,
headers: { 'Content-Type': 'application/json' },
})
it('posts the input to /api/ops/:name with the token and CLI attribution', async () => {
const folder = { id: 'f1', name: 'Renders', type: 'folder', size: 0, projectId: 'p1' }
fetchMock.mockResolvedValue(json(folder))
const output = await callOperation(createFolder, { parent: 'root', name: 'Renders' })
expect(output).toEqual(folder)
const [url, init] = fetchMock.mock.calls[0]
expect(url).toBe('http://shumai.test/api/ops/create_folder')
expect(init).toMatchObject({
method: 'POST',
headers: {
Authorization: 'Bearer shumai_token',
'Content-Type': 'application/json',
'x-shumai-client': 'cli',
},
body: JSON.stringify({ parent: 'root', name: 'Renders' }),
})
})
it('throws the server error message', async () => {
fetchMock.mockResolvedValue(json({ error: 'User is not a member of the team' }, 403))
await expect(callOperation(listProjects, {})).rejects.toEqual(
new CliError('User is not a member of the team'),
)
})
it('falls back to the status when the error body is not JSON', async () => {
fetchMock.mockResolvedValue(new Response('Bad gateway', { status: 502 }))
await expect(callOperation(listProjects, {})).rejects.toThrow('Request failed with status 502')
})
it('reports connection failures', async () => {
fetchMock.mockRejectedValue(new TypeError('fetch failed'))
await expect(callOperation(listProjects, {})).rejects.toMatchObject({
message: 'Error connecting to API server: fetch failed',
prefixed: true,
})
})
it('rejects responses that do not match the output schema', async () => {
fetchMock.mockResolvedValue(json({ unexpected: true }))
await expect(callOperation(listProjects, {})).rejects.toThrow(
'Unexpected response from server for list_projects',
)
})
})
+55
View File
@@ -0,0 +1,55 @@
import type { z } from 'zod'
import type { AnyOperationDefinition } from '@shumai/operations'
import { getCliConfig } from '../client'
import { CliError } from './errors'
/** Header that attributes invocations to the CLI (`via: cli`) in audit logs. */
const CLIENT_HEADER = 'x-shumai-client'
/** Signature used by generated commands, which only see type-erased definitions. */
export type CallOperation = (
definition: AnyOperationDefinition,
input: Record<string, unknown>,
) => Promise<unknown>
/** Runs an Operation on the server via `POST /api/ops/:name`. */
export async function callOperation<TDef extends AnyOperationDefinition>(
definition: TDef,
input: z.output<TDef['input']>,
): Promise<z.output<TDef['output']>> {
const { apiServer, apiKey } = getCliConfig()
let res: Response
try {
res = await fetch(`${apiServer}/api/ops/${definition.name}`, {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
[CLIENT_HEADER]: 'cli',
},
body: JSON.stringify(input),
})
} catch (err) {
throw new CliError(
`Error connecting to API server: ${err instanceof Error ? err.message : String(err)}`,
{ prefixed: true },
)
}
const body: unknown = await res.json().catch(() => undefined)
if (!res.ok) {
const message =
body && typeof body === 'object' && 'error' in body && typeof body.error === 'string'
? body.error
: `Request failed with status ${res.status}`
throw new CliError(message)
}
const parsed = definition.output.safeParse(body)
if (!parsed.success) {
throw new CliError(`Unexpected response from server for ${definition.name}`)
}
// safeParse on the generic schema type loses the concrete shape; the schema guarantees it.
return parsed.data as z.output<TDef['output']>
}
+18
View File
@@ -0,0 +1,18 @@
/** An expected failure, printed as `Error: <message>` with exit code 1. */
export class CliError extends Error {
/** When true, the message already carries its own prefix and is printed as-is. */
readonly prefixed: boolean
constructor(message: string, options: { prefixed?: boolean } = {}) {
super(message)
this.name = 'CliError'
this.prefixed = options.prefixed ?? false
}
}
export function formatCliError(err: unknown): string {
if (err instanceof CliError) {
return err.prefixed ? err.message : `Error: ${err.message}`
}
return `Unexpected error: ${err instanceof Error ? err.message : String(err)}`
}
@@ -0,0 +1,103 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { mkdtemp, readFile, readdir, rm, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import * as path from 'node:path'
import type { DownloadAssetOutput } from '@shumai/operations'
import { CliError } from '../errors'
import { downloadAssetExtension, safeFileName, uniquePath } from './download-asset'
const output: DownloadAssetOutput = {
files: [
{
assetId: 'a-1',
name: 'clip.mp4',
kind: 'proxy',
size: 2048,
mimeType: 'video/mp4',
url: 'https://files.example/a-1',
},
{
assetId: 'a-2',
name: 'clip.mp4',
kind: 'original',
size: 10,
mimeType: 'video/mp4',
url: 'https://files.example/a-2',
},
],
}
describe('download CLI extension', () => {
let dir: string
let written: string
beforeEach(async () => {
dir = await mkdtemp(path.join(tmpdir(), 'shumai-cli-download-'))
written = ''
vi.stubGlobal(
'fetch',
vi.fn(async (url: string) => new Response(`bytes of ${url}`, { status: 200 })),
)
})
afterEach(async () => {
vi.unstubAllGlobals()
await rm(dir, { recursive: true, force: true })
})
const o = () => ({ out: { write: (s: string) => void (written += s) }, isTty: true, columns: 80 })
it('saves every file, numbering names that are already taken', async () => {
await writeFile(path.join(dir, 'clip.mp4'), 'existing')
await downloadAssetExtension.present(output, { opts: { out: dir }, json: false, output: o() })
expect((await readdir(dir)).sort()).toEqual(['clip (2).mp4', 'clip (3).mp4', 'clip.mp4'])
expect(await readFile(path.join(dir, 'clip.mp4'), 'utf8')).toBe('existing')
expect(await readFile(path.join(dir, 'clip (2).mp4'), 'utf8')).toBe(
'bytes of https://files.example/a-1',
)
expect(written).toBe(
`Saved ${path.join(dir, 'clip (2).mp4')} (2 KB, proxy)\nSaved ${path.join(dir, 'clip (3).mp4')} (10 B, original)\n`,
)
})
it('creates the folder and prints JSON with the saved paths', async () => {
const out = path.join(dir, 'nested', 'files')
await downloadAssetExtension.present(output, { opts: { out }, json: true, output: o() })
const printed = JSON.parse(written) as { files: Array<{ path: string; url: string }> }
expect(printed.files.map((f) => f.path)).toEqual([
path.join(out, 'clip.mp4'),
path.join(out, 'clip (2).mp4'),
])
expect(printed.files[0].url).toBe('https://files.example/a-1')
})
it('fails clearly when a download fails', async () => {
vi.stubGlobal(
'fetch',
vi.fn(async () => new Response('gone', { status: 403 })),
)
await expect(
downloadAssetExtension.present(output, { opts: { out: dir }, json: false, output: o() }),
).rejects.toThrow(new CliError('Failed to download "clip.mp4" (status 403).'))
})
it('keeps file names inside the target folder', () => {
expect(safeFileName('../../etc/passwd')).toBe('_.._etc_passwd')
expect(safeFileName('a\\b.txt')).toBe('a_b.txt')
expect(safeFileName('...')).toBe('file')
const taken = new Set<string>()
expect(uniquePath(dir, 'notes', taken)).toBe(path.join(dir, 'notes'))
expect(uniquePath(dir, 'notes', taken)).toBe(path.join(dir, 'notes (2)'))
})
it('maps --original to proxy false', () => {
expect(downloadAssetExtension.toInput!({ assetIds: ['a'] }, { original: true })).toEqual({
assetIds: ['a'],
proxy: false,
})
expect(downloadAssetExtension.toInput!({ assetIds: ['a'] }, {})).toEqual({ assetIds: ['a'] })
})
})
@@ -0,0 +1,58 @@
import { existsSync } from 'node:fs'
import { mkdir } from 'node:fs/promises'
import * as path from 'node:path'
import { Option } from 'commander'
import type { DownloadAssetOutput } from '@shumai/operations'
import type { CliCommandExtension } from '../generate'
import { formatSize } from '../render'
import { saveUrlToFile } from './save-url'
/** A file name that is safe to create inside the target folder (no paths or control chars). */
export function safeFileName(name: string): string {
const safe = name
// eslint-disable-next-line no-control-regex
.replace(/[\x00-\x1f\x7f/\\]/g, '_')
.replace(/^[\s.]+|[\s.]+$/g, '')
return safe || 'file'
}
/** `name.ext`, or `name (2).ext`, `name (3).ext`, ... if taken on disk or in this download. */
export function uniquePath(dir: string, name: string, taken: Set<string>): string {
const ext = path.extname(name)
const stem = ext ? name.slice(0, -ext.length) : name
for (let n = 1; ; n++) {
const candidate = path.join(dir, n === 1 ? name : `${stem} (${n})${ext}`)
if (!taken.has(candidate) && !existsSync(candidate)) {
taken.add(candidate)
return candidate
}
}
}
/** `download`: saves each file into `--out` (the current folder by default). */
export const downloadAssetExtension: CliCommandExtension = {
options: () => [
new Option('-o, --out <dir>', 'Folder to save the files in.').default('.'),
new Option('--original', 'Download the original uploaded files instead of the web previews.'),
],
toInput: (input, opts) => (opts.original === true ? { ...input, proxy: false } : input),
async present(raw, { opts, json, output: o }) {
const output = raw as DownloadAssetOutput
const dir = typeof opts.out === 'string' ? opts.out : '.'
await mkdir(dir, { recursive: true })
const taken = new Set<string>()
const saved: string[] = []
for (const file of output.files) {
const filePath = uniquePath(dir, safeFileName(file.name), taken)
await saveUrlToFile(file.url, filePath, file.name)
saved.push(filePath)
if (!json) {
o.out.write(`Saved ${filePath} (${formatSize(file.size)}, ${file.kind})\n`)
}
}
if (json) {
const files = output.files.map((file, i) => ({ ...file, path: saved[i] }))
o.out.write(`${JSON.stringify({ files }, null, 2)}\n`)
}
},
}
@@ -0,0 +1,10 @@
import type { CliCommandExtension } from '../generate'
import { downloadAssetExtension } from './download-asset'
import { getAssetRenderExtension, readAssetExtension } from './read-asset'
/** CLI-specific behavior for generated commands, by Operation name. */
export const cliExtensions: ReadonlyMap<string, CliCommandExtension> = new Map([
['read_asset', readAssetExtension],
['get_asset_render', getAssetRenderExtension],
['download_asset', downloadAssetExtension],
])
@@ -0,0 +1,98 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { mkdtemp, readFile, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import * as path from 'node:path'
import type { AssetReadOutput } from '@shumai/operations'
import { CliError } from '../errors'
import { downloadImages, imageFileName, readAssetExtension } from './read-asset'
const output: AssetReadOutput = {
status: 'ready',
summary: 'Rendered 2 page(s) of "deck.pdf" (Pages 1 to 2):',
asset: { id: 'doc-1', name: 'deck.pdf', kind: 'document', mediaType: 'application/pdf' },
details: [],
images: [
{ label: 'Page 1', mimeType: 'image/webp', url: 'https://files.example/p1' },
{ label: 'Page 2', mimeType: 'image/png', url: 'https://files.example/p2' },
],
}
describe('read / render CLI extension', () => {
let dir: string
let written: string
beforeEach(async () => {
dir = await mkdtemp(path.join(tmpdir(), 'shumai-cli-read-'))
written = ''
vi.stubGlobal(
'fetch',
vi.fn(async (url: string) => new Response(`bytes of ${url}`, { status: 200 })),
)
})
afterEach(async () => {
vi.unstubAllGlobals()
await rm(dir, { recursive: true, force: true })
})
const o = () => ({ out: { write: (s: string) => void (written += s) }, isTty: true, columns: 80 })
it('names files after the asset, position, and label', () => {
expect(imageFileName('vid-1', 0, { label: 'Frame at 2.5s', mimeType: 'image/webp' })).toBe(
'vid-1-1-frame-at-2.5s.webp',
)
expect(imageFileName('m-1', 3, { label: 'View at 90°', mimeType: 'image/jpeg' })).toBe(
'm-1-4-view-at-90.jpg',
)
})
it('downloads every image with --out and prints the saved paths', async () => {
const out = path.join(dir, 'pages')
await readAssetExtension.present(output, { opts: { out }, json: false, output: o() })
const first = path.join(out, 'doc-1-1-page-1.webp')
const second = path.join(out, 'doc-1-2-page-2.png')
expect(await readFile(first, 'utf8')).toBe('bytes of https://files.example/p1')
expect(await readFile(second, 'utf8')).toBe('bytes of https://files.example/p2')
expect(written).toBe(`${output.summary}\n- Page 1: ${first}\n- Page 2: ${second}\n`)
})
it('adds the saved path to each image in --json mode', async () => {
await readAssetExtension.present(output, { opts: { out: dir }, json: true, output: o() })
const printed = JSON.parse(written) as { images: Array<{ path: string }> }
expect(printed.images.map((i) => i.path)).toEqual([
path.join(dir, 'doc-1-1-page-1.webp'),
path.join(dir, 'doc-1-2-page-2.png'),
])
})
it('fails clearly when a download fails', async () => {
vi.stubGlobal(
'fetch',
vi.fn(async () => new Response('gone', { status: 403 })),
)
await expect(downloadImages(output, dir)).rejects.toThrow(
new CliError('Failed to download "Page 1" (status 403).'),
)
})
it('does not download anything for a pending render', async () => {
await readAssetExtension.present(
{ ...output, status: 'pending', images: [], taskId: 't-1', retryAfterSeconds: 5 },
{ opts: { out: dir }, json: false, output: o() },
)
expect(fetch).not.toHaveBeenCalled()
expect(written).toContain(`shumai-cli render t-1 --out ${JSON.stringify(dir)}`)
})
it('maps --no-wait to maxWaitSeconds 0', () => {
expect(readAssetExtension.toInput!({ assetId: 'a' }, { wait: false })).toEqual({
assetId: 'a',
maxWaitSeconds: 0,
})
expect(readAssetExtension.toInput!({ assetId: 'a' }, { wait: true })).toEqual({
assetId: 'a',
})
})
})
@@ -0,0 +1,116 @@
import { mkdir } from 'node:fs/promises'
import * as path from 'node:path'
import { Option } from 'commander'
import type { AssetReadOutput } from '@shumai/operations'
import { CliError } from '../errors'
import { saveUrlToFile } from './save-url'
import type { CliCommandExtension } from '../generate'
import type { Output } from '../render'
const EXTENSIONS: Record<string, string> = {
'image/webp': 'webp',
'image/png': 'png',
'image/jpeg': 'jpg',
'image/gif': 'gif',
'image/avif': 'avif',
}
function slug(value: string): string {
return (
value
.toLowerCase()
.replace(/[^a-z0-9.]+/g, '-')
.replace(/^-+|-+$/g, '') || 'image'
)
}
/** File name for the n-th image of a read, e.g. `01ABC-1-frame-at-2s.webp`. */
export function imageFileName(
assetId: string,
index: number,
image: AssetReadOutput['images'][number],
): string {
const ext = EXTENSIONS[image.mimeType] ?? image.mimeType.split('/')[1] ?? 'bin'
return `${assetId}-${index + 1}-${slug(image.label).replace(/\.+$/, '')}.${ext}`
}
/** Downloads every image of a ready read into `dir`; returns the saved paths in order. */
export async function downloadImages(output: AssetReadOutput, dir: string): Promise<string[]> {
await mkdir(dir, { recursive: true })
const saved: string[] = []
for (const [index, image] of output.images.entries()) {
if (!image.url) {
throw new CliError(`No download link was returned for "${image.label}".`)
}
const filePath = path.join(dir, imageFileName(output.asset.id, index, image))
await saveUrlToFile(image.url, filePath, image.label)
saved.push(filePath)
}
return saved
}
function renderCommand(taskId: string, out: unknown): string {
const outArg = typeof out === 'string' ? ` --out ${JSON.stringify(out)}` : ''
return `shumai-cli render ${taskId}${outArg}`
}
function writeReady(output: AssetReadOutput, paths: string[] | null, o: Output): void {
const lines = [output.summary, ...output.details]
output.images.forEach((image, i) => {
lines.push(`- ${image.label}: ${paths ? paths[i] : (image.url ?? '')}`)
})
o.out.write(`${lines.join('\n')}\n`)
if (output.text) {
o.out.write(`\n${output.text.content}`)
if (!output.text.content.endsWith('\n')) o.out.write('\n')
if (output.text.truncated) {
o.out.write(
`\n[Content truncated: showing the first part of a ${output.text.size}-byte file. Run \`shumai-cli download ${output.asset.id}\` to get the whole file.]\n`,
)
}
}
}
/**
* `read` and `render`: images are printed as links (valid for about an hour) or downloaded
* with `--out`; a render that takes longer than the wait prints the `render` command to run.
*/
function readExtension(noWaitHelp: string): CliCommandExtension {
return {
options: () => [
new Option('-o, --out <dir>', 'Download the images into this folder and print their paths.'),
new Option('--no-wait', noWaitHelp),
],
toInput: (input, opts) => (opts.wait === false ? { ...input, maxWaitSeconds: 0 } : input),
async present(raw, { opts, json, output: o }) {
const output = raw as AssetReadOutput
if (output.status === 'pending') {
if (json) {
o.out.write(`${JSON.stringify(output, null, 2)}\n`)
return
}
o.out.write(
`${output.summary}\nRun this to get the result: ${renderCommand(output.taskId ?? '', opts.out)}\n`,
)
return
}
const paths = typeof opts.out === 'string' ? await downloadImages(output, opts.out) : null
if (json) {
const images = output.images.map((image, i) =>
paths ? { ...image, path: paths[i] } : image,
)
o.out.write(`${JSON.stringify({ ...output, images }, null, 2)}\n`)
return
}
writeReady(output, paths, o)
},
}
}
export const readAssetExtension = readExtension(
'Return right away with a task ID if the asset needs rendering.',
)
export const getAssetRenderExtension = readExtension(
'Check once and return right away if the render is still running.',
)
@@ -0,0 +1,32 @@
import { createWriteStream } from 'node:fs'
import { rm } from 'node:fs/promises'
import { Readable } from 'node:stream'
import { pipeline } from 'node:stream/promises'
import type { ReadableStream as WebReadableStream } from 'node:stream/web'
import { CliError } from '../errors'
/** Streams a download link to `filePath` (large files never sit in memory). */
export async function saveUrlToFile(url: string, filePath: string, label: string): Promise<void> {
let res: Response
try {
res = await fetch(url)
} catch (err) {
throw new CliError(
`Failed to download "${label}": ${err instanceof Error ? err.message : String(err)}`,
)
}
if (!res.ok || !res.body) {
throw new CliError(`Failed to download "${label}" (status ${res.status}).`)
}
try {
await pipeline(
Readable.fromWeb(res.body as unknown as WebReadableStream<Uint8Array>),
createWriteStream(filePath),
)
} catch (err) {
await rm(filePath, { force: true })
throw new CliError(
`Failed to save "${label}" to ${filePath}: ${err instanceof Error ? err.message : String(err)}`,
)
}
}
+269
View File
@@ -0,0 +1,269 @@
import { Command, InvalidArgumentError, Option } from 'commander'
import { z } from 'zod'
import type { AnyOperationDefinition } from '@shumai/operations'
import type { CallOperation } from './call-operation'
import { CliError } from './errors'
import { renderOutput, type Output } from './render'
/**
* CLI-specific behavior for one Operation's command, for things a definition can't describe
* (it must stay free of I/O): extra options, input mapping, and output that downloads files.
*/
export interface CliCommandExtension {
/** Extra options only the CLI has; their values are passed to `toInput` and `present`. */
options?(): Option[]
/** Adjust the Operation input using the command's options. */
toInput?(input: Record<string, unknown>, opts: Record<string, unknown>): Record<string, unknown>
/** Writes the output, including in `--json` mode. Replaces the default rendering. */
present(
output: unknown,
ctx: { opts: Record<string, unknown>; json: boolean; output: Output },
): Promise<void>
}
export interface GenerateDeps {
callOperation: CallOperation
output: Output
/** Whether destructive Operations are allowed (SHUMAI_ALLOW_DELETE). */
allowDestructive: () => boolean
/** CLI extensions by Operation name. */
extensions?: ReadonlyMap<string, CliCommandExtension>
}
type FieldKind =
| { type: 'string' }
| { type: 'number' }
| { type: 'boolean' }
| { type: 'enum'; values: string[] }
| { type: 'array' }
/** A key/value object (`z.record`), passed as a JSON object. */
| { type: 'json' }
interface FieldInfo {
name: string
kind: FieldKind
required: boolean
description: string
}
/** Strip optional/nullable/default wrappers to find the field's base schema. */
function unwrap(schema: z.ZodType): z.ZodType {
let current = schema
while (
current instanceof z.ZodOptional ||
current instanceof z.ZodNullable ||
current instanceof z.ZodDefault
) {
current = current.unwrap() as z.ZodType
}
return current
}
function describeField(definition: AnyOperationDefinition, name: string): FieldInfo {
return describeSchema(definition, name, definition.input.shape[name] as z.ZodType)
}
function describeSchema(
definition: AnyOperationDefinition,
name: string,
schema: z.ZodType,
): FieldInfo {
const base = unwrap(schema)
let kind: FieldKind
if (base instanceof z.ZodNumber) kind = { type: 'number' }
else if (base instanceof z.ZodBoolean) kind = { type: 'boolean' }
else if (base instanceof z.ZodEnum) kind = { type: 'enum', values: base.options.map(String) }
else if (base instanceof z.ZodArray) kind = { type: 'array' }
else if (base instanceof z.ZodString) kind = { type: 'string' }
else if (base instanceof z.ZodRecord) kind = { type: 'json' }
else {
throw new Error(`${definition.name}.${name}: unsupported input type for the CLI`)
}
return {
name,
kind,
required: !schema.safeParse(undefined).success,
description: schema.description ?? base.description ?? '',
}
}
/**
* Input errors name the input path (e.g. `videoConfig.end`). For flattened fields, name the
* flag the user typed instead (e.g. `--video-end`).
*/
function formatInputError(
error: z.ZodError,
options: ReadonlyArray<{ path: [string] | [string, string]; option: Option }>,
): string {
const flagFor = (path: PropertyKey[]): string | undefined =>
options.find((o) => o.path.length === 2 && o.path[0] === path[0] && o.path[1] === path[1])
?.option.long
if (!error.issues.some((issue) => flagFor(issue.path))) {
return z.prettifyError(error)
}
return error.issues
.map((issue) => {
const flag = flagFor(issue.path)
return flag ? `✖ ${flag}: ${issue.message}` : z.prettifyError(new z.ZodError([issue]))
})
.join('\n')
}
function parseNumber(value: string): number {
const parsed = Number(value)
if (value.trim() === '' || Number.isNaN(parsed)) {
throw new InvalidArgumentError('Not a number.')
}
return parsed
}
function parseJsonObject(value: string): Record<string, unknown> {
let parsed: unknown
try {
parsed = JSON.parse(value)
} catch {
throw new InvalidArgumentError('Not valid JSON.')
}
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
throw new InvalidArgumentError('Expected a JSON object, e.g. \'{"key": "value"}\'.')
}
return parsed as Record<string, unknown>
}
function kebab(name: string): string {
return name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)
}
/** Find or create the subcommand path, e.g. `project` for `project ls`. */
function ensureParent(program: Command, path: readonly string[]): Command {
let parent = program
for (const segment of path) {
parent =
parent.commands.find((c) => c.name() === segment) ??
parent.command(segment).description(`Manage ${segment}s.`)
}
return parent
}
/** Registers one command for each definition with a `cli` spec. */
export function registerOperationCommands(
program: Command,
definitions: readonly AnyOperationDefinition[],
deps: GenerateDeps,
): void {
for (const definition of definitions) {
const cli = definition.cli
if (!cli || !definition.surfaces.includes('cli')) continue
const parent = ensureParent(program, cli.command.slice(0, -1))
const cmd = parent
.command(cli.command[cli.command.length - 1])
.description(cli.description ?? definition.description)
if (cli.aliases) cmd.aliases([...cli.aliases])
const positional = (cli.positional ?? []).map((name) => describeField(definition, name))
for (const field of positional) {
const placeholder = field.kind.type === 'array' ? `${field.name}...` : field.name
cmd.argument(field.required ? `<${placeholder}>` : `[${placeholder}]`, field.description)
}
const positionalNames = new Set(positional.map((f) => f.name))
const omitted = new Set<string>(cli.omit ?? [])
const flatten = (cli.flatten ?? {}) as Record<string, string | undefined>
// `path` is where the value goes in the input: `[field]` or `[field, subField]`.
const options: Array<{ path: [string] | [string, string]; option: Option }> = []
const addOption = (
path: [string] | [string, string],
field: FieldInfo,
spellings: readonly string[],
) => {
const valueHint =
field.kind.type === 'boolean'
? ''
: field.kind.type === 'array'
? ` <${field.name}...>`
: field.kind.type === 'json'
? ` <json>`
: ` <${field.name}>`
const option = new Option(`${spellings.join(', ')}${valueHint}`, field.description)
if (field.kind.type === 'number') option.argParser(parseNumber)
if (field.kind.type === 'json') option.argParser(parseJsonObject)
if (field.kind.type === 'enum') option.choices(field.kind.values)
if (field.required) option.makeOptionMandatory()
cmd.addOption(option)
options.push({ path, option })
return option
}
for (const name of Object.keys(definition.input.shape)) {
if (positionalNames.has(name) || omitted.has(name)) continue
const prefix = flatten[name]
if (prefix !== undefined) {
const schema = definition.input.shape[name] as z.ZodType
const base = unwrap(schema)
if (!(base instanceof z.ZodObject)) {
throw new Error(`${definition.name}.${name}: only object fields can be flattened`)
}
const parentRequired = !schema.safeParse(undefined).success
for (const [subName, subSchema] of Object.entries(base.shape)) {
const field = describeSchema(definition, `${name}.${subName}`, subSchema as z.ZodType)
field.name = subName
// Sub-fields are only mandatory when the object itself is.
field.required = parentRequired && field.required
const flag = prefix ? `--${prefix}-${kebab(subName)}` : `--${kebab(subName)}`
addOption([name, subName], field, [flag])
}
continue
}
const field = describeField(definition, name)
const option = addOption([name], field, cli.flags?.[name] ?? [`--${kebab(name)}`])
const cliDefault = (cli.defaults as Record<string, unknown> | undefined)?.[name]
if (cliDefault !== undefined) option.default(cliDefault)
}
const extension = deps.extensions?.get(definition.name)
for (const option of extension?.options?.() ?? []) cmd.addOption(option)
cmd.action(async (...args: unknown[]) => {
const command = args[args.length - 1] as Command
const input: Record<string, unknown> = { ...cli.defaults }
positional.forEach((field, i) => {
if (args[i] !== undefined) input[field.name] = args[i]
})
const opts = command.opts()
for (const { path, option } of options) {
const value = opts[option.attributeName()]
if (value === undefined) continue
if (path.length === 1) {
input[path[0]] = value
} else {
const parent = (input[path[0]] ?? {}) as Record<string, unknown>
input[path[0]] = { ...parent, [path[1]]: value }
}
}
if (definition.annotations.destructive && !deps.allowDestructive()) {
throw new CliError(
`${definition.title} is disabled in this environment. Set SHUMAI_ALLOW_DELETE=true to enable it.`,
)
}
const parsed = definition.input.safeParse(
extension?.toInput ? extension.toInput(input, opts) : input,
)
if (!parsed.success) {
throw new CliError(formatInputError(parsed.error, options))
}
const output = await deps.callOperation(definition, parsed.data)
const json = Boolean(command.optsWithGlobals().json)
if (extension) {
await extension.present(output, { opts, json, output: deps.output })
} else if (json) {
deps.output.out.write(`${JSON.stringify(output, null, 2)}\n`)
} else {
renderOutput(definition, output, deps.output)
}
})
}
}
+68
View File
@@ -0,0 +1,68 @@
import { describe, expect, it } from 'vitest'
import { z } from 'zod'
import { defineOperation, listAssets, renameAsset } from '@shumai/operations'
import { formatSize, renderOutput, type Output } from './render'
function capture(isTty = true): Output & { text: () => string } {
let text = ''
return { out: { write: (s) => void (text += s) }, isTty, columns: 120, text: () => text }
}
const page = {
data: [{ id: 'd1', name: 'Renders', type: 'folder', size: 0, projectId: 'p' }],
pageInfo: { hasNextPage: true, endCursor: 'CUR' },
total: 2,
}
describe('renderOutput', () => {
it('shows the next-page cursor only on a terminal', () => {
const tty = capture(true)
renderOutput(listAssets, page, tty)
expect(tty.text()).toContain('Next page: --after CUR')
const piped = capture(false)
renderOutput(listAssets, page, piped)
expect(piped.text()).toBe('d1\tRenders\tfolder\t-\n')
})
it('uses the definition formatter when there is no table renderer', () => {
const o = capture()
renderOutput(renameAsset, { id: 'a1', name: 'new', type: 'file', size: 1, projectId: null }, o)
expect(o.text()).toBe('Renamed asset a1 to "new"\n')
})
it('falls back to tables for lists and key/value lines for objects', () => {
const generic = defineOperation({
name: 'generic_thing',
title: 'Generic',
description: 'Generic output.',
input: z.object({}),
output: z.unknown(),
surfaces: ['agent'],
annotations: { readOnly: true, destructive: false },
})
const list = capture(false)
renderOutput(generic, { data: [{ id: 'x', tags: ['a'] }] }, list)
expect(list.text()).toBe('x\t["a"]\n')
const empty = capture()
renderOutput(generic, [], empty)
expect(empty.text()).toBe('No results.\n')
const object = capture()
renderOutput(generic, { id: 'x', count: 2, note: null }, object)
expect(object.text()).toBe('id: x\ncount: 2\nnote: \n')
})
})
describe('formatSize', () => {
it.each([
[0, '-'],
[512, '512 B'],
[1536, '1.5 KB'],
[5 * 1024 * 1024, '5 MB'],
])('formats %d bytes as %s', (bytes, expected) => {
expect(formatSize(bytes)).toBe(expected)
})
})
+121
View File
@@ -0,0 +1,121 @@
import { newTablePrinter, withTruncate, type Writer } from '@shumai/tableprinter'
import type {
AnyOperationDefinition,
AssetSummary,
PageInfo,
ProjectSummary,
} from '@shumai/operations'
export interface Output {
out: Writer
isTty: boolean
columns: number
}
export function formatSize(bytes: number): string {
if (bytes === 0) return '-'
const k = 1024
const sizes = ['B', 'KB', 'MB', 'GB', 'TB']
const i = Math.floor(Math.log(bytes) / Math.log(k))
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
}
function renderAssets(output: { data: AssetSummary[]; pageInfo: PageInfo }, o: Output): void {
if (output.data.length === 0) {
o.out.write('No assets found in this folder.\n')
return
}
// Folders first, as in the file browser's default listing
const items = [...output.data].sort(
(a, b) => Number(b.type === 'folder') - Number(a.type === 'folder'),
)
const tp = newTablePrinter(o.out, o.isTty, o.columns)
tp.addHeader(['ID', 'Name', 'Type', 'Size'])
for (const item of items) {
const isFolder = item.type === 'folder'
tp.addField(item.id, withTruncate(null))
tp.addField(item.name)
tp.addField(isFolder ? 'folder' : 'file', withTruncate(null))
tp.addField(isFolder ? '-' : formatSize(item.size), withTruncate(null))
tp.endRow()
}
tp.render()
// Piped output is TSV for scripts (use --json for pagination metadata); keep it clean.
if (o.isTty && output.pageInfo.hasNextPage && output.pageInfo.endCursor) {
o.out.write(`\nMore assets available. Next page: --after ${output.pageInfo.endCursor}\n`)
}
}
function renderProjects(output: { data: ProjectSummary[] }, o: Output): void {
if (output.data.length === 0) {
o.out.write('No projects found.\n')
return
}
const tp = newTablePrinter(o.out, o.isTty, o.columns)
tp.addHeader(['ID', 'Name', 'Root Folder ID'])
for (const p of output.data) {
tp.addField(p.id)
tp.addField(p.name)
tp.addField(p.rootFolderId ?? '')
tp.endRow()
}
tp.render()
}
/** Table renderers for list Operations; other Operations use their `cli.format` or the fallback. */
const tableRenderers = new Map<string, (output: never, o: Output) => void>([
['list_assets', renderAssets],
['list_projects', renderProjects],
])
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null && !Array.isArray(value)
}
function cell(value: unknown): string {
if (value === null || value === undefined) return ''
return typeof value === 'object' ? JSON.stringify(value) : String(value)
}
/** Generic rendering: `{ data: [...] }` and arrays as tables, objects as `key: value` lines. */
function renderFallback(output: unknown, o: Output): void {
const rows = Array.isArray(output)
? output
: isRecord(output) && Array.isArray(output.data)
? output.data
: null
if (rows) {
if (rows.length === 0) {
o.out.write('No results.\n')
return
}
const keys = Object.keys(isRecord(rows[0]) ? rows[0] : { value: rows[0] })
const tp = newTablePrinter(o.out, o.isTty, o.columns)
tp.addHeader(keys)
for (const row of rows) {
for (const key of keys) tp.addField(cell(isRecord(row) ? row[key] : row))
tp.endRow()
}
tp.render()
return
}
if (isRecord(output)) {
for (const [key, value] of Object.entries(output)) o.out.write(`${key}: ${cell(value)}\n`)
return
}
o.out.write(`${cell(output)}\n`)
}
/** Writes an Operation's output in human-friendly form. */
export function renderOutput(definition: AnyOperationDefinition, output: unknown, o: Output): void {
const table = tableRenderers.get(definition.name)
if (table) {
table(output as never, o)
return
}
if (definition.cli?.format) {
o.out.write(`${definition.cli.format(output)}\n`)
return
}
renderFallback(output, o)
}
+844
View File
@@ -0,0 +1,844 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type { Command } from 'commander'
import {
copyAssets,
createComment,
createFolder,
createVersionStack,
deleteAsset,
downloadAsset,
getAssetRender,
getFolderInstructions,
readAsset,
listAssets,
listComments,
listMetadataFields,
listProjects,
listVersions,
moveAssets,
removeVersion,
renameAsset,
resolveComment,
searchAssets,
updateAssetMetadata,
} from '@shumai/operations'
import type { CallOperation } from './operations/call-operation'
import { CliError, formatCliError } from './operations/errors'
import { createProgram } from './program'
/** Runs the CLI with mocked Operation calls and captures stdout/stderr. */
function setup() {
let stdout = ''
let stderr = ''
const callOperation = vi.fn<CallOperation>()
const program = createProgram({
callOperation,
output: { out: { write: (s) => void (stdout += s) }, isTty: true, columns: 120 },
})
const configure = (cmd: Command) => {
cmd.exitOverride().configureOutput({
writeOut: (s) => void (stdout += s),
writeErr: (s) => void (stderr += s),
})
cmd.commands.forEach(configure)
}
configure(program)
return {
callOperation,
run: (...argv: string[]) => program.parseAsync(['node', 'shumai-cli', ...argv]),
stdout: () => stdout,
stderr: () => stderr,
}
}
const folder = { id: 'f-1', name: 'Renders', type: 'folder', size: 0, projectId: 'p-1' }
const frames = {
status: 'ready',
summary: 'Extracted 2 frame(s) from "clip.mp4" (0s - 4s):',
asset: { id: 'vid-1', name: 'clip.mp4', kind: 'video', mediaType: 'video/mp4' },
details: [],
images: [
{ label: 'Frame at 0s', mimeType: 'image/webp', url: 'https://files.example/0.webp' },
{ label: 'Frame at 4s', mimeType: 'image/webp', url: 'https://files.example/4.webp' },
],
}
const pendingRead = {
status: 'pending',
summary: 'Rendering is still in progress for "clip.mp4".',
asset: frames.asset,
details: [],
images: [],
taskId: 'task-1',
retryAfterSeconds: 5,
}
describe('shumai-cli', () => {
const originalAllowDelete = process.env.SHUMAI_ALLOW_DELETE
afterEach(() => {
if (originalAllowDelete === undefined) delete process.env.SHUMAI_ALLOW_DELETE
else process.env.SHUMAI_ALLOW_DELETE = originalAllowDelete
})
describe('project ls', () => {
it('lists projects with their root folder', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue({
data: [
{ id: 'p1', name: 'Proj 1', teamId: 't1', rootFolderId: 'root1' },
{ id: 'p2', name: 'Proj 2', teamId: 't1', rootFolderId: 'root2' },
],
})
await cli.run('project', 'ls')
expect(cli.callOperation).toHaveBeenCalledWith(listProjects, {})
expect(cli.stdout()).toContain('Root Folder ID')
expect(cli.stdout()).toMatch(/p1\s+Proj 1\s+root1/)
expect(cli.stdout()).toContain('Proj 2')
})
it('reports when there are no projects', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue({ data: [] })
await cli.run('project', 'ls')
expect(cli.stdout()).toBe('No projects found.\n')
})
})
describe('ls', () => {
it('lists a folder with the maximum page size, folders first', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue({
data: [
{ id: 'file1', name: 'doc.pdf', type: 'file', size: 1024, projectId: 'p' },
{ id: 'sub1', name: 'Sub 1', type: 'folder', size: 0, projectId: 'p' },
],
pageInfo: { hasNextPage: false, endCursor: null },
total: 2,
})
await cli.run('ls', '-p', 'parentId123')
expect(cli.callOperation).toHaveBeenCalledWith(listAssets, {
parent: 'parentId123',
first: 200,
})
const out = cli.stdout()
expect(out.indexOf('Sub 1')).toBeLessThan(out.indexOf('doc.pdf'))
expect(out).toMatch(/file1\s+doc\.pdf\s+file\s+1 KB/)
expect(out).not.toContain('More assets available')
})
it('passes pagination and type flags and prints the next-page cursor', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue({
data: [{ id: 'sub1', name: 'Sub 1', type: 'folder', size: 0, projectId: 'p' }],
pageInfo: { hasNextPage: true, endCursor: 'cur-2' },
total: 3,
})
await cli.run('ls', '--parent', 'p1', '--type', 'folder', '--first', '1', '--after', 'cur-1')
expect(cli.callOperation).toHaveBeenCalledWith(listAssets, {
parent: 'p1',
type: 'folder',
first: 1,
after: 'cur-1',
})
expect(cli.stdout()).toContain('Next page: --after cur-2')
})
it('requires the parent option', async () => {
const cli = setup()
await expect(cli.run('ls')).rejects.toThrow()
expect(cli.stderr()).toContain("required option '-p, --parent <parent>' not specified")
expect(cli.callOperation).not.toHaveBeenCalled()
})
it('rejects an invalid type and a non-numeric page size', async () => {
const cli = setup()
await expect(cli.run('ls', '-p', 'x', '--type', 'video')).rejects.toThrow()
expect(cli.stderr()).toContain('Allowed choices are file, folder, all')
await expect(cli.run('ls', '-p', 'x', '--first', 'many')).rejects.toThrow()
expect(cli.stderr()).toContain('Not a number')
expect(cli.callOperation).not.toHaveBeenCalled()
})
})
describe('mkdir', () => {
it('creates a folder and prints its ID', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue({ ...folder, id: 'new_folder_ulid' })
await cli.run('mkdir', 'NewFolder', '-p', 'parent_ulid')
expect(cli.callOperation).toHaveBeenCalledWith(createFolder, {
name: 'NewFolder',
parent: 'parent_ulid',
})
expect(cli.stdout()).toBe('Created folder with ID: new_folder_ulid\n')
})
it('requires a folder name', async () => {
const cli = setup()
await expect(cli.run('mkdir', '-p', 'parent_ulid')).rejects.toThrow()
expect(cli.stderr()).toContain("missing required argument 'name'")
})
})
describe('rename', () => {
it('renames an asset', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue({ ...folder, name: 'Renamed Folder' })
await cli.run('rename', 'f-1', 'Renamed Folder')
expect(cli.callOperation).toHaveBeenCalledWith(renameAsset, {
assetId: 'f-1',
name: 'Renamed Folder',
})
expect(cli.stdout()).toBe('Renamed asset f-1 to "Renamed Folder"\n')
})
it('requires both the asset ID and the new name', async () => {
const cli = setup()
await expect(cli.run('rename', 'f-1')).rejects.toThrow()
expect(cli.stderr()).toContain("missing required argument 'name'")
})
})
describe('move', () => {
it.each(['move', 'mv'])('moves assets with %s', async (command) => {
const cli = setup()
cli.callOperation.mockResolvedValue({
movedAssetIds: ['a-1', 'a-2'],
newParentId: 'parent-1',
})
await cli.run(command, 'a-1', 'a-2', '-p', 'parent-1')
expect(cli.callOperation).toHaveBeenCalledWith(moveAssets, {
assetIds: ['a-1', 'a-2'],
newParentId: 'parent-1',
})
expect(cli.stdout()).toBe('Moved 2 asset(s) to parent parent-1\n')
})
it('requires at least one asset and a destination', async () => {
const cli = setup()
await expect(cli.run('move', '-p', 'parent-1')).rejects.toThrow()
expect(cli.stderr()).toContain("missing required argument 'assetIds'")
await expect(cli.run('move', 'a-1')).rejects.toThrow()
expect(cli.stderr()).toContain("required option '-p, --parent <newParentId>' not specified")
})
})
describe('delete', () => {
it.each([undefined, 'false'])(
'refuses to delete when SHUMAI_ALLOW_DELETE is %s',
async (value) => {
if (value === undefined) delete process.env.SHUMAI_ALLOW_DELETE
else process.env.SHUMAI_ALLOW_DELETE = value
const cli = setup()
const error = await cli.run('delete', 'a-1').catch((err: unknown) => err)
expect(formatCliError(error)).toBe(
'Error: Delete Asset is disabled in this environment. Set SHUMAI_ALLOW_DELETE=true to enable it.',
)
expect(cli.callOperation).not.toHaveBeenCalled()
},
)
it.each([
['delete', 'true'],
['rm', '1'],
])('deletes with %s when SHUMAI_ALLOW_DELETE=%s', async (command, value) => {
process.env.SHUMAI_ALLOW_DELETE = value
const cli = setup()
cli.callOperation.mockResolvedValue({ deletedAssetId: 'a-1' })
await cli.run(command, 'a-1')
expect(cli.callOperation).toHaveBeenCalledWith(deleteAsset, { assetId: 'a-1' })
expect(cli.stdout()).toBe('Deleted asset a-1\n')
})
it('deletes only one asset at a time', async () => {
process.env.SHUMAI_ALLOW_DELETE = 'true'
const cli = setup()
await expect(cli.run('delete', 'a-1', 'a-2')).rejects.toThrow()
expect(cli.stderr()).toContain('too many arguments')
expect(cli.callOperation).not.toHaveBeenCalled()
})
})
describe('read', () => {
it('maps flattened reader flags onto the config objects and prints image links', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue(frames)
await cli.run(
'read',
'vid-1',
'--video-start',
'0',
'--video-end',
'4',
'--video-count',
'2',
'--annotation-id',
'c-1',
)
expect(cli.callOperation).toHaveBeenCalledWith(readAsset, {
assetId: 'vid-1',
annotationId: 'c-1',
videoConfig: { start: 0, end: 4, count: 2 },
})
expect(cli.stdout()).toBe(
[
'Extracted 2 frame(s) from "clip.mp4" (0s - 4s):',
'- Frame at 0s: https://files.example/0.webp',
'- Frame at 4s: https://files.example/4.webp',
'',
].join('\n'),
)
})
it.each([
[
['--doc-mode', 'pages', '--doc-start-page', '1', '--doc-end-page', '3'],
{ docConfig: { mode: 'pages', startPage: 1, endPage: 3 } },
],
[['--doc-mode', 'text'], { docConfig: { mode: 'text' } }],
[['--degree', '90'], { config3d: { degree: 90 } }],
[[], {}],
])('reads with %j', async (flags, config) => {
const cli = setup()
cli.callOperation.mockResolvedValue({ ...frames, images: [] })
await cli.run('read', 'a-1', ...flags)
expect(cli.callOperation).toHaveBeenCalledWith(readAsset, { assetId: 'a-1', ...config })
})
it('names the flag that is missing from a reader config', async () => {
const cli = setup()
const error = await cli
.run('read', 'vid-1', '--video-start', '0', '--video-count', '2')
.catch((err: unknown) => err)
expect(formatCliError(error)).toContain('--video-end')
expect(cli.callOperation).not.toHaveBeenCalled()
})
it('prints text content after the summary', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue({
...frames,
summary: 'Document "notes.md" (ID: d-1):',
images: [],
text: {
content: '# Notes\nhello',
truncated: true,
size: 90000,
mimeType: 'text/markdown',
},
})
await cli.run('read', 'd-1', '--doc-mode', 'text')
expect(cli.stdout()).toBe(
'Document "notes.md" (ID: d-1):\n\n# Notes\nhello\n\n[Content truncated: showing the first part of a 90000-byte file. Run `shumai-cli download vid-1` to get the whole file.]\n',
)
})
it('returns right away with --no-wait and prints the render command', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue(pendingRead)
await cli.run(
'read',
'vid-1',
'--video-start',
'0',
'--video-end',
'4',
'--video-count',
'2',
'--no-wait',
'--out',
'frames',
)
expect(cli.callOperation).toHaveBeenCalledWith(readAsset, {
assetId: 'vid-1',
videoConfig: { start: 0, end: 4, count: 2 },
maxWaitSeconds: 0,
})
expect(cli.stdout()).toBe(
'Rendering is still in progress for "clip.mp4".\nRun this to get the result: shumai-cli render task-1 --out "frames"\n',
)
})
it('prints the raw output with --json', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue(frames)
await cli.run('--json', 'read', 'vid-1')
expect(JSON.parse(cli.stdout())).toEqual(frames)
})
})
describe('render', () => {
it('fetches a pending render by task ID', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue(frames)
await cli.run('render', 'task-1')
expect(cli.callOperation).toHaveBeenCalledWith(getAssetRender, { taskId: 'task-1' })
expect(cli.stdout()).toContain('- Frame at 4s: https://files.example/4.webp')
})
it('checks once with --no-wait', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue(pendingRead)
await cli.run('render', 'task-1', '--no-wait')
expect(cli.callOperation).toHaveBeenCalledWith(getAssetRender, {
taskId: 'task-1',
maxWaitSeconds: 0,
})
expect(cli.stdout()).toContain('Run this to get the result: shumai-cli render task-1\n')
})
})
describe('download', () => {
it('downloads the web previews by default, or the originals with --original', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue({ files: [] })
await cli.run('download', 'a-1', 'a-2')
expect(cli.callOperation).toHaveBeenLastCalledWith(downloadAsset, {
assetIds: ['a-1', 'a-2'],
})
await cli.run('download', 'a-1', '--original')
expect(cli.callOperation).toHaveBeenLastCalledWith(downloadAsset, {
assetIds: ['a-1'],
proxy: false,
})
})
it('requires at least one asset ID and documents its options', async () => {
const cli = setup()
await expect(cli.run('download')).rejects.toThrow()
expect(cli.stderr()).toContain("missing required argument 'assetIds'")
await expect(cli.run('download', '--help')).rejects.toThrow()
expect(cli.stdout()).toContain('-o, --out <dir>')
expect(cli.stdout()).toContain('--original')
expect(cli.stdout()).not.toContain('--proxy')
})
})
describe('--json', () => {
it('prints the raw Operation output', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue(folder)
await cli.run('mkdir', 'Renders', '-p', 'root', '--json')
expect(JSON.parse(cli.stdout())).toEqual(folder)
})
it('works before the command too', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue({ data: [] })
await cli.run('--json', 'project', 'ls')
expect(JSON.parse(cli.stdout())).toEqual({ data: [] })
})
})
describe('errors', () => {
it('surfaces server errors for the entry point to print', async () => {
const cli = setup()
cli.callOperation.mockRejectedValue(new CliError('User is not a member of the team'))
const error = await cli.run('mkdir', 'x', '-p', 'root').catch((err: unknown) => err)
expect(formatCliError(error)).toBe('Error: User is not a member of the team')
})
it('validates input against the Operation schema before calling the server', async () => {
const cli = setup()
const error = await cli.run('mkdir', '', '-p', 'root').catch((err: unknown) => err)
expect(error).toBeInstanceOf(CliError)
expect(cli.callOperation).not.toHaveBeenCalled()
})
it('suggests similar commands for typos', async () => {
const cli = setup()
await expect(cli.run('mkidr', 'x')).rejects.toThrow()
expect(cli.stderr()).toContain('Did you mean mkdir?')
})
})
describe('help', () => {
it('lists every command, including generated ones', async () => {
const cli = setup()
await expect(cli.run('--help')).rejects.toThrow()
const help = cli.stdout()
for (const command of [
'project',
'ls',
'mkdir',
'rename',
'move|mv',
'delete|rm',
'read',
'render',
'download',
'upload',
'create-version',
]) {
expect(help).toContain(command)
}
expect(help).toContain('--json')
})
it('documents generated options from the Operation schema', async () => {
const cli = setup()
await expect(cli.run('ls', '--help')).rejects.toThrow()
const help = cli.stdout()
expect(help).toContain('-p, --parent <parent>')
expect(help).toContain('The parent folder ID to list assets from.')
expect(help).toContain('--type <type>')
expect(help).toContain('choices: "file", "folder", "all"')
expect(help).toContain('(default: 200)')
expect(help).toContain('List the files and folders inside a parent folder.')
})
it('documents flattened reader options for read', async () => {
const cli = setup()
await expect(cli.run('read', '--help')).rejects.toThrow()
const help = cli.stdout()
for (const flag of [
'--video-start <start>',
'--video-end <end>',
'--video-count <count>',
'--doc-mode <mode>',
'--doc-start-page <startPage>',
'--doc-end-page <endPage>',
'--degree <degree>',
'--annotation-id <annotationId>',
'-o, --out <dir>',
'--no-wait',
]) {
expect(help).toContain(flag)
}
expect(help).not.toContain('--include-content')
expect(help).not.toContain('--image')
})
})
describe('search', () => {
it('searches a folder by name with the maximum page size', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue({
data: [{ id: 'f1', name: 'sunset.png', type: 'file', size: 10, projectId: 'p' }],
pageInfo: { hasNextPage: false, endCursor: null },
total: 1,
})
await cli.run('search', 'sunset', '-p', 'root-1')
expect(cli.callOperation).toHaveBeenCalledWith(searchAssets, {
parent: 'root-1',
query: 'sunset',
first: 200,
})
expect(cli.stdout()).toContain('sunset.png')
})
it('searches by meaning with --semantic', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue({
data: [],
pageInfo: { hasNextPage: false, endCursor: null },
total: 0,
})
await cli.run('search', 'a calm beach', '-p', 'root-1', '--semantic')
expect(cli.callOperation).toHaveBeenCalledWith(
searchAssets,
expect.objectContaining({ query: 'a calm beach', semantic: true }),
)
})
})
describe('copy', () => {
it.each(['copy', 'cp'])('copies assets with %s', async (command) => {
const cli = setup()
cli.callOperation.mockResolvedValue({ copiedAssetIds: ['c-1', 'c-2'], newParentId: 'f-2' })
await cli.run(command, 'a-1', 'a-2', '-p', 'f-2', '--with-comments')
expect(cli.callOperation).toHaveBeenCalledWith(copyAssets, {
assetIds: ['a-1', 'a-2'],
newParentId: 'f-2',
withComments: true,
})
expect(cli.stdout()).toBe('Copied 2 asset(s) to parent f-2: c-1, c-2\n')
})
})
describe('comment', () => {
const thread = {
id: 'c-1',
message: 'Too dark here',
author: { id: 'u-1', name: 'Ana' },
second: 12.5,
hasMarkup: false,
attachmentCount: 0,
createdAt: '2026-01-01T00:00:00.000Z',
resolved: true,
replies: [
{
id: 'c-2',
message: 'Fixed in v2',
author: { id: 'u-2', name: 'Bo' },
second: null,
hasMarkup: false,
attachmentCount: 0,
createdAt: '2026-01-02T00:00:00.000Z',
},
],
}
it('lists threads with their replies', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue({
data: [thread],
pageInfo: { hasNextPage: false, endCursor: null },
total: 1,
})
await cli.run('comment', 'ls', 'vid-1')
expect(cli.callOperation).toHaveBeenCalledWith(listComments, {
assetId: 'vid-1',
first: 200,
})
expect(cli.stdout()).toBe(
'c-1 @12.5s [resolved] Ana: Too dark here\n ↳ c-2 Bo: Fixed in v2\n',
)
})
it('posts a reply at a timecode', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue({ id: 'c-3', assetId: 'vid-1', replyToId: 'c-1' })
await cli.run('comment', 'add', 'vid-1', 'Looks good now', '--reply-to', 'c-1', '--at', '3')
expect(cli.callOperation).toHaveBeenCalledWith(createComment, {
assetId: 'vid-1',
message: 'Looks good now',
replyToId: 'c-1',
second: 3,
})
expect(cli.stdout()).toBe('Posted comment c-3\n')
})
it('resolves and reopens comments', async () => {
const cli = setup()
cli.callOperation.mockResolvedValueOnce({ commentId: 'c-1', resolved: true })
cli.callOperation.mockResolvedValueOnce({ commentId: 'c-1', resolved: false })
await cli.run('comment', 'resolve', 'c-1')
await cli.run('comment', 'resolve', 'c-1', '--reopen')
expect(cli.callOperation).toHaveBeenNthCalledWith(1, resolveComment, { commentId: 'c-1' })
expect(cli.callOperation).toHaveBeenNthCalledWith(2, resolveComment, {
commentId: 'c-1',
reopen: true,
})
expect(cli.stdout()).toBe('Comment c-1 is resolved\nComment c-1 is unresolved\n')
})
})
describe('meta set', () => {
it('passes --values as a JSON object', async () => {
const cli = setup()
cli.callOperation.mockResolvedValue({ assetId: 'a-1', updatedKeys: ['status', 'rating'] })
await cli.run('meta', 'set', 'a-1', '--values', '{"status":"approved","rating":4}')
expect(cli.callOperation).toHaveBeenCalledWith(updateAssetMetadata, {
assetId: 'a-1',
values: { status: 'approved', rating: 4 },
})
expect(cli.stdout()).toBe('Updated status, rating on a-1\n')
})
it.each([
['{not json', 'Not valid JSON.'],
['["status"]', 'Expected a JSON object'],
])('rejects --values %s', async (value, message) => {
const cli = setup()
await expect(cli.run('meta', 'set', 'a-1', '--values', value)).rejects.toThrow()
expect(cli.stderr()).toContain(message)
expect(cli.callOperation).not.toHaveBeenCalled()
})
})
describe('field ls', () => {
it("lists a project's fields with their choices", async () => {
const cli = setup()
cli.callOperation.mockResolvedValue({
fields: [
{
key: 'status',
name: 'Status',
type: 'select',
description: '',
readOnly: false,
creationContext: false,
options: [{ id: 'approved', name: 'Approved' }],
},
{
key: 'prompt',
name: 'Prompt',
type: 'text',
description: '',
readOnly: false,
creationContext: true,
},
],
})
await cli.run('field', 'ls', 'p-1')
expect(cli.callOperation).toHaveBeenCalledWith(listMetadataFields, { projectId: 'p-1' })
expect(cli.stdout()).toBe(
'status Status (select) [approved=Approved]\nprompt Prompt (text, creation)\n',
)
})
})
describe('version', () => {
it('stacks files, lists versions, and unstacks one', async () => {
const cli = setup()
cli.callOperation.mockResolvedValueOnce({
id: 's-1',
name: 'cut_v2.mp4',
type: 'version_stack',
size: 20,
projectId: 'p-1',
})
cli.callOperation.mockResolvedValueOnce({
versions: [
{
id: 'v-2',
version: 2,
name: 'cut_v2.mp4',
current: true,
createdAt: '2026-01-02T00:00:00.000Z',
creator: null,
agent: null,
},
{
id: 'v-1',
version: 1,
name: 'cut_v1.mp4',
current: false,
createdAt: '2026-01-01T00:00:00.000Z',
creator: null,
agent: null,
},
],
})
cli.callOperation.mockResolvedValueOnce({ versionId: 'v-1', stackId: 's-1' })
await cli.run('version', 'stack', 'v-2', 'v-1')
await cli.run('version', 'ls', 's-1')
await cli.run('version', 'unstack', 'v-1')
expect(cli.callOperation).toHaveBeenNthCalledWith(1, createVersionStack, {
fileIds: ['v-2', 'v-1'],
})
expect(cli.callOperation).toHaveBeenNthCalledWith(2, listVersions, { stackId: 's-1' })
expect(cli.callOperation).toHaveBeenNthCalledWith(3, removeVersion, { versionId: 'v-1' })
expect(cli.stdout()).toBe(
'Created version stack s-1\n' +
'v2 (current) v-2 cut_v2.mp4\nv1 v-1 cut_v1.mp4\n' +
'Removed v-1 from version stack s-1\n',
)
})
})
describe('instructions', () => {
it("prints a folder's instructions, or says it has none", async () => {
const cli = setup()
cli.callOperation.mockResolvedValueOnce({ folderId: 'f-1', content: '# Rules' })
cli.callOperation.mockResolvedValueOnce({ folderId: 'f-2', content: null })
await cli.run('instructions', 'f-1')
await cli.run('instructions', 'f-2')
expect(cli.callOperation).toHaveBeenCalledWith(getFolderInstructions, { folderId: 'f-1' })
expect(cli.stdout()).toBe('# Rules\n(This folder has no instructions.)\n')
})
})
it('has no upload Operation commands: upload and create-version stream local files', () => {
const program = createProgram({ callOperation: vi.fn<CallOperation>() })
const names = program.commands.map((c) => c.name())
expect(names).not.toContain('complete-upload')
expect(names.filter((n) => n === 'create-version')).toHaveLength(1)
})
})
describe('formatCliError', () => {
beforeEach(() => vi.restoreAllMocks())
it('formats expected and unexpected errors', () => {
expect(formatCliError(new CliError('boom'))).toBe('Error: boom')
expect(
formatCliError(new CliError('Error connecting to API server: x', { prefixed: true })),
).toBe('Error connecting to API server: x')
expect(formatCliError(new TypeError('bad'))).toBe('Unexpected error: bad')
})
})
+59
View File
@@ -0,0 +1,59 @@
import { Command } from 'commander'
import { operationDefinitions } from '@shumai/operations'
import { createVersion } from './commands/create-version'
import { upload } from './commands/upload'
import { callOperation, type CallOperation } from './operations/call-operation'
import { cliExtensions } from './operations/extensions'
import { registerOperationCommands } from './operations/generate'
import type { Output } from './operations/render'
export interface ProgramOptions {
callOperation?: CallOperation
output?: Output
}
function isDeleteAllowed(): boolean {
const value = process.env.SHUMAI_ALLOW_DELETE
return value === 'true' || value === '1'
}
/**
* Builds the `shumai-cli` program. Operation commands (ls, mkdir, rename, move, delete,
* read, render, project ls, ...) are generated from `@shumai/operations`; upload and create-version stream
* local files and are defined here.
*/
export function createProgram(options: ProgramOptions = {}): Command {
const program = new Command()
.name('shumai-cli')
.description('Command line interface for the Shumai media workspace.')
.option('--json', 'Print raw JSON output instead of human-friendly text')
.showHelpAfterError()
.showSuggestionAfterError()
registerOperationCommands(program, operationDefinitions, {
callOperation: options.callOperation ?? callOperation,
output: options.output ?? {
out: process.stdout,
isTty: Boolean(process.stdout.isTTY),
columns: process.stdout.columns || 80,
},
allowDestructive: isDeleteAllowed,
extensions: cliExtensions,
})
program
.command('upload')
.description('Upload a local file or folder to a parent folder.')
.argument('<path>', 'Local file or folder to upload.')
.requiredOption('-p, --parent <parentId>', 'The parent folder ID to upload into.')
.action((localPath: string, opts: { parent: string }) => upload(localPath, opts.parent))
program
.command('create-version')
.description('Upload a local file as a new version of an existing file or version stack.')
.argument('<path>', 'Local file to upload as the new version.')
.requiredOption('-p, --parent <parentId>', 'The file or version stack ID to add a version to.')
.action((localPath: string, opts: { parent: string }) => createVersion(localPath, opts.parent))
return program
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/premiere-uxp",
"version": "0.5.2",
"version": "0.6.2",
"private": true,
"type": "commonjs",
"scripts": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/transcode-app",
"version": "0.5.2",
"version": "0.6.2",
"private": true,
"type": "module",
"bin": {
+76 -9
View File
@@ -14,18 +14,85 @@ async function run() {
// Initialize workflows and activities
initTranscodeWorkflows()
console.log('🚀 Starting Transcode Worker...')
let idleTimeoutMs = process.env.SHUMAI_WORKER_IDLE_TIMEOUT_MS
? parseInt(process.env.SHUMAI_WORKER_IDLE_TIMEOUT_MS, 10)
: 0
const options: { workflowBundle?: unknown; workflowsPath?: string } = {}
if (process.env.NODE_ENV === 'production') {
// @ts-ignore: Bun temporal plugin macro
const { default: workflowBundle } = await import('./workflows.ts:::workflow')
options.workflowBundle = workflowBundle
} else {
options.workflowsPath = new URL('./workflows.ts', import.meta.url).pathname
const idleTimeoutArg = process.argv.find((arg) => arg.startsWith('--idle-timeout='))
if (idleTimeoutArg) {
const val = parseInt(idleTimeoutArg.split('=')[1], 10)
if (!isNaN(val)) idleTimeoutMs = val
}
await workflowService.startWorkers(TaskQueueTranscode, options)
if (idleTimeoutMs > 0) {
console.log(
`🚀 Starting Transcode Worker with idle timeout (${idleTimeoutMs / 1000}s auto-drain)...`,
)
} else {
console.log('🚀 Starting Transcode Worker (persistent daemon mode)...')
}
await workflowService.startWorkers(TaskQueueTranscode)
let isShuttingDown = false
let idleTimer: Timer | null = null
let activeWorkflows = 0
const shutdown = async () => {
if (isShuttingDown) return
isShuttingDown = true
if (idleTimer) {
clearTimeout(idleTimer)
idleTimer = null
}
console.log('Shutting down Transcode Worker gracefully...')
try {
await workflowService.shutdownWorkers()
} catch (err) {
console.error('Error during Transcode Worker shutdown:', err)
}
process.exit(0)
}
if (idleTimeoutMs > 0) {
const resetIdleTimer = () => {
if (idleTimer) {
clearTimeout(idleTimer)
idleTimer = null
}
if (activeWorkflows === 0 && !isShuttingDown) {
idleTimer = setTimeout(async () => {
console.log(
`[Transcode Worker] Inactive for ${idleTimeoutMs / 1000}s with no active workflows, shutting down.`,
)
await shutdown()
}, idleTimeoutMs)
}
}
// Start idle timer immediately on startup in case no tasks are enqueued
resetIdleTimer()
workflowService.getExecutor().on('workflowStarted', (task) => {
activeWorkflows++
console.log(
`[Transcode Worker] Claimed task ${task.id} (active: ${activeWorkflows}), cancelling idle timer.`,
)
if (idleTimer) {
clearTimeout(idleTimer)
idleTimer = null
}
})
workflowService.getExecutor().on('workflowFinished', async ({ taskId }) => {
activeWorkflows = Math.max(0, activeWorkflows - 1)
console.log(`[Transcode Worker] Completed task ${taskId} (active: ${activeWorkflows}).`)
resetIdleTimer()
})
}
process.on('SIGINT', shutdown)
process.on('SIGTERM', shutdown)
}
handleDaemonCommands('shumai-transcode', run).catch((err) => {
-1
View File
@@ -1 +0,0 @@
export * from '@shumai/transcode/src/workflows/transcode'
+1
View File
@@ -66,6 +66,7 @@ apps/web/e2e/
| Owner removes a member via the members dialog; the membership is deleted from the DB | `tests/team/remove-member.spec.ts` |
| Owner changes a team member role in the members dialog and permissions update | `tests/team/change-member-role.spec.ts` |
| Owner manages resource quotas in settings and resets usage from the dashboard | `tests/team/quotas-settings.spec.ts` |
| Owner creates an API token that is shown once, listed by hint, and authenticates API calls | `tests/team/api-tokens.spec.ts` |
### project
| Test | File |
+1
View File
@@ -19,6 +19,7 @@ async function start() {
process.env.BETTER_AUTH_URL = 'http://localhost:5200'
process.env.NODE_ENV = 'development'
process.env.SHUMAI_E2E = 'true'
process.env.ENABLE_EMBEDDING_AGENT = 'false'
// Write variables to .env.e2e file so the teardown can load them
const envContent = [`DATABASE_URL=${process.env.DATABASE_URL}`, `S3_BUCKET=${bucketName}`].join(
@@ -0,0 +1,61 @@
import { createHash } from 'node:crypto'
import { expect, test } from '../../fixtures'
import { E2E_APP_URL } from '../../helpers/auth'
test('owner creates an API token that is shown once, listed by hint, and authenticates API calls', async ({
owner,
prisma,
playwright,
}) => {
const { page, teamId } = owner
// 1. Open the API Tokens settings tab
await page.goto(`/teams/${teamId}/settings`)
await page.getByRole('button', { name: /^(API Tokens|API 令牌)$/i }).click()
await expect(page.getByText(/No API tokens found|未找到 API 令牌/i)).toBeVisible()
// 2. Generate a token
await page.fill('#tokenName', 'e2e-cli')
await page.getByRole('button', { name: /^(Generate|生成)$/i }).click()
// 3. The plaintext is shown once in a dialog
const dialog = page.getByRole('dialog')
await expect(dialog.getByText(/Save your API token|保存您的 API 令牌/i)).toBeVisible()
const tokenInput = dialog.getByRole('textbox')
await expect(tokenInput).toHaveValue(/^shumai_[A-Za-z0-9_-]{43}$/)
const token = await tokenInput.inputValue()
await dialog.getByRole('button', { name: /^(Done|完成)$/i }).click()
await expect(dialog).toBeHidden()
// 4. The list identifies the token by name and hint only
const hint = token.slice(-4)
const row = page.getByRole('row', { name: /e2e-cli/ })
await expect(row).toBeVisible()
await expect(row.getByText(`…${hint}`)).toBeVisible()
await expect(page.getByText(token)).toHaveCount(0)
// 5. Only the hash is stored
const stored = await prisma.apiToken.findFirstOrThrow({ where: { name: 'e2e-cli' } })
expect(stored.tokenHash).toBe(createHash('sha256').update(token, 'utf8').digest('hex'))
expect(stored.tokenHint).toBe(hint)
// 6. The token authenticates a request that carries no session cookie
const tokenClient = await playwright.request.newContext({
// eslint-disable-next-line @typescript-eslint/naming-convention
baseURL: E2E_APP_URL,
})
try {
const ok = await tokenClient.get('/api/projects', {
headers: { Authorization: `Bearer ${token}` },
})
expect(ok.status()).toBe(200)
const rejected = await tokenClient.get('/api/projects', {
headers: { Authorization: `Bearer ${stored.tokenHash}` },
})
expect(rejected.status()).toBe(401)
} finally {
await tokenClient.dispose()
}
})
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/web-app",
"version": "0.5.2",
"version": "0.6.2",
"private": true,
"type": "module",
"dependencies": {
+54 -22
View File
@@ -12,9 +12,11 @@ import { metadataService } from '@shumai/core/src/metadata/metadata'
import { initTranscodeWorkflows } from '@shumai/transcode'
import { workflowService } from '@shumai/workflow-core'
import { migrateLegacyAgentAvatars } from '@shumai/core/src/agent/migration'
import { agentService } from '@shumai/core/src/agent/agent'
import { handleDaemonCommands } from '@shumai/core/src/utils/daemon'
import { authService } from '@shumai/core/src/auth/auth'
import { embeddingService } from '@shumai/core/src/search/embedding-service'
import { sandboxService } from '@shumai/core'
import { notificationJobService } from '@shumai/core/src/notification/notification-job'
@@ -47,6 +49,32 @@ if (resetCmdIndex !== -1) {
}
}
const regenCmdIndex = cliArgs.findIndex((arg) => arg === 'regenerate-embeddings')
if (regenCmdIndex !== -1) {
try {
initAgentWorkflows()
initTranscodeWorkflows()
console.log('🔄 Regenerating embeddings...')
const result = await embeddingService.regenerateEmbeddings()
await workflowService.waitForPendingSubmissions()
console.log(
`✅ Successfully queued ${result.tasksCreated} embedding tasks for ${result.totalAssets} assets.`,
)
if (result.skippedTeams.length > 0) {
console.warn(
`⚠️ Skipped ${result.skippedTeams.length} team(s) without an active embedding agent.`,
)
}
console.log('The background workers will process the embedding tasks.')
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()
@@ -58,32 +86,31 @@ async function run() {
// Start services
await metadataService.syncSystemFields().catch(console.error)
await migrateLegacyAgentAvatars().catch(console.error)
await agentService.ensureSystemEmbeddingAgents().catch(console.error)
assetService.startCleanupJob()
notificationJobService.start()
workflowService.start()
if (process.env.WORKFLOW_EXECUTOR === 'temporal') {
const args = process.argv.slice(2)
let workersOption = ''
for (let i = 0; i < args.length; i++) {
if (args[i] === '--workers') {
workersOption = args[i + 1] || ''
} else if (args[i].startsWith('--workers=')) {
workersOption = args[i].split('=')[1]
}
const args = process.argv.slice(2)
let workersOption = process.env.SHUMAI_WORKERS || 'all'
for (let i = 0; i < args.length; i++) {
if (args[i] === '--workers') {
workersOption = args[i + 1] || workersOption
} else if (args[i].startsWith('--workers=')) {
workersOption = args[i].split('=')[1] || workersOption
}
const queuesToStart: string[] = []
if (workersOption === 'agent' || workersOption === 'ai') {
queuesToStart.push('agent_queue')
} else if (workersOption === 'transcode') {
queuesToStart.push('transcode_queue')
} else if (workersOption === 'all') {
queuesToStart.push('agent_queue', 'transcode_queue')
}
Promise.all(queuesToStart.map((q) => workflowService.startWorkers(q))).catch(console.error)
}
let listenQueues: string[] = ['agent_queue', 'transcode_queue']
if (workersOption === 'none') {
listenQueues = []
} else if (workersOption === 'agent' || workersOption === 'ai') {
listenQueues = ['agent_queue']
} else if (workersOption === 'transcode') {
listenQueues = ['transcode_queue']
}
workflowService.start(listenQueues)
workflowService.startStaleTaskRecovery()
const isProd = process.env.NODE_ENV === 'production'
const port = process.env.SHUMAI_SERVER_PORT ? parseInt(process.env.SHUMAI_SERVER_PORT) : 3000
@@ -107,6 +134,9 @@ async function run() {
const routes: Record<string, any> = {
'/api/*': app.fetch,
'/files/*': app.fetch,
'/.well-known/*': app.fetch,
// Shumai's MCP server; without this entry the SPA catch-all (`/*`) would serve it HTML.
'/mcp': app.fetch,
}
if (isProd) {
@@ -180,8 +210,10 @@ async function run() {
console.log(`🚀 Server running at ${server.url}`)
const shutdown = () => {
const shutdown = async () => {
console.log('\nShutting down gracefully...')
workflowService.stopStaleTaskRecovery()
await workflowService.shutdownWorkers().catch(() => {})
assetService.stopCleanupJob()
server.stop(true)
process.exit(0)
+45 -34
View File
@@ -3,47 +3,58 @@ import { bunPluginPino } from 'bun-plugin-pino'
import tailwindPlugin from 'bun-plugin-tailwind'
import { existsSync } from 'fs'
import { rm } from 'fs/promises'
import { temporalWorkflow } from './packages/workflow-core/src/bun-temporal-plugin'
console.log('\n🚀 Starting build process...\n')
const outdir = 'dist'
const target = process.argv[2] || 'all'
if (existsSync(outdir)) {
if (existsSync(outdir) && target === 'all') {
console.log(`🗑️ Cleaning previous build at ${outdir}`)
await rm(outdir, { recursive: true, force: true })
}
await Bun.build({
entrypoints: ['./apps/web/src/index.ts'],
root: '.',
target: 'bun',
outdir: outdir,
minify: true,
splitting: true,
naming: '[name].[ext]',
plugins: [
temporalWorkflow({
bundleOptions: {},
}),
tailwindPlugin,
bunPluginPino({ transports: ['pino-pretty'] }),
],
external: [
'@temporalio/activity',
'@temporalio/client',
'@temporalio/worker',
'@temporalio/workflow',
'pdfkit',
],
// compile: {
// outfile: 'Shumai',
// autoloadBunfig: true,
// autoloadDotenv: true,
// autoloadTsconfig: true,
// autoloadPackageJson: true,
// },
define: {
'process.env.NODE_ENV': JSON.stringify('production'),
if (target === 'all' || target === 'web') {
await Bun.build({
entrypoints: ['./apps/web/src/index.ts'],
root: '.',
target: 'bun',
outdir: outdir,
minify: true,
splitting: true,
naming: '[name].[ext]',
plugins: [tailwindPlugin, bunPluginPino({ transports: ['pino-pretty'] })],
external: ['@dbos-inc/dbos-sdk', 'pg', 'pdfkit'],
define: {
'process.env.NODE_ENV': JSON.stringify('production'),
},
})
}
const allWorkers = [
{
name: 'transcode',
entrypoint: './apps/transcode/src/index.ts',
naming: 'transcode-worker.[ext]',
},
})
{ name: 'agent', entrypoint: './apps/agent/src/index.ts', naming: 'agent-worker.[ext]' },
]
const workersToBuild = target === 'all' ? allWorkers : allWorkers.filter((w) => w.name === target)
for (const worker of workersToBuild) {
await Bun.build({
entrypoints: [worker.entrypoint],
root: '.',
target: 'bun',
outdir: outdir,
minify: true,
splitting: false,
naming: worker.naming,
plugins: [bunPluginPino({ transports: ['pino-pretty'] })],
external: ['@dbos-inc/dbos-sdk', 'pg', 'pdfkit'],
define: {
'process.env.NODE_ENV': JSON.stringify('production'),
},
})
}
+83 -304
View File
@@ -11,14 +11,13 @@
"@testcontainers/postgresql": "12.1.0",
"@testing-library/dom": "10.4.1",
"@testing-library/react": "16.3.3",
"@types/bun": "1.4.0",
"@types/bun": "1.4.3",
"@types/node": "25.9.1",
"bun-plugin-pino": "1.5.0",
"bun-plugin-tailwind": "0.1.2",
"bun-types": "1.4.0",
"bun-types": "1.4.3",
"eslint": "10.9.1",
"eslint-config-prettier": "10.1.8",
"eslint-plugin-prettier": "5.5.6",
"eslint-plugin-react": "7.37.5",
"globals": "17.11.0",
"happy-dom": "20.12.0",
@@ -33,7 +32,7 @@
},
"apps/agent": {
"name": "@shumai/agent-app",
"version": "0.5.2",
"version": "0.6.2",
"bin": {
"shumai-agent": "./src/index.ts",
},
@@ -45,22 +44,24 @@
},
"apps/cli": {
"name": "@shumai/cli",
"version": "0.5.2",
"version": "0.6.2",
"bin": {
"shumai-cli": "./src/index.ts",
},
"dependencies": {
"@shumai/api": "workspace:*",
"@shumai/core": "workspace:*",
"@shumai/dtos": "workspace:*",
"@shumai/operations": "workspace:*",
"@shumai/tableprinter": "workspace:*",
"commander": "15.0.0",
"hono": "4.13.5",
"ulid": "3.0.2",
"zod": "4.5.4",
},
},
"apps/premiere-uxp": {
"name": "@shumai/premiere-uxp",
"version": "0.5.2",
"version": "0.6.2",
"dependencies": {
"@shumai/api": "workspace:*",
"@shumai/dtos": "workspace:*",
@@ -114,7 +115,7 @@
},
"apps/transcode": {
"name": "@shumai/transcode-app",
"version": "0.5.2",
"version": "0.6.2",
"bin": {
"shumai-transcode": "./src/index.ts",
},
@@ -126,7 +127,7 @@
},
"apps/web": {
"name": "@shumai/web-app",
"version": "0.5.2",
"version": "0.6.2",
"dependencies": {
"@shumai/agent": "workspace:*",
"@shumai/api": "workspace:*",
@@ -146,21 +147,20 @@
},
"packages/agent": {
"name": "@shumai/agent",
"version": "0.5.2",
"version": "0.6.2",
"dependencies": {
"@anthropic-ai/sandbox-runtime": "0.0.74",
"@earendil-works/pi-agent-core": "0.82.1",
"@earendil-works/pi-ai": "0.82.1",
"@google/genai": "2.19.0",
"@google/genai": "2.28.0",
"@shumai/core": "workspace:*",
"@shumai/db": "workspace:*",
"@shumai/dtos": "workspace:*",
"@shumai/operations": "workspace:*",
"@shumai/workflow-core": "workspace:*",
"@temporalio/activity": "1.23.0",
"@temporalio/worker": "1.23.0",
"@temporalio/workflow": "1.23.0",
"adm-zip": "0.6.0",
"jittered-fractional-indexing": "1.0.1",
"sharp": "0.35.4",
"typebox": "1.3.22",
"ulid": "3.0.2",
"zod": "4.5.4",
@@ -171,21 +171,27 @@
},
"packages/api": {
"name": "@shumai/api",
"version": "0.5.2",
"version": "0.6.2",
"dependencies": {
"@better-auth/mcp": "1.7.12",
"@hono/zod-validator": "0.7.6",
"@modelcontextprotocol/server": "2.0.0",
"@shumai/core": "workspace:*",
"@shumai/db": "workspace:*",
"@shumai/dtos": "workspace:*",
"@shumai/operations": "workspace:*",
"hono": "4.13.5",
"pino": "10.3.1",
"ulid": "3.0.2",
"zod": "4.5.4",
},
"devDependencies": {
"@modelcontextprotocol/client": "2.0.0",
},
},
"packages/core": {
"name": "@shumai/core",
"version": "0.5.2",
"version": "0.6.2",
"dependencies": {
"@ai-sdk/alibaba": "2.0.38",
"@ai-sdk/amazon-bedrock": "5.0.67",
@@ -208,17 +214,19 @@
"@anthropic-ai/sandbox-runtime": "0.0.74",
"@aws-sdk/client-s3": "3.1121.0",
"@aws-sdk/s3-request-presigner": "3.1121.0",
"@better-auth/mcp": "1.7.12",
"@better-auth/oauth-provider": "1.7.12",
"@earendil-works/pi-agent-core": "0.82.1",
"@earendil-works/pi-ai": "0.82.1",
"@google/genai": "2.28.0",
"@modelcontextprotocol/client": "2.0.0",
"@shumai/db": "workspace:*",
"@shumai/dtos": "workspace:*",
"@shumai/operations": "workspace:*",
"@sinclair/typebox": "0.34.52",
"@temporalio/activity": "1.24.0",
"@temporalio/workflow": "1.24.0",
"adm-zip": "0.6.0",
"ai": "7.0.84",
"better-auth": "1.6.11",
"better-auth": "1.7.12",
"csv-parse": "7.0.2",
"date-fns": "4.4.0",
"dotenv": "17.4.2",
@@ -247,7 +255,7 @@
},
"packages/db": {
"name": "@shumai/db",
"version": "0.5.2",
"version": "0.6.2",
"dependencies": {
"@earendil-works/pi-agent-core": "0.82.1",
"@prisma/adapter-pg": "7.10.0",
@@ -263,7 +271,7 @@
},
"packages/dtos": {
"name": "@shumai/dtos",
"version": "0.5.2",
"version": "0.6.2",
"dependencies": {
"@earendil-works/pi-agent-core": "0.82.1",
"zod": "4.5.4",
@@ -271,10 +279,10 @@
},
"packages/e2e": {
"name": "@shumai/e2e",
"version": "0.5.2",
"version": "0.6.2",
"dependencies": {
"@earendil-works/pi-agent-core": "0.82.1",
"@google/genai": "2.19.0",
"@google/genai": "2.28.0",
"@shumai/agent": "workspace:*",
"@shumai/core": "workspace:*",
"@shumai/db": "workspace:*",
@@ -284,29 +292,34 @@
"sharp": "0.35.4",
},
},
"packages/operations": {
"name": "@shumai/operations",
"version": "0.6.2",
"dependencies": {
"zod": "4.5.4",
},
},
"packages/tableprinter": {
"name": "@shumai/tableprinter",
"version": "0.5.2",
"version": "0.6.2",
},
"packages/transcode": {
"name": "@shumai/transcode",
"version": "0.5.2",
"version": "0.6.2",
"dependencies": {
"@shumai/core": "workspace:*",
"@shumai/db": "workspace:*",
"@shumai/dtos": "workspace:*",
"@shumai/workflow-core": "workspace:*",
"@temporalio/activity": "1.23.0",
"@temporalio/worker": "1.23.0",
"@temporalio/workflow": "1.23.0",
"ulid": "3.0.2",
},
},
"packages/webui": {
"name": "@shumai/webui",
"version": "0.5.2",
"version": "0.6.2",
"dependencies": {
"@base-ui/react": "1.7.0",
"@better-auth/oauth-provider": "1.7.12",
"@dnd-kit/abstract": "0.5.0",
"@dnd-kit/dom": "0.5.0",
"@dnd-kit/react": "0.5.0",
@@ -358,7 +371,7 @@
"@uppy/aws-s3": "6.0.0",
"@uppy/core": "6.0.0",
"@uppy/xhr-upload": "6.0.0",
"better-auth": "1.6.11",
"better-auth": "1.7.12",
"class-variance-authority": "0.7.1",
"clsx": "2.1.1",
"cmdk": "1.1.1",
@@ -406,14 +419,12 @@
},
"packages/workflow-core": {
"name": "@shumai/workflow-core",
"version": "0.5.2",
"version": "0.6.2",
"dependencies": {
"@dbos-inc/dbos-sdk": "5.2.11",
"@shumai/core": "workspace:*",
"@shumai/db": "workspace:*",
"@shumai/dtos": "workspace:*",
"@temporalio/client": "1.23.0",
"@temporalio/worker": "1.23.0",
"@temporalio/workflow": "1.23.0",
"ulid": "3.0.2",
},
},
@@ -580,26 +591,32 @@
"@base-ui/utils": ["@base-ui/utils@0.3.2", "", { "dependencies": { "@babel/runtime": "^7.29.2", "@floating-ui/utils": "^0.2.12", "reselect": "^5.2.0", "use-sync-external-store": "^1.6.0" }, "peerDependencies": { "@types/react": "^17 || ^18 || ^19", "react": "^17 || ^18 || ^19", "react-dom": "^17 || ^18 || ^19" }, "optionalPeers": ["@types/react"] }, "sha512-oWy1aq/I2GmYjpl4PhEAhzflF8VPGKgZeq0xAWTbfD5KBWyxcN0ZP2+WHSUm/5Z6lVMBDLReLcoXwSYoRc/zNQ=="],
"@better-auth/core": ["@better-auth/core@1.6.11", "", { "dependencies": { "@opentelemetry/semantic-conventions": "^1.39.0", "@standard-schema/spec": "^1.1.0", "zod": "^4.3.6" }, "peerDependencies": { "@better-auth/utils": "0.4.0", "@better-fetch/fetch": "1.1.21", "@cloudflare/workers-types": ">=4", "@opentelemetry/api": "^1.9.0", "better-call": "1.3.5", "jose": "^6.1.0", "kysely": "^0.28.5", "nanostores": "^1.0.1" }, "optionalPeers": ["@cloudflare/workers-types", "@opentelemetry/api"] }, "sha512-LrwidLCV8azdMGjvtwp30nj9tIv1BwI3VhtC0UaGSjQkAVWw4bN42I8qwbxRziPeSQoj+zUVkOpxZzAWBDARtQ=="],
"@better-auth/core": ["@better-auth/core@1.7.12", "", { "dependencies": { "@standard-schema/spec": "^1.1.0", "zod": "^4.5.4" }, "peerDependencies": { "@better-auth/utils": "^0.4.2 || ^0.5.0", "@better-fetch/fetch": "1.3.2", "@opentelemetry/api": "^1.9.0", "better-call": "1.4.4", "jose": "^6.1.0", "kysely": "^0.28.5 || ^0.29.0", "nanostores": "^1.0.1" }, "optionalPeers": ["@opentelemetry/api"] }, "sha512-SUStBGHJ13KnSO6+7U/1DSlfuOtln4jtOrFZqzQtxZVHZIrAoMjwHNGitlF+s7hvKbuC3Z14xjnqfLLqIqGfxw=="],
"@better-auth/drizzle-adapter": ["@better-auth/drizzle-adapter@1.6.11", "", { "peerDependencies": { "@better-auth/core": "^1.6.11", "@better-auth/utils": "0.4.0", "drizzle-orm": "^0.45.2" }, "optionalPeers": ["drizzle-orm"] }, "sha512-4jpkETIGZOHCf7BK4jnu22fdN6jjomH0/HhEzkaWy3+Eppi5PYlHTF/460jrTmA3Xc+Vqwp9t282ymHiEPypGw=="],
"@better-auth/drizzle-adapter": ["@better-auth/drizzle-adapter@1.7.12", "", { "peerDependencies": { "@better-auth/core": "^1.7.12", "@better-auth/utils": "^0.4.2 || ^0.5.0", "drizzle-orm": "^0.45.2 || >=1.0.0-rc.1 <2.0.0" }, "optionalPeers": ["drizzle-orm"] }, "sha512-Qzoyuf05aK01Pc0k3EXv8Xj3XCT2m2dCWc5HoB7x+xX6N3Pm2eQsca+UIArsJcbuNEWWP3L51oIebnBoHJ5DTw=="],
"@better-auth/kysely-adapter": ["@better-auth/kysely-adapter@1.6.11", "", { "peerDependencies": { "@better-auth/core": "^1.6.11", "@better-auth/utils": "0.4.0", "kysely": "^0.28.17" }, "optionalPeers": ["kysely"] }, "sha512-/g8M9RfIjdcZDnbstSUvQiINkvdNlCeZr248zwqx2/PVksQI1MhQofbzUn3RnQnbPKp0EPwpX/dR3oudRFenUg=="],
"@better-auth/kysely-adapter": ["@better-auth/kysely-adapter@1.7.12", "", { "peerDependencies": { "@better-auth/core": "^1.7.12", "@better-auth/utils": "^0.4.2 || ^0.5.0", "kysely": "^0.28.17 || ^0.29.0" }, "optionalPeers": ["kysely"] }, "sha512-1PaFXktLv4n3DmrGbPaCj5SsvcT40NnWw7NLua5/J1+8/A051N5ZzqOwJifXEIQX5k6NdwvmymwDQxKytduEAQ=="],
"@better-auth/memory-adapter": ["@better-auth/memory-adapter@1.6.11", "", { "peerDependencies": { "@better-auth/core": "^1.6.11", "@better-auth/utils": "0.4.0" } }, "sha512-hpdfw0BBf8MuzLkIdmbcUZICbY9r/bhLO2RxSnkzT5+/O+0I0u2I8+m0YUP7vNllP/ZCKASHOYgXPLO75Z0f9Q=="],
"@better-auth/mcp": ["@better-auth/mcp@1.7.12", "", { "dependencies": { "@better-auth/oauth-provider": "^1.7.12", "jose": "^6.1.3" }, "peerDependencies": { "@better-auth/core": "^1.7.12", "better-auth": "^1.7.12", "better-call": "1.4.4" } }, "sha512-iiD6qW/aSBznMJ/t9v9/a3Obd1T2QeiBbbHZTLwusCLm+tzeH6fLHIgB7631TYQBuB/iEA+xpEs9mCy14MpQ8Q=="],
"@better-auth/mongo-adapter": ["@better-auth/mongo-adapter@1.6.11", "", { "peerDependencies": { "@better-auth/core": "^1.6.11", "@better-auth/utils": "0.4.0", "mongodb": "^6.0.0 || ^7.0.0" }, "optionalPeers": ["mongodb"] }, "sha512-3Tor8rSv8vSEIMEaV2PFpPEuVhqc1gNoZ6eGvoh3LwExXXuj8madew6ob+H1pH7Aphn3Ar5PQ08AguT8TbwFAA=="],
"@better-auth/memory-adapter": ["@better-auth/memory-adapter@1.7.12", "", { "peerDependencies": { "@better-auth/core": "^1.7.12", "@better-auth/utils": "^0.4.2 || ^0.5.0" } }, "sha512-glaDwXzDptnddHqRuu7fj47FAssUcOzLNgdlTGJoEPrspkX69x2vnXwgAzNuApjZI21WLtPH/rQ6CN+DQGybPA=="],
"@better-auth/prisma-adapter": ["@better-auth/prisma-adapter@1.6.11", "", { "peerDependencies": { "@better-auth/core": "^1.6.11", "@better-auth/utils": "0.4.0", "@prisma/client": "^5.0.0 || ^6.0.0 || ^7.0.0", "prisma": "^5.0.0 || ^6.0.0 || ^7.0.0" }, "optionalPeers": ["@prisma/client", "prisma"] }, "sha512-Pw+7q7zTp+VSci1V+CYMvuxIbAeVMZLe4lRo46LJoAKMHfjFl5T/ycsyFvWs/DkWC7n9gZZzRDEbHp0I5FiKKw=="],
"@better-auth/mongo-adapter": ["@better-auth/mongo-adapter@1.7.12", "", { "peerDependencies": { "@better-auth/core": "^1.7.12", "@better-auth/utils": "^0.4.2 || ^0.5.0", "mongodb": "^6.0.0 || ^7.0.0" }, "optionalPeers": ["mongodb"] }, "sha512-HKV4sgYSw/Gdt9AuHlESMkiKL72SWdGweDy1Wsyxoh06BpG7aNu4aSJ7marNpMdKZteyRbxWWqQkA9ediA8qFw=="],
"@better-auth/telemetry": ["@better-auth/telemetry@1.6.11", "", { "peerDependencies": { "@better-auth/core": "^1.6.11", "@better-auth/utils": "0.4.0", "@better-fetch/fetch": "1.1.21" } }, "sha512-hsjDHc8MZbm6/AHeNdtywrWedXevnBjmdvnHTcZub+rTVjOv+Td0roI8USKuC6uUibmrl//2rJfVCsGbopihNA=="],
"@better-auth/oauth-provider": ["@better-auth/oauth-provider@1.7.12", "", { "dependencies": { "jose": "^6.2.3", "zod": "^4.5.4" }, "peerDependencies": { "@better-auth/core": "^1.7.12", "@better-auth/utils": "^0.4.2 || ^0.5.0", "@better-fetch/fetch": "1.3.2", "better-auth": "^1.7.12", "better-call": "1.4.4" } }, "sha512-XzjlApbWtuuoEK63CUNHbgs8zpr3AjlQeGbT1vWEPqvOvI2z4lOaIvIsogomfqFAgj/jgB0zMGYjt0MRyW0T7w=="],
"@better-auth/utils": ["@better-auth/utils@0.4.0", "", { "dependencies": { "@noble/hashes": "^2.0.1" } }, "sha512-RpMtLUIQAEWMgdPLNVbIF5ON2mm+CH0U3rCdUCU1VyeAUui4m38DyK7/aXMLZov2YDjG684pS1D0MBllrmgjQA=="],
"@better-auth/prisma-adapter": ["@better-auth/prisma-adapter@1.7.12", "", { "peerDependencies": { "@better-auth/core": "^1.7.12", "@better-auth/utils": "^0.4.2 || ^0.5.0", "@prisma/client": "^5.0.0 || ^6.0.0 || ^7.0.0", "prisma": "^5.0.0 || ^6.0.0 || ^7.0.0" }, "optionalPeers": ["@prisma/client", "prisma"] }, "sha512-FZRX6ORbwhDmeYE1Tl0IPtUn8v3BlVFgbJxDnm/DCNHxuFRf+0t4HfddUgYeYehHFR8aSDsdYX44fEFWM9877w=="],
"@better-fetch/fetch": ["@better-fetch/fetch@1.1.21", "", {}, "sha512-/ImESw0sskqlVR94jB+5+Pxjf+xBwDZF/N5+y2/q4EqD7IARUTSpPfIo8uf39SYpCxyOCtbyYpUrZ3F/k0zT4A=="],
"@better-auth/telemetry": ["@better-auth/telemetry@1.7.12", "", { "peerDependencies": { "@better-auth/core": "^1.7.12", "@better-auth/utils": "^0.4.2 || ^0.5.0", "@better-fetch/fetch": "1.3.2" } }, "sha512-DaDkKNnI99vKGGbWq9KJg2uYeaOjsK9nIBw9T2m2KG/RkxpvQRjYkZ00++up2bZQkR5pB1nukGbplza3UJG/Xg=="],
"@better-auth/utils": ["@better-auth/utils@0.5.0", "", { "dependencies": { "@noble/hashes": "^2.0.1" } }, "sha512-BL8W4EfIZFwlu0r54m3v1ztjDhu6dDe/amLTm0xybmbZaNgYUqhD3SjpAsnq0q8YD6/ki4iwIgxJNLP/N3TxiA=="],
"@better-fetch/fetch": ["@better-fetch/fetch@1.3.2", "", {}, "sha512-Gs7n99b5tqUC6cQAPbV0uED3IraHB6xQbHLQ/C3l7ZFafHScOx9pQ+DYmP5blbLFShVWLqxNUlI9wi4xU/X+ow=="],
"@date-fns/tz": ["@date-fns/tz@1.5.0", "", {}, "sha512-lwYN/vDPeNRULcepoE/LO2Pgx+7/RV+S9ARfbc9lr2DtGkOD7pAiruHvbR1RX3Qyf6ja47EWJDMsNK5vK08DJg=="],
"@dbos-inc/dbos-sdk": ["@dbos-inc/dbos-sdk@5.2.11", "", { "dependencies": { "commander": "^12.0.0", "pg": "^8.11.3", "serialize-error": "^8.1.0", "superjson": "^1.13.3", "ws": "^8.18.1", "yaml": "^2.8.3" }, "bin": { "dbos": "dist/src/cli/cli.js", "dbos-sdk": "dist/src/cli/cli.js" } }, "sha512-qrqWGA+7bt48viESoxRIEt518pcYbJXGy1KZJ3GRaK4WI0sR3f2xmvTqc8+Rhs/tbfROso5zFb9bgnUnMKNqbg=="],
"@dnd-kit/abstract": ["@dnd-kit/abstract@0.5.0", "", { "dependencies": { "@dnd-kit/geometry": "^0.5.0", "@dnd-kit/state": "^0.5.0", "tslib": "^2.6.2" } }, "sha512-hi13iMJgjPX/KDYVKg5VeDIhmYiV6buc9bAX+tCLYf4QdyYjPbsXjn2sPo6m7fQ6SGJBEFgHJ2PemeKDUbwBaA=="],
"@dnd-kit/collision": ["@dnd-kit/collision@0.5.0", "", { "dependencies": { "@dnd-kit/abstract": "^0.5.0", "@dnd-kit/geometry": "^0.5.0", "tslib": "^2.6.2" } }, "sha512-xUqRn3lS7oqLkT0AnnHS/STh/Czvwe1UapZFYiLbsUGxopMsQd4teaPCzPouOThoMdGEe+dHWjfqJl6t9iG4mQ=="],
@@ -652,7 +669,7 @@
"@floating-ui/utils": ["@floating-ui/utils@0.2.12", "", {}, "sha512-HpCo8tmWzLVad5s2d19EhAz5zqrrQ6s69qd6moPMQvkOuSwDT1YgRfWSVuc4ennqrgv3OHppiOGMQ7oC13yIww=="],
"@google/genai": ["@google/genai@2.19.0", "", { "dependencies": { "google-auth-library": "^10.3.0", "p-retry": "^4.6.2", "protobufjs": "^7.5.4", "ws": "^8.18.0" }, "peerDependencies": { "@modelcontextprotocol/sdk": "^1.25.2" }, "optionalPeers": ["@modelcontextprotocol/sdk"] }, "sha512-IM3u1FjpOLyOPsPh0smGA6Ntj2olUWCPbTs/WQj7cA/2AKCGw/652W7IaySx0XtwuscFnMYBoraebQusSZ0zSQ=="],
"@google/genai": ["@google/genai@2.28.0", "", { "dependencies": { "google-auth-library": "^10.3.0", "p-retry": "^4.6.2", "protobufjs": "^7.5.4", "ws": "^8.18.0" }, "peerDependencies": { "@modelcontextprotocol/sdk": "^1.25.2" }, "optionalPeers": ["@modelcontextprotocol/sdk"] }, "sha512-hyNAJj+ywu3L46qlZod6KO/JvcT3QONz6VCiPevC/FWOjAD+LQb7DMLUoV8vzoLpt61Q0ruQX99iqbxEjPJWmw=="],
"@grpc/grpc-js": ["@grpc/grpc-js@1.14.4", "", { "dependencies": { "@grpc/proto-loader": "^0.8.0", "@js-sdsl/ordered-map": "^4.4.2" } }, "sha512-k9Dj3DV/itK9D06Y8f190Qgop7/Ui+D0njFV3LHMPwPT75DpXLQohE9Wmz0QElrJnzsjB7KPWiKJbOl7IPDArQ=="],
@@ -740,42 +757,12 @@
"@jridgewell/resolve-uri": ["@jridgewell/resolve-uri@3.1.2", "", {}, "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw=="],
"@jridgewell/source-map": ["@jridgewell/source-map@0.3.11", "", { "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.25" } }, "sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA=="],
"@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.6.0", "", {}, "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw=="],
"@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.31", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw=="],
"@js-sdsl/ordered-map": ["@js-sdsl/ordered-map@4.4.2", "", {}, "sha512-iUKgm52T8HOE/makSxjqoWhe95ZJA1/G1sYsGev2JDKUSS14KAgg1LHb+Ba+IPow0xflbnSkOsZcO08C7w1gYw=="],
"@jsonjoy.com/base64": ["@jsonjoy.com/base64@1.1.2", "", { "peerDependencies": { "tslib": "2" } }, "sha512-q6XAnWQDIMA3+FTiOYajoYqySkO+JSat0ytXGSuRdq9uXE7o92gzuQwQM14xaCRlBLGq3v5miDGC4vkVTn54xA=="],
"@jsonjoy.com/buffers": ["@jsonjoy.com/buffers@17.67.0", "", { "peerDependencies": { "tslib": "2" } }, "sha512-tfExRpYxBvi32vPs9ZHaTjSP4fHAfzSmcahOfNxtvGHcyJel+aibkPlGeBB+7AoC6hL7lXIE++8okecBxx7lcw=="],
"@jsonjoy.com/codegen": ["@jsonjoy.com/codegen@1.0.0", "", { "peerDependencies": { "tslib": "2" } }, "sha512-E8Oy+08cmCf0EK/NMxpaJZmOxPqM+6iSe2S4nlSBrPZOORoDJILxtbSUEDKQyTamm/BVAhIGllOBNU79/dwf0g=="],
"@jsonjoy.com/fs-core": ["@jsonjoy.com/fs-core@4.68.2", "", { "dependencies": { "@jsonjoy.com/fs-node-builtins": "4.68.2", "@jsonjoy.com/fs-node-utils": "4.68.2", "thingies": "^2.5.0" }, "peerDependencies": { "tslib": "2" } }, "sha512-PoBeUNEbjyLKKwCap2z8LkkqdhdfttS4rTHCALVuP65BdF+sAoyBqHo1m+uGTRBiQWv3H7MGfr8f7lY4pDwanw=="],
"@jsonjoy.com/fs-fsa": ["@jsonjoy.com/fs-fsa@4.68.2", "", { "dependencies": { "@jsonjoy.com/fs-core": "4.68.2", "@jsonjoy.com/fs-node-builtins": "4.68.2", "@jsonjoy.com/fs-node-utils": "4.68.2", "thingies": "^2.5.0" }, "peerDependencies": { "tslib": "2" } }, "sha512-h6eGXlLGGMyPfNliDQrbuHKTB9Z29ksCLjreAmdBqrDOBdfrTrHssi+b9WLfrF+J2KzAbIt9OMjJu6AEpTnYkg=="],
"@jsonjoy.com/fs-node": ["@jsonjoy.com/fs-node@4.68.2", "", { "dependencies": { "@jsonjoy.com/fs-core": "4.68.2", "@jsonjoy.com/fs-node-builtins": "4.68.2", "@jsonjoy.com/fs-node-utils": "4.68.2", "@jsonjoy.com/fs-print": "4.68.2", "@jsonjoy.com/fs-snapshot": "4.68.2", "glob-to-regex.js": "^1.0.0", "thingies": "^2.5.0" }, "peerDependencies": { "tslib": "2" } }, "sha512-Kpj519Qk4OXG4+mZ8vTf9BEflliJrPueIDEVcbx8tAOufMJJ8IxR0WwdbcEvJol2KQog3PJjtALXVclorE+xbQ=="],
"@jsonjoy.com/fs-node-builtins": ["@jsonjoy.com/fs-node-builtins@4.68.2", "", { "peerDependencies": { "tslib": "2" } }, "sha512-V8WzQsW2YIrH3RxBGY6HZisxn+dDUltHgksVRuCdPEOXEkAfXuhL/01eHFrabNu84Dn13XuLqvcQUKOYVKAUOA=="],
"@jsonjoy.com/fs-node-to-fsa": ["@jsonjoy.com/fs-node-to-fsa@4.68.2", "", { "dependencies": { "@jsonjoy.com/fs-fsa": "4.68.2", "@jsonjoy.com/fs-node-builtins": "4.68.2", "@jsonjoy.com/fs-node-utils": "4.68.2" }, "peerDependencies": { "tslib": "2" } }, "sha512-4O1K4w5G4oJIpKpoa3WSLG83AsQYVnGv+aUSBGOvIUph9Axm6bB1mPlvldkNg2tBx/4dkiTlZnqNrK5SQ21Wtg=="],
"@jsonjoy.com/fs-node-utils": ["@jsonjoy.com/fs-node-utils@4.68.2", "", { "dependencies": { "@jsonjoy.com/fs-node-builtins": "4.68.2", "glob-to-regex.js": "^1.0.1" }, "peerDependencies": { "tslib": "2" } }, "sha512-CxFwyG9fJr7dAKAd1uanNRNrRMtDDqbYJA8do53+M4LY7SxcBEEmMjC1zi9MOsBlVLHTXvA7OP9+n639UqtIcw=="],
"@jsonjoy.com/fs-print": ["@jsonjoy.com/fs-print@4.68.2", "", { "dependencies": { "@jsonjoy.com/fs-node-utils": "4.68.2", "tree-dump": "^1.1.0" }, "peerDependencies": { "tslib": "2" } }, "sha512-cBABQmZJXig6bahwNka3+yPNGUF1GeMWbR76ZM1N2ajgCd+S+twZigCoe9+0ueZmkhM9xd2a7688Gy/ch7T+2w=="],
"@jsonjoy.com/fs-snapshot": ["@jsonjoy.com/fs-snapshot@4.68.2", "", { "dependencies": { "@jsonjoy.com/buffers": "^17.65.0", "@jsonjoy.com/fs-node-utils": "4.68.2", "@jsonjoy.com/json-pack": "^17.65.0", "@jsonjoy.com/util": "^17.65.0" }, "peerDependencies": { "tslib": "2" } }, "sha512-Aix7+NM38LzvewM0T3PICSgFdF5BVCtVgsjNsrlDPGc9hiMgJzReTDDl2/elgl0A9USMl3QP27x5WwxZSOtrfw=="],
"@jsonjoy.com/json-pack": ["@jsonjoy.com/json-pack@1.21.0", "", { "dependencies": { "@jsonjoy.com/base64": "^1.1.2", "@jsonjoy.com/buffers": "^1.2.0", "@jsonjoy.com/codegen": "^1.0.0", "@jsonjoy.com/json-pointer": "^1.0.2", "@jsonjoy.com/util": "^1.9.0", "hyperdyperid": "^1.2.0", "thingies": "^2.5.0", "tree-dump": "^1.1.0" }, "peerDependencies": { "tslib": "2" } }, "sha512-+AKG+R2cfZMShzrF2uQw34v3zbeDYUqnQ+jg7ORic3BGtfw9p/+N6RJbq/kkV8JmYZaINknaEQ2m0/f693ZPpg=="],
"@jsonjoy.com/json-pointer": ["@jsonjoy.com/json-pointer@1.0.2", "", { "dependencies": { "@jsonjoy.com/codegen": "^1.0.0", "@jsonjoy.com/util": "^1.9.0" }, "peerDependencies": { "tslib": "2" } }, "sha512-Fsn6wM2zlDzY1U+v4Nc8bo3bVqgfNTGcn6dMgs6FjrEnt4ZCe60o6ByKRjOGlI2gow0aE/Q41QOigdTqkyK5fg=="],
"@jsonjoy.com/util": ["@jsonjoy.com/util@1.9.0", "", { "dependencies": { "@jsonjoy.com/buffers": "^1.0.0", "@jsonjoy.com/codegen": "^1.0.0" }, "peerDependencies": { "tslib": "2" } }, "sha512-pLuQo+VPRnN8hfPqUTLTHk126wuYdXVxE6aDmjSeV4NCAgyxWbiOIeNJVtID3h1Vzpoi9m4jXezf73I6LgabgQ=="],
"@kwsites/file-exists": ["@kwsites/file-exists@1.1.1", "", { "dependencies": { "debug": "^4.1.1" } }, "sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw=="],
"@lexical/a11y": ["@lexical/a11y@0.49.0", "", { "dependencies": { "@lexical/extension": "0.49.0", "@lexical/utils": "0.49.0", "lexical": "0.49.0" }, "peerDependencies": { "typescript": ">=5.2" }, "optionalPeers": ["typescript"] }, "sha512-ypvO0SI9DCzEAjxkRLq+gNzRqfjg632RCkwu16Hk94PCBrEmcDhx5iUGg3SRJC7WnM2wXC/F/SB8yWDEfq7tEw=="],
@@ -918,8 +905,6 @@
"@pkgjs/parseargs": ["@pkgjs/parseargs@0.11.0", "", {}, "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg=="],
"@pkgr/core": ["@pkgr/core@0.3.6", "", {}, "sha512-SEeaJLb3qBNF/OaXnaR1NmmBbFYk1zC0ZH/52fATcRPLFg/p791YrcyFFy44Bo9sLaGuSuLp5Q6axbb/O+v/RA=="],
"@playwright/test": ["@playwright/test@1.61.1", "", { "dependencies": { "playwright": "1.61.1" }, "bin": { "playwright": "cli.js" } }, "sha512-8nKv6+0RJSL9FE4jYOEGXnPeM/Hg12qZpmqzZjRh3qM0Y7c3z1mrOTfFLids72RDQYVh9WpLEfR5WdpNX4fkig=="],
"@pondwader/socks5-server": ["@pondwader/socks5-server@1.0.10", "", {}, "sha512-bQY06wzzR8D2+vVCUoBsr5QS2U6UgPUQRmErNwtsuI6vLcyRKkafjkr3KxbtGFf9aBBIV2mcvlsKD1UYaIV+sg=="],
@@ -1148,6 +1133,8 @@
"@shumai/e2e": ["@shumai/e2e@workspace:packages/e2e"],
"@shumai/operations": ["@shumai/operations@workspace:packages/operations"],
"@shumai/premiere-uxp": ["@shumai/premiere-uxp@workspace:apps/premiere-uxp"],
"@shumai/tableprinter": ["@shumai/tableprinter@workspace:packages/tableprinter"],
@@ -1380,38 +1367,8 @@
"@swc-uxp-wrappers/utils": ["@swc-uxp-wrappers/utils@2.0.1", "", { "dependencies": { "@swc-uxp-internal/base": "npm:@spectrum-web-components/base@0.37.0", "@swc-uxp-internal/icon": "npm:@spectrum-web-components/icon@0.37.0", "@swc-uxp-internal/icons": "npm:@spectrum-web-components/icons@0.37.0", "@swc-uxp-internal/icons-ui": "npm:@spectrum-web-components/icons-ui@0.37.0", "@swc-uxp-internal/icons-workflow": "npm:@spectrum-web-components/icons-workflow@0.37.0", "@swc-uxp-internal/iconset": "npm:@spectrum-web-components/iconset@0.37.0", "@swc-uxp-internal/reactive-controllers": "npm:@spectrum-web-components/reactive-controllers@0.37.0", "@swc-uxp-internal/shared": "npm:@spectrum-web-components/shared@0.37.0", "@swc-uxp-internal/styles": "npm:@spectrum-web-components/styles@0.37.0", "@swc-uxp-internal/theme": "npm:@spectrum-web-components/theme@0.37.0" } }, "sha512-8vbd6fOok2/f8Tp0KPlBPUJYlMhnMGmEhiiySf/dhsOR85kiFMKf3VwILWkd0No2+fViARviDCVZbk+5F8EtNA=="],
"@swc/core": ["@swc/core@1.16.1", "", { "dependencies": { "@swc/counter": "^0.1.3", "@swc/types": "^0.1.28" }, "optionalDependencies": { "@swc/core-darwin-arm64": "1.16.1", "@swc/core-darwin-x64": "1.16.1", "@swc/core-linux-arm-gnueabihf": "1.16.1", "@swc/core-linux-arm64-gnu": "1.16.1", "@swc/core-linux-arm64-musl": "1.16.1", "@swc/core-linux-ppc64-gnu": "1.16.1", "@swc/core-linux-s390x-gnu": "1.16.1", "@swc/core-linux-x64-gnu": "1.16.1", "@swc/core-linux-x64-musl": "1.16.1", "@swc/core-win32-arm64-msvc": "1.16.1", "@swc/core-win32-ia32-msvc": "1.16.1", "@swc/core-win32-x64-msvc": "1.16.1" }, "peerDependencies": { "@swc/helpers": ">=0.5.17" }, "optionalPeers": ["@swc/helpers"] }, "sha512-nUaeu91O5QZKrQdaDCHd402ogUIoNOOjpkZNq0UomWK0G6gDaGmLhvddF1/3BXf5O8aLyo6ZPY/aMDWvaJQ/hg=="],
"@swc/core-darwin-arm64": ["@swc/core-darwin-arm64@1.16.1", "", { "os": "darwin", "cpu": "arm64" }, "sha512-zlJblJ8ncErD43lKdxjbUaUskJQf+LxiPXYcWXD8/8ZMV+7uuAT+CwjciLXpyZBd5Pq/S726bMpeeAwSeL1hhg=="],
"@swc/core-darwin-x64": ["@swc/core-darwin-x64@1.16.1", "", { "os": "darwin", "cpu": "x64" }, "sha512-IN0BmPWb0YAh/17mmlWB/HDBtTw2MfuW4hulf/tQAgTQBRH17l+z499bNJLK6LizSjqs0P7V+jU38Zj+vJC1DA=="],
"@swc/core-linux-arm-gnueabihf": ["@swc/core-linux-arm-gnueabihf@1.16.1", "", { "os": "linux", "cpu": "arm" }, "sha512-EYgrx2YOCQ2Twz2S793kqNjPkpvYVUPzzR95bIb7by+VQcyaai4lZZ2iz/tZvcFVKSNcN3/JTKwx+aBn2ZL52A=="],
"@swc/core-linux-arm64-gnu": ["@swc/core-linux-arm64-gnu@1.16.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-moyKm0YZlHdHohzm1YwgAyesqnE853rO0REMfJLFAova51wF9BNi+3ZW2PeS7Vqvn6HeJuepLpAHbBdZctxpHA=="],
"@swc/core-linux-arm64-musl": ["@swc/core-linux-arm64-musl@1.16.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-kKGBO9wdapiSzuf5ZzZ2fYtlu1BNSYtIIUxvH1ir/gcelTOREEHGDCLTDFx/2Knf878nU11A40z7LxwasEFxqA=="],
"@swc/core-linux-ppc64-gnu": ["@swc/core-linux-ppc64-gnu@1.16.1", "", { "os": "linux", "cpu": "ppc64" }, "sha512-nZ6qahtLxC3PM54cWOQZHxt4lTCF/3J4LIoWWzz6v7A+rLs8Dx54anYQf7mH3eIi8KlNpgKci/ie8ZSqFN8O7A=="],
"@swc/core-linux-s390x-gnu": ["@swc/core-linux-s390x-gnu@1.16.1", "", { "os": "linux", "cpu": "s390x" }, "sha512-4ji5PNzhYq193Z4/4xUaSoNJza6iCkDJSzhetrbB6KOYxsr+kxtQr8ePWhMJUiMt6JUWtXaZ1PYT8FhtED+nGA=="],
"@swc/core-linux-x64-gnu": ["@swc/core-linux-x64-gnu@1.16.1", "", { "os": "linux", "cpu": "x64" }, "sha512-VJQxqrisHV+B394IgrOu8YsIIXZgffnf5tO+yc9Z/hoUpuZEvuQTjWwlnpZdpyD+0nx6LTD1/3k646JYm43yJA=="],
"@swc/core-linux-x64-musl": ["@swc/core-linux-x64-musl@1.16.1", "", { "os": "linux", "cpu": "x64" }, "sha512-r9oV1mwxxsIGcLV1IQ/tw76MW3doatKze1QFWuC+a7QqJUkhY/bKTSVk6NpKKUGm2LDsE33Va8VqSClfA7vSiQ=="],
"@swc/core-win32-arm64-msvc": ["@swc/core-win32-arm64-msvc@1.16.1", "", { "os": "win32", "cpu": "arm64" }, "sha512-6huNRessoBLxWEqBm5zJXyCQ27TO7anvkdiuQ5MDO4CJni0nOXEqKtV9RllQ2TdyENKKsUMXVnIfW2hIXx/R5Q=="],
"@swc/core-win32-ia32-msvc": ["@swc/core-win32-ia32-msvc@1.16.1", "", { "os": "win32", "cpu": "ia32" }, "sha512-OVKJFUzphrGmsh+BGtcZDesx0YryV7/Yvy5XGgTqnrZfjnyfcr5uaqYQugCckdIlupc5Vs3XtDjRAj12z4ZPlw=="],
"@swc/core-win32-x64-msvc": ["@swc/core-win32-x64-msvc@1.16.1", "", { "os": "win32", "cpu": "x64" }, "sha512-Bt+VIhWYCGk4urklnkkteLUOeLv1VxigwTCeB/xC6rBZxY6IIKdDwCJf6on3E3SUGsIqmQS6QqtuJQc1VxF4Aw=="],
"@swc/counter": ["@swc/counter@0.1.3", "", {}, "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ=="],
"@swc/helpers": ["@swc/helpers@0.5.23", "", { "dependencies": { "tslib": "^2.8.0" } }, "sha512-5lSsMOTXURePglDfvuAQUqkGek9Hg2kksOYay2m0+XR++b2NWYL/4sWyuvVBIs8oKnJaxkdi9whaL/sqN13afw=="],
"@swc/types": ["@swc/types@0.1.28", "", { "dependencies": { "@swc/counter": "^0.1.3" } }, "sha512-V6Mnml8v09QALx6K0elJ7o9K/MkVDtW3t6L+7Ou/JcWtb3xwId2AH4FeOceySd2JaO87IMw4+6vSZxLm34LPbw=="],
"@tailwindcss/node": ["@tailwindcss/node@4.3.3", "", { "dependencies": { "@jridgewell/remapping": "^2.3.5", "enhanced-resolve": "^5.24.1", "jiti": "^2.7.0", "lightningcss": "1.32.0", "magic-string": "^0.30.21", "source-map-js": "^1.2.1", "tailwindcss": "4.3.3" } }, "sha512-/T8IKEsf9VTU6tLjgC7+sv2mOPtQxzE2jMw7u4Tt40Tx+QSZxpzh95/H6cMKoja9XuW7iMdLJYBB0o9G1CaAgg=="],
"@tailwindcss/oxide": ["@tailwindcss/oxide@4.3.3", "", { "optionalDependencies": { "@tailwindcss/oxide-android-arm64": "4.3.3", "@tailwindcss/oxide-darwin-arm64": "4.3.3", "@tailwindcss/oxide-darwin-x64": "4.3.3", "@tailwindcss/oxide-freebsd-x64": "4.3.3", "@tailwindcss/oxide-linux-arm-gnueabihf": "4.3.3", "@tailwindcss/oxide-linux-arm64-gnu": "4.3.3", "@tailwindcss/oxide-linux-arm64-musl": "4.3.3", "@tailwindcss/oxide-linux-x64-gnu": "4.3.3", "@tailwindcss/oxide-linux-x64-musl": "4.3.3", "@tailwindcss/oxide-wasm32-wasi": "4.3.3", "@tailwindcss/oxide-win32-arm64-msvc": "4.3.3", "@tailwindcss/oxide-win32-x64-msvc": "4.3.3" } }, "sha512-krXjAikiaFSPaK/FkAQT5UTx3VormQaiZ5hBFlJZ9UFQGB/rwg1MZIhHAG9smMQRTdyJxP6Qt5MwMtdyU5FWrA=="],
@@ -1482,22 +1439,6 @@
"@tanstack/virtual-file-routes": ["@tanstack/virtual-file-routes@1.162.0", "", {}, "sha512-uhOeFyxLcU41HzvrxsGpiWdcMbScY1EDgbZ5K7DVRMYInbLYWAC0EA/kx9wXAoSM8q82bUG2hRl8+EAjE6XAbA=="],
"@temporalio/activity": ["@temporalio/activity@1.23.0", "", { "dependencies": { "@temporalio/client": "1.23.0", "@temporalio/common": "1.23.0" } }, "sha512-BVeiizVD08yk0Ls6MhKCK+g3fPIWbVM9MLx+o990KwhCaZtRM6o1+du1/qfIIShHl6YjHk+H0ewkx2x14QQ6bA=="],
"@temporalio/client": ["@temporalio/client@1.23.0", "", { "dependencies": { "@grpc/grpc-js": "^1.12.4", "@temporalio/common": "1.23.0", "@temporalio/proto": "1.23.0", "abort-controller": "^3.0.0", "long": "^5.3.2", "nexus-rpc": "^0.0.3", "uuid": "^11.1.0" } }, "sha512-E9nXZPiKDGEDbPpRi0EyQ9i1x70fEIG26aMXZO88kKslKZnEKNPphs06xIic7bhuDoSrPsgVfdDap6o3l6IO2A=="],
"@temporalio/common": ["@temporalio/common@1.23.0", "", { "dependencies": { "@temporalio/proto": "1.23.0", "long": "^5.3.2", "ms": "3.0.0-canary.1", "nexus-rpc": "^0.0.3", "protobufjs": "^8.7.1" } }, "sha512-TaZYb/ruzgzJ8jd42EqRUCI4ispLZETt2Jigc9szES6q9edDmfncRw143HyvPi7b8n9naohYmA/IxTe9COH/dg=="],
"@temporalio/core-bridge": ["@temporalio/core-bridge@1.23.0", "", { "dependencies": { "@grpc/grpc-js": "^1.12.4", "@temporalio/common": "1.23.0" } }, "sha512-sid14odlYnci9WgB+iDLyxFbzkq+qBbRPp+CW9U1v+DLRfHlFJwpznQ1AZl4mHjtAZRGQFvDsDG0XNncl9ESSA=="],
"@temporalio/nexus": ["@temporalio/nexus@1.23.0", "", { "dependencies": { "@temporalio/client": "1.23.0", "@temporalio/common": "1.23.0", "@temporalio/proto": "1.23.0", "long": "^5.3.2", "nexus-rpc": "^0.0.3" } }, "sha512-mObGNp3thR+mTXdtKXpUvFpsdjEI9xpVjewhblKXao7Nqv6xrs7RpFiLdKfJhkEvDyfRgIk/dH5RkiCbZ58I9w=="],
"@temporalio/proto": ["@temporalio/proto@1.23.0", "", { "dependencies": { "long": "^5.3.2", "protobufjs": "^8.7.1" } }, "sha512-90JWnYEs1wyq97/SXkQGknRVMr/BCV9sZ0pOnK3fHTedVinfvz3/PBVFkeAJyU3CJqMQGnzRs9IIfsBTT1icrA=="],
"@temporalio/worker": ["@temporalio/worker@1.23.0", "", { "dependencies": { "@grpc/grpc-js": "^1.12.4", "@swc/core": "^1.3.102", "@temporalio/activity": "1.23.0", "@temporalio/client": "1.23.0", "@temporalio/common": "1.23.0", "@temporalio/core-bridge": "1.23.0", "@temporalio/nexus": "1.23.0", "@temporalio/proto": "1.23.0", "@temporalio/workflow": "1.23.0", "heap-js": "^2.6.0", "memfs": "^4.6.0", "nexus-rpc": "^0.0.3", "protobufjs": "^8.7.1", "rxjs": "^7.8.1", "source-map": "^0.7.4", "source-map-loader": "^5.0.0", "supports-color": "^8.1.1", "swc-loader": "^0.2.3", "unionfs": "^4.5.1", "webpack": "^5.108.4" } }, "sha512-k1MrK10lD1s7U66PFqAwGlQMRsVrfU5nCB+CjIAg5RyL7JpOzidDCz/E/jB2HobXzZnxtMcDBfBHh/BYUoyhxw=="],
"@temporalio/workflow": ["@temporalio/workflow@1.23.0", "", { "dependencies": { "@temporalio/common": "1.23.0", "@temporalio/proto": "1.23.0", "nexus-rpc": "^0.0.3" } }, "sha512-dHQnYmxU/QN7VfTmdfCfpdfTS1w0hoW/NQ7Zefr55QnqLwZw+E0Vn6S4fAbJrpfHrsAmezUZQFVLi+Z4Sq+jzA=="],
"@testcontainers/postgresql": ["@testcontainers/postgresql@12.1.0", "", { "dependencies": { "testcontainers": "^12.1.0" } }, "sha512-Pjf2VSVNirEPfz36nidyrVAnZvc2YhajOznY4VgyEsvfTd5qiMNOuPq96drREvxAUtXl5SFLX7vXj7sSq4aTcA=="],
"@testing-library/dom": ["@testing-library/dom@10.4.1", "", { "dependencies": { "@babel/code-frame": "^7.10.4", "@babel/runtime": "^7.12.5", "@types/aria-query": "^5.0.1", "aria-query": "5.3.0", "dom-accessibility-api": "^0.5.9", "lz-string": "^1.5.0", "picocolors": "1.1.1", "pretty-format": "^27.0.2" } }, "sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg=="],
@@ -1510,7 +1451,7 @@
"@types/aria-query": ["@types/aria-query@5.0.4", "", {}, "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw=="],
"@types/bun": ["@types/bun@1.4.0", "", { "dependencies": { "bun-types": "1.4.0" } }, "sha512-K+lZULY23vRgK/CfTjFIV+tyifaNdSMlPh9j+6mQ/cLfpOznLyAuzgV/JQysyECpkBQLVMSyvjlr2fBUSA9wFQ=="],
"@types/bun": ["@types/bun@1.4.3", "", { "dependencies": { "bun-types": "1.4.3" } }, "sha512-N67Pqy8JXbAY/j0tNraS3V5mubGvc6rrrNDmDCtZLlFzccbUJPDb0tvgUBC5q4m8ybkP93Jcn1QB+RYQ6PvBhw=="],
"@types/chai": ["@types/chai@5.2.3", "", { "dependencies": { "@types/deep-eql": "*", "assertion-error": "^2.0.1" } }, "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA=="],
@@ -1664,42 +1605,8 @@
"@vitest/utils": ["@vitest/utils@4.1.11", "", { "dependencies": { "@vitest/pretty-format": "4.1.11", "convert-source-map": "^2.0.0", "tinyrainbow": "^3.1.0" } }, "sha512-zTCVGpyFsGWBhllOyKlTw/vnr6D9qxsfSDyfbyZmTyjHw5N/VuvzHpHoQjm2ZJzn4RJgx5w4r7V0er69CmLgPQ=="],
"@webassemblyjs/ast": ["@webassemblyjs/ast@1.14.1", "", { "dependencies": { "@webassemblyjs/helper-numbers": "1.13.2", "@webassemblyjs/helper-wasm-bytecode": "1.13.2" } }, "sha512-nuBEDgQfm1ccRp/8bCQrx1frohyufl4JlbMMZ4P1wpeOfDhF6FQkxZJ1b/e+PLwr6X1Nhw6OLme5usuBWYBvuQ=="],
"@webassemblyjs/floating-point-hex-parser": ["@webassemblyjs/floating-point-hex-parser@1.13.2", "", {}, "sha512-6oXyTOzbKxGH4steLbLNOu71Oj+C8Lg34n6CqRvqfS2O71BxY6ByfMDRhBytzknj9yGUPVJ1qIKhRlAwO1AovA=="],
"@webassemblyjs/helper-api-error": ["@webassemblyjs/helper-api-error@1.13.2", "", {}, "sha512-U56GMYxy4ZQCbDZd6JuvvNV/WFildOjsaWD3Tzzvmw/mas3cXzRJPMjP83JqEsgSbyrmaGjBfDtV7KDXV9UzFQ=="],
"@webassemblyjs/helper-buffer": ["@webassemblyjs/helper-buffer@1.14.1", "", {}, "sha512-jyH7wtcHiKssDtFPRB+iQdxlDf96m0E39yb0k5uJVhFGleZFoNw1c4aeIcVUPPbXUVJ94wwnMOAqUHyzoEPVMA=="],
"@webassemblyjs/helper-numbers": ["@webassemblyjs/helper-numbers@1.13.2", "", { "dependencies": { "@webassemblyjs/floating-point-hex-parser": "1.13.2", "@webassemblyjs/helper-api-error": "1.13.2", "@xtuc/long": "4.2.2" } }, "sha512-FE8aCmS5Q6eQYcV3gI35O4J789wlQA+7JrqTTpJqn5emA4U2hvwJmvFRC0HODS+3Ye6WioDklgd6scJ3+PLnEA=="],
"@webassemblyjs/helper-wasm-bytecode": ["@webassemblyjs/helper-wasm-bytecode@1.13.2", "", {}, "sha512-3QbLKy93F0EAIXLh0ogEVR6rOubA9AoZ+WRYhNbFyuB70j3dRdwH9g+qXhLAO0kiYGlg3TxDV+I4rQTr/YNXkA=="],
"@webassemblyjs/helper-wasm-section": ["@webassemblyjs/helper-wasm-section@1.14.1", "", { "dependencies": { "@webassemblyjs/ast": "1.14.1", "@webassemblyjs/helper-buffer": "1.14.1", "@webassemblyjs/helper-wasm-bytecode": "1.13.2", "@webassemblyjs/wasm-gen": "1.14.1" } }, "sha512-ds5mXEqTJ6oxRoqjhWDU83OgzAYjwsCV8Lo/N+oRsNDmx/ZDpqalmrtgOMkHwxsG0iI//3BwWAErYRHtgn0dZw=="],
"@webassemblyjs/ieee754": ["@webassemblyjs/ieee754@1.13.2", "", { "dependencies": { "@xtuc/ieee754": "^1.2.0" } }, "sha512-4LtOzh58S/5lX4ITKxnAK2USuNEvpdVV9AlgGQb8rJDHaLeHciwG4zlGr0j/SNWlr7x3vO1lDEsuePvtcDNCkw=="],
"@webassemblyjs/leb128": ["@webassemblyjs/leb128@1.13.2", "", { "dependencies": { "@xtuc/long": "4.2.2" } }, "sha512-Lde1oNoIdzVzdkNEAWZ1dZ5orIbff80YPdHx20mrHwHrVNNTjNr8E3xz9BdpcGqRQbAEa+fkrCb+fRFTl/6sQw=="],
"@webassemblyjs/utf8": ["@webassemblyjs/utf8@1.13.2", "", {}, "sha512-3NQWGjKTASY1xV5m7Hr0iPeXD9+RDobLll3T9d2AO+g3my8xy5peVyjSag4I50mR1bBSN/Ct12lo+R9tJk0NZQ=="],
"@webassemblyjs/wasm-edit": ["@webassemblyjs/wasm-edit@1.14.1", "", { "dependencies": { "@webassemblyjs/ast": "1.14.1", "@webassemblyjs/helper-buffer": "1.14.1", "@webassemblyjs/helper-wasm-bytecode": "1.13.2", "@webassemblyjs/helper-wasm-section": "1.14.1", "@webassemblyjs/wasm-gen": "1.14.1", "@webassemblyjs/wasm-opt": "1.14.1", "@webassemblyjs/wasm-parser": "1.14.1", "@webassemblyjs/wast-printer": "1.14.1" } }, "sha512-RNJUIQH/J8iA/1NzlE4N7KtyZNHi3w7at7hDjvRNm5rcUXa00z1vRz3glZoULfJ5mpvYhLybmVcwcjGrC1pRrQ=="],
"@webassemblyjs/wasm-gen": ["@webassemblyjs/wasm-gen@1.14.1", "", { "dependencies": { "@webassemblyjs/ast": "1.14.1", "@webassemblyjs/helper-wasm-bytecode": "1.13.2", "@webassemblyjs/ieee754": "1.13.2", "@webassemblyjs/leb128": "1.13.2", "@webassemblyjs/utf8": "1.13.2" } }, "sha512-AmomSIjP8ZbfGQhumkNvgC33AY7qtMCXnN6bL2u2Js4gVCg8fp735aEiMSBbDR7UQIj90n4wKAFUSEd0QN2Ukg=="],
"@webassemblyjs/wasm-opt": ["@webassemblyjs/wasm-opt@1.14.1", "", { "dependencies": { "@webassemblyjs/ast": "1.14.1", "@webassemblyjs/helper-buffer": "1.14.1", "@webassemblyjs/wasm-gen": "1.14.1", "@webassemblyjs/wasm-parser": "1.14.1" } }, "sha512-PTcKLUNvBqnY2U6E5bdOQcSM+oVP/PmrDY9NzowJjislEjwP/C4an2303MCVS2Mg9d3AJpIGdUFIQQWbPds0Sw=="],
"@webassemblyjs/wasm-parser": ["@webassemblyjs/wasm-parser@1.14.1", "", { "dependencies": { "@webassemblyjs/ast": "1.14.1", "@webassemblyjs/helper-api-error": "1.13.2", "@webassemblyjs/helper-wasm-bytecode": "1.13.2", "@webassemblyjs/ieee754": "1.13.2", "@webassemblyjs/leb128": "1.13.2", "@webassemblyjs/utf8": "1.13.2" } }, "sha512-JLBl+KZ0R5qB7mCnud/yyX08jWFw5MsoalJ1pQ4EdFlgj9VdXKGuENGsiCIjegI1W7p91rUlcB/LB5yRJKNTcQ=="],
"@webassemblyjs/wast-printer": ["@webassemblyjs/wast-printer@1.14.1", "", { "dependencies": { "@webassemblyjs/ast": "1.14.1", "@xtuc/long": "4.2.2" } }, "sha512-kPSSXE6De1XOR820C90RIo2ogvZG+c3KiHzqUoO/F34Y2shGzesfqv7o57xrxovZJH/MetF5UjroJ/R/3isoiw=="],
"@workflow/serde": ["@workflow/serde@4.1.0", "", {}, "sha512-pav4F2BoirECWR7Nf1TKt+2eETcBj7jj4cBefQ8VXQCA6NPkaKeLfj/zMgi+3zYV5ZIBT4GuUiphsj0/b9hPQQ=="],
"@xtuc/ieee754": ["@xtuc/ieee754@1.2.0", "", {}, "sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA=="],
"@xtuc/long": ["@xtuc/long@4.2.2", "", {}, "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ=="],
"abort-controller": ["abort-controller@3.0.0", "", { "dependencies": { "event-target-shim": "^5.0.0" } }, "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg=="],
"acorn": ["acorn@8.18.0", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ=="],
@@ -1714,10 +1621,6 @@
"ajv": ["ajv@6.15.0", "", { "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" } }, "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw=="],
"ajv-formats": ["ajv-formats@2.1.1", "", { "dependencies": { "ajv": "^8.0.0" } }, "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA=="],
"ajv-keywords": ["ajv-keywords@5.1.0", "", { "dependencies": { "fast-deep-equal": "^3.1.3" }, "peerDependencies": { "ajv": "^8.8.2" } }, "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw=="],
"ansi-regex": ["ansi-regex@5.0.1", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="],
"ansi-styles": ["ansi-styles@5.2.0", "", {}, "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA=="],
@@ -1794,9 +1697,9 @@
"bcrypt-pbkdf": ["bcrypt-pbkdf@1.0.2", "", { "dependencies": { "tweetnacl": "^0.14.3" } }, "sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w=="],
"better-auth": ["better-auth@1.6.11", "", { "dependencies": { "@better-auth/core": "1.6.11", "@better-auth/drizzle-adapter": "1.6.11", "@better-auth/kysely-adapter": "1.6.11", "@better-auth/memory-adapter": "1.6.11", "@better-auth/mongo-adapter": "1.6.11", "@better-auth/prisma-adapter": "1.6.11", "@better-auth/telemetry": "1.6.11", "@better-auth/utils": "0.4.0", "@better-fetch/fetch": "1.1.21", "@noble/ciphers": "^2.1.1", "@noble/hashes": "^2.0.1", "better-call": "1.3.5", "defu": "^6.1.4", "jose": "^6.1.3", "kysely": "^0.28.17", "nanostores": "^1.1.1", "zod": "^4.3.6" }, "peerDependencies": { "@lynx-js/react": "*", "@prisma/client": "^5.0.0 || ^6.0.0 || ^7.0.0", "@sveltejs/kit": "^2.0.0", "@tanstack/react-start": "^1.0.0", "@tanstack/solid-start": "^1.0.0", "better-sqlite3": "^12.0.0", "drizzle-kit": ">=0.31.4", "drizzle-orm": "^0.45.2", "mongodb": "^6.0.0 || ^7.0.0", "mysql2": "^3.0.0", "next": "^14.0.0 || ^15.0.0 || ^16.0.0", "pg": "^8.0.0", "prisma": "^5.0.0 || ^6.0.0 || ^7.0.0", "react": "^18.0.0 || ^19.0.0", "react-dom": "^18.0.0 || ^19.0.0", "solid-js": "^1.0.0", "svelte": "^4.0.0 || ^5.0.0", "vitest": "^2.0.0 || ^3.0.0 || ^4.0.0", "vue": "^3.0.0" }, "optionalPeers": ["@lynx-js/react", "@prisma/client", "@sveltejs/kit", "@tanstack/react-start", "@tanstack/solid-start", "better-sqlite3", "drizzle-kit", "drizzle-orm", "mongodb", "mysql2", "next", "pg", "prisma", "react", "react-dom", "solid-js", "svelte", "vitest", "vue"] }, "sha512-Wwt6+q07dwIhsp6XiM7L1qSXVUWBEtNl+eZvwM778CguFqDZFBN9Pt6LtFaHl55t8Z+Zc//5kxcbgDY8/79vFQ=="],
"better-auth": ["better-auth@1.7.12", "", { "dependencies": { "@better-auth/core": "1.7.12", "@better-auth/drizzle-adapter": "1.7.12", "@better-auth/kysely-adapter": "1.7.12", "@better-auth/memory-adapter": "1.7.12", "@better-auth/mongo-adapter": "1.7.12", "@better-auth/prisma-adapter": "1.7.12", "@better-auth/telemetry": "1.7.12", "@better-auth/utils": "0.5.0", "@better-fetch/fetch": "1.3.2", "@noble/ciphers": "^2.2.0", "@noble/hashes": "^2.2.0", "better-call": "1.4.4", "defu": "^6.1.4", "jose": "^6.2.3", "kysely": "^0.28.17 || ^0.29.0", "nanostores": "^1.3.0", "zod": "^4.5.4" }, "peerDependencies": { "@lynx-js/react": "*", "@prisma/client": "^5.0.0 || ^6.0.0 || ^7.0.0", "@sveltejs/kit": "^2.0.0 || ^3.0.0", "@tanstack/react-start": "^1.0.0", "@tanstack/solid-start": "^1.0.0", "drizzle-kit": ">=0.31.4 || >=1.0.0-beta.1", "drizzle-orm": "^0.45.2 || >=1.0.0-rc.1 <2.0.0", "mongodb": "^6.0.0 || ^7.0.0", "mysql2": "^3.0.0", "next": "^14.0.0 || ^15.0.0 || ^16.0.0", "pg": "^8.0.0", "prisma": "^5.0.0 || ^6.0.0 || ^7.0.0", "react": "^18.0.0 || ^19.0.0", "react-dom": "^18.0.0 || ^19.0.0", "solid-js": "^1.0.0", "svelte": "^4.0.0 || ^5.0.0", "vitest": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0", "vue": "^3.0.0" }, "optionalPeers": ["@lynx-js/react", "@prisma/client", "@sveltejs/kit", "@tanstack/react-start", "@tanstack/solid-start", "drizzle-kit", "drizzle-orm", "mongodb", "mysql2", "next", "pg", "prisma", "react", "react-dom", "solid-js", "svelte", "vitest", "vue"] }, "sha512-f1fEG0QdTslzbmFA+vOGFFW/XXCWkG4kBxLeH9n1vp1otTH9+ZzV6EJ6797GStWeiYYgS5Vnt9xqE12KwSyAAw=="],
"better-call": ["better-call@1.3.5", "", { "dependencies": { "@better-auth/utils": "^0.4.0", "@better-fetch/fetch": "^1.1.21", "rou3": "^0.7.12", "set-cookie-parser": "^3.0.1" }, "peerDependencies": { "zod": "^4.0.0" }, "optionalPeers": ["zod"] }, "sha512-kOFJkBP7utAQLEYrobZm3vkTH8mXq5GNgvjc5/XEST1ilVHaxXUXfeDeFlqoETMtyqS4+3/h4ONX2i++ebZrvA=="],
"better-call": ["better-call@1.4.4", "", { "dependencies": { "@better-auth/utils": "^0.5.0", "@better-fetch/fetch": "^1.3.1", "rou3": "^0.9.1", "set-cookie-parser": "^3.1.2" }, "peerDependencies": { "zod": "^4.0.0" }, "optionalPeers": ["zod"] }, "sha512-Gq4XdGFy4dmUxFEAX2nj0ycFcFbD9ZWh8YROouZoyXeF1M11TpYbplk0pDByTFF8Wz+MYa6W9052c9m7dD+mfw=="],
"better-result": ["better-result@2.10.0", "", {}, "sha512-oQhh0y1qo2/ZKdAAEvHZAqKKiHOFU5k/bW96fE2ScgQOVkJRiHwB+nOS1SgFsYqRlxMDWvefXi9Q3px7QvgNDw=="],
@@ -1818,8 +1721,6 @@
"buffer-equal-constant-time": ["buffer-equal-constant-time@1.0.1", "", {}, "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="],
"buffer-from": ["buffer-from@1.1.2", "", {}, "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="],
"buffer-image-size": ["buffer-image-size@0.6.4", "", { "dependencies": { "@types/node": "*" } }, "sha512-nEh+kZOPY1w+gcCMobZ6ETUp9WfibndnosbpwB1iJk/8Gt5ZF2bhS6+B6bPYz424KtwsR6Rflc3tCz1/ghX2dQ=="],
"buildcheck": ["buildcheck@0.0.7", "", {}, "sha512-lHblz4ahamxpTmnsk+MNTRWsjYKv965MwOrSJyeD588rR3Jcu7swE+0wN5F+PbL5cjgu/9ObkhfzEPuofEMwLA=="],
@@ -1830,7 +1731,7 @@
"bun-plugin-tailwind": ["bun-plugin-tailwind@0.1.2", "", { "peerDependencies": { "bun": ">=1.0.0" } }, "sha512-41jNC1tZRSK3s1o7pTNrLuQG8kL/0vR/JgiTmZAJ1eHwe0w5j6HFPKeqEk0WAD13jfrUC7+ULuewFBBCoADPpg=="],
"bun-types": ["bun-types@1.4.0", "", { "dependencies": { "@types/node": "*" } }, "sha512-iIKw23BspnQQYd3prITOBxeUsxBHnwzX6YJfGMuNOZzeNcMmVqzIIVGRm1l69ogaPQmb4wB6BN8mA5bE9YuC5Q=="],
"bun-types": ["bun-types@1.4.3", "", { "dependencies": { "@types/node": "*", "undici-types": "*" } }, "sha512-tinRJNGOmUN+tEAsn2y2e942n9JHRHR42iUYzDH75NmhJqVBokGSQkkfSFdNWwsANIdrK6ACH9t01M452YyTwg=="],
"byline": ["byline@5.0.0", "", {}, "sha512-s6webAy+R4SR8XVuJWt2V2rGvhnrhxN+9S15GNuTK3wKPOXFF6RNc+8ug2XhH+2s4f+uudG4kUVYmYOQWL2g0Q=="],
@@ -1862,8 +1763,6 @@
"chownr": ["chownr@1.1.4", "", {}, "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg=="],
"chrome-trace-event": ["chrome-trace-event@1.0.4", "", {}, "sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ=="],
"class-variance-authority": ["class-variance-authority@0.7.1", "", { "dependencies": { "clsx": "^2.1.1" } }, "sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg=="],
"classnames": ["classnames@2.5.1", "", {}, "sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow=="],
@@ -1886,7 +1785,7 @@
"comma-separated-tokens": ["comma-separated-tokens@2.0.3", "", {}, "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg=="],
"commander": ["commander@11.1.0", "", {}, "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ=="],
"commander": ["commander@15.0.0", "", {}, "sha512-z67u4ZhzCL/Tydu1lJARtEZYWbWaN7oYLHbsuzocr6y4N6WZAagG3RQ4FW61V1/0+jImpj293XfrcYnd1qxtPg=="],
"comment-json": ["comment-json@4.6.2", "", { "dependencies": { "array-timsort": "^1.0.3", "esprima": "^4.0.1" } }, "sha512-R2rze/hDX30uul4NZoIZ76ImSJLFxn/1/ZxtKC1L77y2X1k+yYu1joKbAtMA2Fg3hZrTOiw0I5mwVMo0cf250w=="],
@@ -1902,6 +1801,8 @@
"cookie-es": ["cookie-es@3.1.1", "", {}, "sha512-UaXxwISYJPTr9hwQxMFYZ7kNhSXboMXP+Z3TRX6f1/NyaGPfuNUZOWP1pUEb75B2HjfklIYLVRfWiFZJyC6Npg=="],
"copy-anything": ["copy-anything@3.0.5", "", { "dependencies": { "is-what": "^4.1.8" } }, "sha512-yCEafptTtb4bk7GLEQoM8KVJpxAfdBJYaXyzQEgQQQgYrZiDp8SJmGKlYza6CYjEDNstAdNdKA3UuoULlEbS6w=="],
"core-util-is": ["core-util-is@1.0.3", "", {}, "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="],
"cpu-features": ["cpu-features@0.0.10", "", { "dependencies": { "buildcheck": "~0.0.6", "nan": "^2.19.0" } }, "sha512-9IkYqtX3YHPCzoVg1Py+o9057a3i0fp7S530UWokCSaFVTc7CwXPRiOjRjBQQ18ZCNafx78YfnG+HALxtVmOGA=="],
@@ -2064,8 +1965,6 @@
"eslint-config-prettier": ["eslint-config-prettier@10.1.8", "", { "peerDependencies": { "eslint": ">=7.0.0" }, "bin": { "eslint-config-prettier": "bin/cli.js" } }, "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w=="],
"eslint-plugin-prettier": ["eslint-plugin-prettier@5.5.6", "", { "dependencies": { "prettier-linter-helpers": "^1.0.1", "synckit": "^0.11.13" }, "peerDependencies": { "@types/eslint": ">=8.0.0", "eslint": ">=8.0.0", "eslint-config-prettier": ">= 7.0.0 <10.0.0 || >=10.1.0", "prettier": ">=3.0.0" }, "optionalPeers": ["@types/eslint", "eslint-config-prettier"] }, "sha512-ifetmTcxWfz+4qRW3pH/ujdTq2jQIj59AxJMIN26K5avYgU8dxycUETQonWiW+wPrYXA0j3Try0l1CnwVQtDqQ=="],
"eslint-plugin-react": ["eslint-plugin-react@7.37.5", "", { "dependencies": { "array-includes": "^3.1.8", "array.prototype.findlast": "^1.2.5", "array.prototype.flatmap": "^1.3.3", "array.prototype.tosorted": "^1.1.4", "doctrine": "^2.1.0", "es-iterator-helpers": "^1.2.1", "estraverse": "^5.3.0", "hasown": "^2.0.2", "jsx-ast-utils": "^2.4.1 || ^3.0.0", "minimatch": "^3.1.2", "object.entries": "^1.1.9", "object.fromentries": "^2.0.8", "object.values": "^1.2.1", "prop-types": "^15.8.1", "resolve": "^2.0.0-next.5", "semver": "^6.3.1", "string.prototype.matchall": "^4.0.12", "string.prototype.repeat": "^1.0.0" }, "peerDependencies": { "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7" } }, "sha512-Qteup0SqU15kdocexFNAJMvCJEfa2xUKNV4CC1xsVMrIIqEy3SQ/rqyxCWNzfrd3/ldy6HMlD2e0JDVpDg2qIA=="],
"eslint-scope": ["eslint-scope@9.1.2", "", { "dependencies": { "@types/esrecurse": "^4.3.1", "@types/estree": "^1.0.8", "esrecurse": "^4.3.0", "estraverse": "^5.2.0" } }, "sha512-xS90H51cKw0jltxmvmHy2Iai1LIqrfbw57b79w/J7MfvDfkIkFZ+kj6zC3BjtUwh150HsSSdxXZcsuv72miDFQ=="],
@@ -2122,8 +2021,6 @@
"fast-deep-equal": ["fast-deep-equal@3.1.3", "", {}, "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="],
"fast-diff": ["fast-diff@1.3.0", "", {}, "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw=="],
"fast-fifo": ["fast-fifo@1.3.2", "", {}, "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ=="],
"fast-json-stable-stringify": ["fast-json-stable-stringify@2.1.0", "", {}, "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw=="],
@@ -2170,8 +2067,6 @@
"fs-constants": ["fs-constants@1.0.0", "", {}, "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow=="],
"fs-monkey": ["fs-monkey@1.1.0", "", {}, "sha512-QMUezzXWII9EV5aTFXW1UBVUO77wYPpjqIF8/AviUCThNeSYZykpoTixUeaNNBwmCev0AMDWMAni+f8Hxb1IFw=="],
"fsevents": ["fsevents@2.3.3", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
"function-bind": ["function-bind@1.1.2", "", {}, "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="],
@@ -2212,8 +2107,6 @@
"glob-parent": ["glob-parent@6.0.2", "", { "dependencies": { "is-glob": "^4.0.3" } }, "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A=="],
"glob-to-regex.js": ["glob-to-regex.js@1.2.0", "", { "peerDependencies": { "tslib": "2" } }, "sha512-QMwlOQKU/IzqMUOAZWubUOT8Qft+Y0KQWnX9nK3ch0CJg0tTp4TvGZsTfudYKv2NzoQSyPcnA6TYeIQ3jGichQ=="],
"globals": ["globals@17.11.0", "", {}, "sha512-Z2I8hM+PbJDXQDq3Icgpzv+mPdwr68iZUU9d5WW4FuXfDUQfkZaZuvjMv42/5crNyw154+9+VWXbYrUgDXbxNw=="],
"globalthis": ["globalthis@1.0.4", "", { "dependencies": { "define-properties": "^1.2.1", "gopd": "^1.0.1" } }, "sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ=="],
@@ -2236,8 +2129,6 @@
"has-bigints": ["has-bigints@1.1.0", "", {}, "sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg=="],
"has-flag": ["has-flag@4.0.0", "", {}, "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="],
"has-property-descriptors": ["has-property-descriptors@1.0.2", "", { "dependencies": { "es-define-property": "^1.0.0" } }, "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg=="],
"has-proto": ["has-proto@1.2.0", "", { "dependencies": { "dunder-proto": "^1.0.0" } }, "sha512-KIL7eQPfHQRC8+XluaIw7BHUwwqL19bQn4hzNgdr+1wXoU0KKj6rufu47lhY7KbJR2C6T6+PfyN0Ea7wkSS+qQ=="],
@@ -2254,8 +2145,6 @@
"he": ["he@1.2.0", "", { "bin": { "he": "bin/he" } }, "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw=="],
"heap-js": ["heap-js@2.7.1", "", {}, "sha512-EQfezRg0NCZGNlhlDR3Evrw1FVL2G3LhU7EgPoxufQKruNBSYA8MiRPHeWbU+36o+Fhel0wMwM+sLEiBAlNLJA=="],
"help-me": ["help-me@5.0.0", "", {}, "sha512-7xgomUX6ADmcYzFik0HzAxh/73YlKR9bmFzf51CZwR+b6YtzU2m0u49hQCqV6SvlqIqsaxovfwdvbnsw3b/zpg=="],
"hls.js": ["hls.js@1.7.3", "", {}, "sha512-MsPlx6yVW4Qv4C7mEVou4/gk/5cN2dVxOTnrNjPSmyH2f0Ln+/UkG10Ax1PE6OvrmTVPKgQYozTtBaPOuCzq7A=="],
@@ -2268,8 +2157,6 @@
"https-proxy-agent": ["https-proxy-agent@7.0.6", "", { "dependencies": { "agent-base": "^7.1.2", "debug": "4" } }, "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw=="],
"hyperdyperid": ["hyperdyperid@1.2.0", "", {}, "sha512-Y93lCzHYgGWdrJ66yIktxiaGULYc6oGiABxhcO5AufBeOyoIdZF7bIfLaOrbM0iGIOXQQgxxRrFEnb+Y6w1n4A=="],
"iconv-lite": ["iconv-lite@0.7.3", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ=="],
"ieee754": ["ieee754@1.2.1", "", {}, "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="],
@@ -2358,6 +2245,8 @@
"is-weakset": ["is-weakset@2.0.4", "", { "dependencies": { "call-bound": "^1.0.3", "get-intrinsic": "^1.2.6" } }, "sha512-mfcwb6IzQyOKTs84CQMrOwW4gQcaTOAWJ0zzJCl2WSPDrWk/OzDaImWFH3djXhb24g4eudZfLRozAvPGw4d9hQ=="],
"is-what": ["is-what@4.1.16", "", {}, "sha512-ZhMwEosbFJkA0YhFnNDgTM4ZxDRsS6HqTo7qsZM08fehyRYIYa0yHu5R6mgo1n/8MgaPBXiPimPD77baVFYg+A=="],
"isarray": ["isarray@2.0.5", "", {}, "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw=="],
"isbot": ["isbot@5.2.2", "", {}, "sha512-iQcBXcd+Rv/pkubRyGh2utW2j1oPG5hZY6TUhVPpqK4G+o3IbxpJNx04hgksjc/N7GK5pEorUxDeg31cFgEk/w=="],
@@ -2372,8 +2261,6 @@
"jackspeak": ["jackspeak@3.4.3", "", { "dependencies": { "@isaacs/cliui": "^8.0.2" }, "optionalDependencies": { "@pkgjs/parseargs": "^0.11.0" } }, "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw=="],
"jest-worker": ["jest-worker@27.5.1", "", { "dependencies": { "@types/node": "*", "merge-stream": "^2.0.0", "supports-color": "^8.0.0" } }, "sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg=="],
"jiti": ["jiti@2.7.0", "", { "bin": { "jiti": "lib/jiti-cli.mjs" } }, "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ=="],
"jittered-fractional-indexing": ["jittered-fractional-indexing@1.0.1", "", { "dependencies": { "fractional-indexing": "^3.2.0" } }, "sha512-OpKFkVr4hU5ivd1ZCjZfHvVpWekraJvcePcMusBmgBmCVQK5JiRCA+4TT1vAUTLqGD9MkhqFwO0l3QspvlZgzw=="],
@@ -2496,10 +2383,6 @@
"mdast-util-to-string": ["mdast-util-to-string@4.0.0", "", { "dependencies": { "@types/mdast": "^4.0.0" } }, "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg=="],
"memfs": ["memfs@4.68.2", "", { "dependencies": { "@jsonjoy.com/fs-core": "4.68.2", "@jsonjoy.com/fs-fsa": "4.68.2", "@jsonjoy.com/fs-node": "4.68.2", "@jsonjoy.com/fs-node-builtins": "4.68.2", "@jsonjoy.com/fs-node-to-fsa": "4.68.2", "@jsonjoy.com/fs-node-utils": "4.68.2", "@jsonjoy.com/fs-print": "4.68.2", "@jsonjoy.com/fs-snapshot": "4.68.2", "@jsonjoy.com/json-pack": "^1.11.0", "@jsonjoy.com/util": "^1.9.0", "glob-to-regex.js": "^1.0.1", "thingies": "^2.5.0", "tree-dump": "^1.0.3", "tslib": "^2.0.0" } }, "sha512-Un1ElEBoIdPI9kg0sm3LebVEuEViodfIvlaG8Z1MFXa7ZnR9vWuPKUo3dt/vuWY2ivc05l76B5QOjdgCzAzmGw=="],
"merge-stream": ["merge-stream@2.0.0", "", {}, "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w=="],
"micromark": ["micromark@4.0.2", "", { "dependencies": { "@types/debug": "^4.0.0", "debug": "^4.0.0", "decode-named-character-reference": "^1.0.0", "devlop": "^1.0.0", "micromark-core-commonmark": "^2.0.0", "micromark-factory-space": "^2.0.0", "micromark-util-character": "^2.0.0", "micromark-util-chunked": "^2.0.0", "micromark-util-combine-extensions": "^2.0.0", "micromark-util-decode-numeric-character-reference": "^2.0.0", "micromark-util-encode": "^2.0.0", "micromark-util-normalize-identifier": "^2.0.0", "micromark-util-resolve-all": "^2.0.0", "micromark-util-sanitize-uri": "^2.0.0", "micromark-util-subtokenize": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, "sha512-zpe98Q6kvavpCr1NPVSCMebCKfD7CA2NqZ+rykeNhONIJBpc1tFKt9hucLGwha3jNTNI8lHpctWJWoimVF4PfA=="],
"micromark-core-commonmark": ["micromark-core-commonmark@2.0.3", "", { "dependencies": { "decode-named-character-reference": "^1.0.0", "devlop": "^1.0.0", "micromark-factory-destination": "^2.0.0", "micromark-factory-label": "^2.0.0", "micromark-factory-space": "^2.0.0", "micromark-factory-title": "^2.0.0", "micromark-factory-whitespace": "^2.0.0", "micromark-util-character": "^2.0.0", "micromark-util-chunked": "^2.0.0", "micromark-util-classify-character": "^2.0.0", "micromark-util-html-tag-name": "^2.0.0", "micromark-util-normalize-identifier": "^2.0.0", "micromark-util-resolve-all": "^2.0.0", "micromark-util-subtokenize": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, "sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg=="],
@@ -2542,16 +2425,12 @@
"micromark-util-types": ["micromark-util-types@2.0.2", "", {}, "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA=="],
"mime-db": ["mime-db@1.54.0", "", {}, "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ=="],
"mime-match": ["mime-match@1.0.2", "", { "dependencies": { "wildcard": "^1.1.0" } }, "sha512-VXp/ugGDVh3eCLOBCiHZMYWQaTNUHv2IJrut+yXA6+JbLPXHglHwfS/5A5L0ll+jkCY7fIzRJcH6OIunF+c6Cg=="],
"minimatch": ["minimatch@10.2.6", "", { "dependencies": { "brace-expansion": "^5.0.8" } }, "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A=="],
"minimist": ["minimist@1.2.8", "", {}, "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA=="],
"minimizer-webpack-plugin": ["minimizer-webpack-plugin@5.8.0", "", { "dependencies": { "@jridgewell/trace-mapping": "^0.3.31", "jest-worker": "^27.4.5", "schema-utils": "^4.3.3", "terser": "^5.51.0" }, "peerDependencies": { "@minify-html/node": "*", "@swc/core": "*", "@swc/css": "*", "@swc/html": "*", "clean-css": "*", "cssnano": "*", "csso": "*", "esbuild": "*", "html-minifier-terser": "*", "lightningcss": "*", "postcss": "*", "uglify-js": "*", "webpack": "^5.1.0" }, "optionalPeers": ["@minify-html/node", "@swc/core", "@swc/css", "@swc/html", "clean-css", "cssnano", "csso", "esbuild", "html-minifier-terser", "lightningcss", "postcss", "uglify-js"] }, "sha512-2cT9+goJfBhtMz+gJqejSf09ClgmYhPhccRb/fb0ztVbixt0BkO8mRuI26FoPPuUNkRk6iEDryWAIouc5W8eJA=="],
"minipass": ["minipass@7.1.3", "", {}, "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A=="],
"mkdirp": ["mkdirp@3.0.1", "", { "bin": { "mkdirp": "dist/cjs/src/bin.js" } }, "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg=="],
@@ -2574,12 +2453,8 @@
"natural-compare": ["natural-compare@1.4.0", "", {}, "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw=="],
"neo-async": ["neo-async@2.6.2", "", {}, "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw=="],
"next-themes": ["next-themes@0.4.6", "", { "peerDependencies": { "react": "^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc", "react-dom": "^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc" } }, "sha512-pZvgD5L0IEvX5/9GWyHMf3m8BKiVQwsCMHfoFosXtXBMnaS0ZnIJ9ST4b4NqLVKDEm8QBxoNNGNaBv2JNF6XNA=="],
"nexus-rpc": ["nexus-rpc@0.0.3", "", {}, "sha512-ksIBeYHDv6FHAR1h3Vwk0kQ6REhdo1STqDHXMzu/yn/VN/XzgOor2IUjewG6paoA7IgxlIPZoOU/PD78PC6HTg=="],
"node-domexception": ["node-domexception@1.0.0", "", {}, "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="],
"node-emoji": ["node-emoji@2.2.0", "", { "dependencies": { "@sindresorhus/is": "^4.6.0", "char-regex": "^1.0.2", "emojilib": "^2.4.0", "skin-tone": "^2.0.0" } }, "sha512-Z3lTE9pLaJF47NyMhd4ww1yFTAP8YhYI8SleJiHzM46Fgpm5cnNzSl9XfzFNqbaz+VlJrIj3fXQ4DeN1Rjm6cw=="],
@@ -2720,8 +2595,6 @@
"prettier": ["prettier@3.9.6", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-OpN0zzVdiaiAhxpuuj5efpIS4sY9j7bY6uR5mnj5yPzGkdkjNKSJeUThPb60Jw29QuAZgA4o+/iB49kFiaBX6g=="],
"prettier-linter-helpers": ["prettier-linter-helpers@1.0.1", "", { "dependencies": { "fast-diff": "^1.1.2" } }, "sha512-SxToR7P8Y2lWmv/kTzVLC1t/GDI2WGjMwNhLLE9qtH8Q13C+aEmuRlzDst4Up4s0Wc8sF2M+J57iB3cMLqftfg=="],
"pretty-format": ["pretty-format@27.5.1", "", { "dependencies": { "ansi-regex": "^5.0.1", "ansi-styles": "^5.0.0", "react-is": "^17.0.1" } }, "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ=="],
"prisma": ["prisma@7.10.0", "", { "dependencies": { "@prisma/config": "7.10.0", "@prisma/dev": "0.24.17", "@prisma/engines": "7.10.0", "@prisma/studio-core": "0.33.0", "mysql2": "3.15.3", "postgres": "3.4.7" }, "peerDependencies": { "better-sqlite3": ">=9.0.0", "typescript": ">=5.4.0" }, "optionalPeers": ["better-sqlite3", "typescript"], "bin": { "prisma": "build/index.js" } }, "sha512-o0ornyJOWgygVAzGCpr8PdXV8EJLHyVGDDUr/voBQt8Azzw8cYTByzzPGcA/m4tCkPcnJA8raEOv2CslsKhPEw=="],
@@ -2828,9 +2701,7 @@
"rolldown": ["rolldown@1.2.6", "", { "dependencies": { "@oxc-project/types": "=0.147.0", "@rolldown/pluginutils": "^1.0.0" }, "optionalDependencies": { "@rolldown/binding-android-arm-eabi": "1.2.6", "@rolldown/binding-android-arm64": "1.2.6", "@rolldown/binding-darwin-arm64": "1.2.6", "@rolldown/binding-darwin-x64": "1.2.6", "@rolldown/binding-freebsd-x64": "1.2.6", "@rolldown/binding-linux-arm-gnueabihf": "1.2.6", "@rolldown/binding-linux-arm64-gnu": "1.2.6", "@rolldown/binding-linux-arm64-musl": "1.2.6", "@rolldown/binding-linux-ppc64-gnu": "1.2.6", "@rolldown/binding-linux-s390x-gnu": "1.2.6", "@rolldown/binding-linux-x64-gnu": "1.2.6", "@rolldown/binding-linux-x64-musl": "1.2.6", "@rolldown/binding-openharmony-arm64": "1.2.6", "@rolldown/binding-win32-arm64-msvc": "1.2.6", "@rolldown/binding-win32-x64-msvc": "1.2.6" }, "bin": { "rolldown": "./bin/cli.mjs" } }, "sha512-vMM4q3aixf46GiF1Kok8jDPFsEpXgFWGjUHXNkNHNm+Y2adXAG2dbX91jkti3i0ZRsOlcmbuzAz1poObSHCmUA=="],
"rou3": ["rou3@0.7.12", "", {}, "sha512-iFE4hLDuloSWcD7mjdCDhx2bKcIsYbtOTpfH5MHHLSKMOUyjqQXTeZVa289uuwEGEKFoE/BAPbhaU4B774nceg=="],
"rxjs": ["rxjs@7.8.2", "", { "dependencies": { "tslib": "^2.1.0" } }, "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA=="],
"rou3": ["rou3@0.9.2", "", {}, "sha512-3SOzvaAg8rkHrXtRjpCvCvbyO5to9oOO27Z/XqHEYXfMRVSw/qMIVdmaOk9W2lcRLtR6dlqTjo9hDeJk70QBYQ=="],
"safe-array-concat": ["safe-array-concat@1.1.4", "", { "dependencies": { "call-bind": "^1.0.9", "call-bound": "^1.0.4", "get-intrinsic": "^1.3.0", "has-symbols": "^1.1.0", "isarray": "^2.0.5" } }, "sha512-wtZlHyOje6OZTGqAoaDKxFkgRtkF9CnHAVnCHKfuj200wAgL+bSJhdsCD2l0Qx/2ekEXjPWcyKkfGb5CPboslg=="],
@@ -2848,14 +2719,14 @@
"scheduler": ["scheduler@0.27.0", "", {}, "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q=="],
"schema-utils": ["schema-utils@4.3.3", "", { "dependencies": { "@types/json-schema": "^7.0.9", "ajv": "^8.9.0", "ajv-formats": "^2.1.1", "ajv-keywords": "^5.1.0" } }, "sha512-eflK8wEtyOE6+hsaRVPxvUKYCpRgzLqDTb8krvAsRIwOGlHoSgYLgBXoubGgLd2fT41/OUYdb48v4k4WWHQurA=="],
"secure-json-parse": ["secure-json-parse@4.1.0", "", {}, "sha512-l4KnYfEyqYJxDwlNVyRfO2E4NTHfMKAWdUuA8J0yve2Dz/E/PdBepY03RvyJpssIpRFwJoCD55wA+mEDs6ByWA=="],
"semver": ["semver@6.3.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="],
"seq-queue": ["seq-queue@0.0.5", "", {}, "sha512-hr3Wtp/GZIc/6DAGPDcV4/9WoZhjrkXsi5B/07QgX8tsdc6ilr7BFM6PM6rbdAX1kFSDYeZGLipIZZKyQP0O5Q=="],
"serialize-error": ["serialize-error@8.1.0", "", { "dependencies": { "type-fest": "^0.20.2" } }, "sha512-3NnuWfM6vBYoy5gZFvHiYsVbafvI9vZv/+jlIigFn4oP4zjNPK3LhcY0xSCgeb1a5L8jO71Mit9LlNoi2UfDDQ=="],
"seroval": ["seroval@1.6.4", "", {}, "sha512-LErWMNS2RRFdu2RMA5u/PA59/IWs0XsikyEXGQ2/36iEWFrdG0ABmg17E17cikrv76891kOAMq3TkTFXpwAHXw=="],
"seroval-plugins": ["seroval-plugins@1.6.4", "", { "peerDependencies": { "seroval": "^1.0" } }, "sha512-R0f1U9hmn38+dFMz6b6ab8lwucmw4AtiY7St+JPWudy1dm+Bs3g884nyrsH9Cy6rKpZKLYayXuMda9GZ/fl8JQ=="],
@@ -2892,14 +2763,8 @@
"sonner": ["sonner@2.0.8", "", { "peerDependencies": { "@types/react": "^18.0.0 || ^19.0.0", "react": "^18.0.0 || ^19.0.0 || ^19.0.0-rc", "react-dom": "^18.0.0 || ^19.0.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-UM/ByIoFra8yzV75n1o0Puu0bw5U/9UNnDacrJNspekBewIfsQ3D6ez1nvlWpt7aTsO6rujQtifBpycwIivqlg=="],
"source-map": ["source-map@0.7.6", "", {}, "sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ=="],
"source-map-js": ["source-map-js@1.2.1", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="],
"source-map-loader": ["source-map-loader@5.0.0", "", { "dependencies": { "iconv-lite": "^0.6.3", "source-map-js": "^1.0.2" }, "peerDependencies": { "webpack": "^5.72.1" } }, "sha512-k2Dur7CbSLcAH73sBcIkV5xjPV4SzqO1NJ7+XaQl8if3VODDUj3FNchNGpqgJSKbvUfJuhVdv8K2Eu8/TNl2eA=="],
"source-map-support": ["source-map-support@0.5.21", "", { "dependencies": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" } }, "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w=="],
"space-separated-tokens": ["space-separated-tokens@2.0.2", "", {}, "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q=="],
"split-ca": ["split-ca@1.0.1", "", {}, "sha512-Q5thBSxp5t8WPTTJQS59LrGqOZqOsrhDGDVm8azCqIBjSBd7nd9o2PM+mDulQQkh8h//4U6hFZnc/mul8t5pWQ=="],
@@ -2950,14 +2815,10 @@
"style-to-object": ["style-to-object@1.0.14", "", { "dependencies": { "inline-style-parser": "0.2.7" } }, "sha512-LIN7rULI0jBscWQYaSswptyderlarFkjQ+t79nzty8tcIAceVomEVlLzH5VP4Cmsv6MtKhs7qaAiwlcp+Mgaxw=="],
"supports-color": ["supports-color@8.1.1", "", { "dependencies": { "has-flag": "^4.0.0" } }, "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q=="],
"superjson": ["superjson@1.13.3", "", { "dependencies": { "copy-anything": "^3.0.2" } }, "sha512-mJiVjfd2vokfDxsQPOwJ/PtanO87LhpYY88ubI5dUB1Ab58Txbyje3+jpm+/83R/fevaq/107NNhtYBLuoTrFg=="],
"supports-preserve-symlinks-flag": ["supports-preserve-symlinks-flag@1.0.0", "", {}, "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w=="],
"swc-loader": ["swc-loader@0.2.7", "", { "dependencies": { "@swc/counter": "^0.1.3" }, "peerDependencies": { "@swc/core": "^1.2.147", "webpack": ">=2" } }, "sha512-nwYWw3Fh9ame3Rtm7StS9SBLpHRRnYcK7bnpF3UKZmesAK0gw2/ADvlURFAINmPvKtDLzp+GBiP9yLoEjg6S9w=="],
"synckit": ["synckit@0.11.13", "", { "dependencies": { "@pkgr/core": "^0.3.6" } }, "sha512-eNRKgb3z66Yp3D2CixVujOUvXLFUTij/zVnV8KRyvFdQwpz7I5DS8UfRkTeLzb64u+dkzDSdelE24izu+zSSUg=="],
"tabbable": ["tabbable@6.5.0", "", {}, "sha512-wieBHXygIm7OyQOu5hQlkk62/WyCFYGlWg7L6/ZCUZwx0o398Zkn4pVmMyfYhfMG8kGrj/Krt8eIk6UKC6VzwA=="],
"tailwind-merge": ["tailwind-merge@3.6.0", "", {}, "sha512-uxL7qAVQriqRQPAyK3pj66VqskWqoZ37PW94jwOTwNfq/z9oyu1V+eqrZqtR2+fCiXdYOZe/Modt8GtvqNzu+w=="],
@@ -2974,14 +2835,10 @@
"teex": ["teex@1.0.1", "", { "dependencies": { "streamx": "^2.12.5" } }, "sha512-eYE6iEI62Ni1H8oIa7KlDU6uQBtqr4Eajni3wX7rpfXD8ysFx8z0+dri+KWEPWpBsxXfxu58x/0jvTVT1ekOSg=="],
"terser": ["terser@5.51.2", "", { "dependencies": { "@jridgewell/source-map": "^0.3.3", "acorn": "^8.15.0", "commander": "^2.20.0", "source-map-support": "~0.5.20" }, "bin": { "terser": "bin/terser" } }, "sha512-bWnjSNscmuI+GJze6ZupnHP8G/cTcsJF+bXCeQknk2SHQsgbNJnLrqiH9jZ2W4STPVXH2mDKKRX3iwPhc9Cn/Q=="],
"testcontainers": ["testcontainers@12.1.0", "", { "dependencies": { "@balena/dockerignore": "^1.0.2", "@types/dockerode": "^4.0.1", "archiver": "^7.0.1", "async-lock": "^1.4.1", "byline": "^5.0.0", "debug": "^4.4.3", "docker-compose": "^1.4.2", "dockerode": "^5.0.1", "get-port": "^5.1.1", "proper-lockfile": "^4.1.2", "properties-reader": "^3.0.1", "ssh-remote-port-forward": "^1.0.4", "tar-fs": "^3.1.3", "tmp": "^0.2.7", "undici": "^8.9.0" } }, "sha512-YjDLqIITuhGLMnM10yhg3oV6lIG5IMpz1R1DPBZoOOks83q7i7IVpeSWRTiyl7roozjiyLmwIoLK/KY8OnZmIA=="],
"text-decoder": ["text-decoder@1.2.7", "", { "dependencies": { "b4a": "^1.6.4" } }, "sha512-vlLytXkeP4xvEq2otHeJfSQIRyWxo/oZGEbXrtEEF9Hnmrdly59sUbzZ/QgyWuLYHctCHxFF4tRQZNQ9k60ExQ=="],
"thingies": ["thingies@2.6.1", "", { "peerDependencies": { "tslib": "^2" } }, "sha512-cV/CMGTK3M4MlnJ/0At6ismOw/A0EEniDNScajjz/Br3c1sqE72YD01rGpPTKwd27wAxI5Pr+6+0w8yofzFRYw=="],
"thread-stream": ["thread-stream@4.2.0", "", { "dependencies": { "real-require": "^1.0.0" } }, "sha512-e2zZ96wSChazBsbENf/Pcm/4swHt2cEKQ92rhUjkL9GCKiTDJIaTBenjE/m9DXi0QBmTMDkFDdOomUy20A1tDQ=="],
"tiny-inflate": ["tiny-inflate@1.0.3", "", {}, "sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw=="],
@@ -2998,8 +2855,6 @@
"tmp": ["tmp@0.2.7", "", {}, "sha512-e0votIpp4Uo2AJYSzVHV6xCcawuiez3DzqDAbrTc3YxBkplN6e+dM13ZeIcZnDg/QpSuU2zfZ3rzwY8ukEnaXw=="],
"tree-dump": ["tree-dump@1.1.0", "", { "peerDependencies": { "tslib": "2" } }, "sha512-rMuvhU4MCDbcbnleZTFezWsaZXRFemSqAM+7jPnzUl1fo9w3YEKOxAeui0fz3OI4EU4hf23iyA7uQRVko+UaBA=="],
"trim-lines": ["trim-lines@3.0.1", "", {}, "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg=="],
"trough": ["trough@2.2.0", "", {}, "sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw=="],
@@ -3020,6 +2875,8 @@
"type-check": ["type-check@0.4.0", "", { "dependencies": { "prelude-ls": "^1.2.1" } }, "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew=="],
"type-fest": ["type-fest@0.20.2", "", {}, "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ=="],
"typebox": ["typebox@1.3.22", "", {}, "sha512-YoX6QdtuJR/+YpP/qXf9gJXTxvSuiUlKYgW3AilsOSLlsZe/VH6ILR5vhoJM5QXY//uzIRE7NYij3h2+nG9vRQ=="],
"typed-array-buffer": ["typed-array-buffer@1.0.3", "", { "dependencies": { "call-bound": "^1.0.3", "es-errors": "^1.3.0", "is-typed-array": "^1.1.14" } }, "sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw=="],
@@ -3052,8 +2909,6 @@
"unified": ["unified@11.0.5", "", { "dependencies": { "@types/unist": "^3.0.0", "bail": "^2.0.0", "devlop": "^1.0.0", "extend": "^3.0.0", "is-plain-obj": "^4.0.0", "trough": "^2.0.0", "vfile": "^6.0.0" } }, "sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA=="],
"unionfs": ["unionfs@4.6.0", "", { "dependencies": { "fs-monkey": "^1.0.0" } }, "sha512-fJAy3gTHjFi5S3TP5EGdjs/OUMFFvI/ady3T8qVuZfkv8Qi8prV/Q8BuFEgODJslhZTT2z2qdD2lGdee9qjEnA=="],
"unist-util-is": ["unist-util-is@6.0.1", "", { "dependencies": { "@types/unist": "^3.0.0" } }, "sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g=="],
"unist-util-position": ["unist-util-position@5.0.0", "", { "dependencies": { "@types/unist": "^3.0.0" } }, "sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA=="],
@@ -3082,7 +2937,7 @@
"util-deprecate": ["util-deprecate@1.0.2", "", {}, "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="],
"uuid": ["uuid@11.1.1", "", { "bin": { "uuid": "dist/esm/bin/uuid" } }, "sha512-vIYxrBCC/N/K+Js3qSN88go7kIfNPssr/hHCesKCQNAjmgvYS2oqr69kIufEG+O4+PfezOH4EbIeHCfFov8ZgQ=="],
"uuid": ["uuid@14.0.2", "", { "bin": { "uuid": "dist-node/bin/uuid" } }, "sha512-xZe/16rV4aa+HGSOCiY2YeLT1OybRLrrkL/Rqaq7p7GMVXjFh+6wN4oMYgjFmnSnhY8t6Xpdl2l9qmnHYuMHwQ=="],
"valibot": ["valibot@1.4.2", "", { "peerDependencies": { "typescript": ">=5" }, "optionalPeers": ["typescript"] }, "sha512-gjdCvJ6d3RyHAneqxMYMW9QMCwYMb3jpOO0IyHZV1bnRHFBHrX3VkIILt5XYR0WhwHiH7Mty8ovuPZ/O3gamrg=="],
@@ -3100,14 +2955,8 @@
"vitest": ["vitest@4.1.11", "", { "dependencies": { "@vitest/expect": "4.1.11", "@vitest/mocker": "4.1.11", "@vitest/pretty-format": "4.1.11", "@vitest/runner": "4.1.11", "@vitest/snapshot": "4.1.11", "@vitest/spy": "4.1.11", "@vitest/utils": "4.1.11", "es-module-lexer": "^2.0.0", "expect-type": "^1.3.0", "magic-string": "^0.30.21", "obug": "^2.1.1", "pathe": "^2.0.3", "picomatch": "^4.0.3", "std-env": "^4.0.0-rc.1", "tinybench": "^2.9.0", "tinyexec": "^1.0.2", "tinyglobby": "^0.2.15", "tinyrainbow": "^3.1.0", "vite": "^6.0.0 || ^7.0.0 || ^8.0.0", "why-is-node-running": "^2.3.0" }, "peerDependencies": { "@edge-runtime/vm": "*", "@opentelemetry/api": "^1.9.0", "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", "@vitest/browser-playwright": "4.1.11", "@vitest/browser-preview": "4.1.11", "@vitest/browser-webdriverio": "4.1.11", "@vitest/coverage-istanbul": "4.1.11", "@vitest/coverage-v8": "4.1.11", "@vitest/ui": "4.1.11", "happy-dom": "*", "jsdom": "*" }, "optionalPeers": ["@edge-runtime/vm", "@opentelemetry/api", "@types/node", "@vitest/browser-playwright", "@vitest/browser-preview", "@vitest/browser-webdriverio", "@vitest/coverage-istanbul", "@vitest/coverage-v8", "@vitest/ui", "happy-dom", "jsdom"], "bin": { "vitest": "./vitest.mjs" } }, "sha512-fhACrNXUidIbGSBr5FlbuBkO7VWC1ZyLl0DO4CU2DrQoAPxX84Ysxs+HeGQpii5lZWV1Q4gBZTTu49mF+A6Edw=="],
"watchpack": ["watchpack@2.5.2", "", { "dependencies": { "graceful-fs": "^4.1.2" } }, "sha512-6i/00NBjP4yGPs+caKSyRfpTF/8Torsu0MOW3mMzIbhgISFder8i7xbqgHlLMwJrdiN8ndBV3UA1/AfzPSr+jg=="],
"web-streams-polyfill": ["web-streams-polyfill@3.3.3", "", {}, "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw=="],
"webpack": ["webpack@5.110.1", "", { "dependencies": { "@types/estree": "^1.0.8", "@types/json-schema": "^7.0.15", "@webassemblyjs/ast": "^1.14.1", "@webassemblyjs/wasm-edit": "^1.14.1", "@webassemblyjs/wasm-parser": "^1.14.1", "acorn": "^8.16.0", "browserslist": "^4.28.1", "chrome-trace-event": "^1.0.2", "enhanced-resolve": "^5.24.4", "es-module-lexer": "^2.1.0", "events": "^3.2.0", "graceful-fs": "^4.2.11", "mime-db": "^1.54.0", "minimizer-webpack-plugin": "^5.7.0", "neo-async": "^2.6.2", "schema-utils": "^4.3.3", "tapable": "^2.3.0", "watchpack": "^2.5.2", "webpack-sources": "^3.5.1" }, "peerDependencies": { "webpack-cli": "*" }, "optionalPeers": ["webpack-cli"], "bin": { "webpack": "bin/webpack.js" } }, "sha512-gInQB+jxXxgnZyvPwuzT5NGQmECDqeu85oxcrjinrYHqPoBex0hCAN2SFTJVyPVrK0Pq9E44VFP+e89fAc10/w=="],
"webpack-sources": ["webpack-sources@3.5.1", "", {}, "sha512-jyuiGJdtvY434z5bUZrjz67v76/ePNvFZTp9Mdz29IlH4+GPsgyGjiv0fKI+M7BdkU6ADjulUcKAd3tUK3WlEw=="],
"webpack-virtual-modules": ["webpack-virtual-modules@0.6.2", "", {}, "sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ=="],
"whatwg-mimetype": ["whatwg-mimetype@3.0.0", "", {}, "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q=="],
@@ -3188,6 +3037,8 @@
"@base-ui/utils/reselect": ["reselect@5.3.0", "", {}, "sha512-XGoLeRAVzUTcJ1qkxPQhDJyIZ5d6zzZD9nT7AEZOaaU9UbWclhycElmhO+VD5bFeLuzhPBaOV2oXC8uG35ZSpg=="],
"@dbos-inc/dbos-sdk/commander": ["commander@12.1.0", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="],
"@earendil-works/pi-agent-core/ignore": ["ignore@7.0.5", "", {}, "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg=="],
"@earendil-works/pi-agent-core/typebox": ["typebox@1.1.38", "", {}, "sha512-pZ0aQPmMmXoUvSbeuWf/Hzsc+avNw/Zd6VeE8CFgkVGWyuHPJvqeJJDeJqLve+K70LvjYIoleGcoJHPT17cWoA=="],
@@ -3200,9 +3051,9 @@
"@grpc/grpc-js/@grpc/proto-loader": ["@grpc/proto-loader@0.8.1", "", { "dependencies": { "lodash.camelcase": "^4.3.0", "long": "^5.0.0", "protobufjs": "^7.5.5", "yargs": "^17.7.2" }, "bin": { "proto-loader-gen-types": "build/bin/proto-loader-gen-types.js" } }, "sha512-wtF6h+DY6M3YaDBPAmvuuA6jV8Sif9MjtOI5euKFWRgCDl5PeDpPsHR9u2l6St5ceY8AZgoNDww5+HvEsXFsGg=="],
"@inlang/sdk/@sinclair/typebox": ["@sinclair/typebox@0.31.30", "", {}, "sha512-MGsM7bVmHg3sUKCphlu3SGQ+T+5JTbygZWYArfKQCW5anJeACHeqLhcnf+R7XlCWZ+QR3C8JTBx3kCKJTN69ow=="],
"@inlang/paraglide-js/commander": ["commander@11.1.0", "", {}, "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ=="],
"@inlang/sdk/uuid": ["uuid@14.0.2", "", { "bin": { "uuid": "dist-node/bin/uuid" } }, "sha512-xZe/16rV4aa+HGSOCiY2YeLT1OybRLrrkL/Rqaq7p7GMVXjFh+6wN4oMYgjFmnSnhY8t6Xpdl2l9qmnHYuMHwQ=="],
"@inlang/sdk/@sinclair/typebox": ["@sinclair/typebox@0.31.30", "", {}, "sha512-MGsM7bVmHg3sUKCphlu3SGQ+T+5JTbygZWYArfKQCW5anJeACHeqLhcnf+R7XlCWZ+QR3C8JTBx3kCKJTN69ow=="],
"@isaacs/cliui/string-width": ["string-width@5.1.2", "", { "dependencies": { "eastasianwidth": "^0.2.0", "emoji-regex": "^9.2.2", "strip-ansi": "^7.0.1" } }, "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA=="],
@@ -3210,14 +3061,6 @@
"@isaacs/cliui/wrap-ansi": ["wrap-ansi@8.1.0", "", { "dependencies": { "ansi-styles": "^6.1.0", "string-width": "^5.0.1", "strip-ansi": "^7.0.1" } }, "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ=="],
"@jsonjoy.com/fs-snapshot/@jsonjoy.com/json-pack": ["@jsonjoy.com/json-pack@17.67.0", "", { "dependencies": { "@jsonjoy.com/base64": "17.67.0", "@jsonjoy.com/buffers": "17.67.0", "@jsonjoy.com/codegen": "17.67.0", "@jsonjoy.com/json-pointer": "17.67.0", "@jsonjoy.com/util": "17.67.0", "hyperdyperid": "^1.2.0", "thingies": "^2.5.0", "tree-dump": "^1.1.0" }, "peerDependencies": { "tslib": "2" } }, "sha512-t0ejURcGaZsn1ClbJ/3kFqSOjlryd92eQY465IYrezsXmPcfHPE/av4twRSxf6WE+TkZgLY+71vCZbiIiFKA/w=="],
"@jsonjoy.com/fs-snapshot/@jsonjoy.com/util": ["@jsonjoy.com/util@17.67.0", "", { "dependencies": { "@jsonjoy.com/buffers": "17.67.0", "@jsonjoy.com/codegen": "17.67.0" }, "peerDependencies": { "tslib": "2" } }, "sha512-6+8xBaz1rLSohlGh68D1pdw3AwDi9xydm8QNlAFkvnavCJYSze+pxoW2VKP8p308jtlMRLs5NTHfPlZLd4w7ew=="],
"@jsonjoy.com/json-pack/@jsonjoy.com/buffers": ["@jsonjoy.com/buffers@1.2.1", "", { "peerDependencies": { "tslib": "2" } }, "sha512-12cdlDwX4RUM3QxmUbVJWqZ/mrK6dFQH4Zxq6+r1YXKXYBNgZXndx2qbCJwh3+WWkCSn67IjnlG3XYTvmvYtgA=="],
"@jsonjoy.com/util/@jsonjoy.com/buffers": ["@jsonjoy.com/buffers@1.2.1", "", { "peerDependencies": { "tslib": "2" } }, "sha512-12cdlDwX4RUM3QxmUbVJWqZ/mrK6dFQH4Zxq6+r1YXKXYBNgZXndx2qbCJwh3+WWkCSn67IjnlG3XYTvmvYtgA=="],
"@prisma/dev/std-env": ["std-env@3.10.0", "", {}, "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg=="],
"@prisma/engines/@prisma/get-platform": ["@prisma/get-platform@7.10.0", "", { "dependencies": { "@prisma/debug": "7.10.0" } }, "sha512-0bra1LFYi8xNw0yqV62bHJNQk4BKleOngZiqPWIQc7a3+9q6rqsnqJ15BuepP8943PFMvtmgnP52juZsyYkA6w=="],
@@ -3232,10 +3075,6 @@
"@reduxjs/toolkit/reselect": ["reselect@5.3.0", "", {}, "sha512-XGoLeRAVzUTcJ1qkxPQhDJyIZ5d6zzZD9nT7AEZOaaU9UbWclhycElmhO+VD5bFeLuzhPBaOV2oXC8uG35ZSpg=="],
"@shumai/core/@temporalio/activity": ["@temporalio/activity@1.24.0", "", { "dependencies": { "@temporalio/client": "1.24.0", "@temporalio/common": "1.24.0" } }, "sha512-eBBho/r9XHe2KczYGzmaSp6e9+6c9ta/GGOBldIBr00D/cV34kJ76iAY3Ue1pQTaP7YaX3phMuOz07uUg/IKyA=="],
"@shumai/core/@temporalio/workflow": ["@temporalio/workflow@1.24.0", "", { "dependencies": { "@temporalio/common": "1.24.0", "@temporalio/proto": "1.24.0", "nexus-rpc": "^0.0.3" } }, "sha512-pIA9nxkDCCbBnNuMSffQ44HWHYe3zXFfrDpDLwzh/FUSx8uLbsBM8jwf5oUMf+5eV/qVW9PknZhOu9IFO4XnPA=="],
"@shumai/webui/@types/react-dom": ["@types/react-dom@19.2.5", "", { "peerDependencies": { "@types/react": "^19.2.0" } }, "sha512-fMPwH9v7r/pp43yUd2/Mbiex5KouJwwR3dzHkhLREUC6764VyDsqxhAxv6OFEYR1RhjOyD1naqba8ECDBe7ZQg=="],
"@spectrum-web-components/action-button/@spectrum-web-components/icon": ["@spectrum-web-components/icon@0.37.0", "", { "dependencies": { "@spectrum-web-components/base": "^0.37.0", "@spectrum-web-components/iconset": "^0.37.0" } }, "sha512-DZ1yOKHxNQygzIJ7u9akYComDnMmxuTzfmYxxt9sHdUXmc1NbMkCJqEaAG/LYsdb+hc4xWaDTT9SzArLKZ/btA=="],
@@ -3354,14 +3193,6 @@
"@tanstack/router-plugin/unplugin": ["unplugin@3.3.0", "", { "dependencies": { "@jridgewell/remapping": "^2.3.5", "picomatch": "^4.0.4", "webpack-virtual-modules": "^0.6.2" }, "peerDependencies": { "@farmfe/core": "*", "@rspack/core": "*", "bun-types-no-globals": "*", "esbuild": "*", "rolldown": "*", "rollup": "*", "unloader": "*", "vite": "*", "webpack": "*" }, "optionalPeers": ["@farmfe/core", "@rspack/core", "bun-types-no-globals", "esbuild", "rolldown", "rollup", "unloader", "vite", "webpack"] }, "sha512-qa66K+crbfyE6JK10GjvbJeRrOsuC/JpbnHctfyp/i4oBTxWOzJfRZyDiOk1PtErMFRu8JhsU/wPvOdBNWe5Rg=="],
"@temporalio/common/ms": ["ms@3.0.0-canary.1", "", {}, "sha512-kh8ARjh8rMN7Du2igDRO9QJnqCb2xYTJxyQYK7vJJS4TvLLmsbyhiKpSW+t+y26gyOyMd0riphX0GeWKU3ky5g=="],
"@temporalio/common/protobufjs": ["protobufjs@8.8.0", "", { "dependencies": { "long": "^5.3.2" } }, "sha512-N3xhQ5yyBx3vQq4gubBfASzYhJGNzeDbjqBpu61g7UVylsN/qyffU96TKWD3GbbLOKF82VGNRNvv1+BFgE31Eg=="],
"@temporalio/proto/protobufjs": ["protobufjs@8.8.0", "", { "dependencies": { "long": "^5.3.2" } }, "sha512-N3xhQ5yyBx3vQq4gubBfASzYhJGNzeDbjqBpu61g7UVylsN/qyffU96TKWD3GbbLOKF82VGNRNvv1+BFgE31Eg=="],
"@temporalio/worker/protobufjs": ["protobufjs@8.8.0", "", { "dependencies": { "long": "^5.3.2" } }, "sha512-N3xhQ5yyBx3vQq4gubBfASzYhJGNzeDbjqBpu61g7UVylsN/qyffU96TKWD3GbbLOKF82VGNRNvv1+BFgE31Eg=="],
"@types/ssh2/@types/node": ["@types/node@18.19.130", "", { "dependencies": { "undici-types": "~5.26.4" } }, "sha512-GRaXQx6jGfL8sKfaIDD6OupbIHBr9jv7Jnaml9tB7l4v068PAOXqfcujMMo5PhbIs6ggR1XODELqahT2R8v0fg=="],
"@typescript-eslint/eslint-plugin/ignore": ["ignore@7.0.6", "", {}, "sha512-BAg6QkE8W+TuQLrrw0Ugr7HegXduRuuj8/ti2kSOc+jz1dmx8/WNcjr6XGnq5YpDWxFwwaavqD0+jIUOKelTsw=="],
@@ -3388,14 +3219,8 @@
"@visx/vendor/d3-format": ["d3-format@3.1.0", "", {}, "sha512-YyUI6AEuY/Wpt8KWLgZHsIU86atmikuoOmCfommt0LYHiQSPjvX2AcFc38PX0CBpr2RCyZhjex+NS/LPOv6YqA=="],
"ajv-formats/ajv": ["ajv@8.20.0", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2" } }, "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA=="],
"ajv-keywords/ajv": ["ajv@8.20.0", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2" } }, "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA=="],
"bcrypt-pbkdf/tweetnacl": ["tweetnacl@0.14.5", "", {}, "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA=="],
"better-call/@better-auth/utils": ["@better-auth/utils@0.4.2", "", { "dependencies": { "@noble/hashes": "^2.0.1" } }, "sha512-AUxrvu+HaaODsUyzDxFgwd/8RZ1yZaYo42LXKSrU2oGgR38pS1ij8nqQKNgtTWoYGpNevNXtCfgTy6loHveW9A=="],
"better-call/@better-fetch/fetch": ["@better-fetch/fetch@1.3.1", "", {}, "sha512-ABkD1WhyfPZprKRQI3bhATjeiFuNWC9PXhfGWqL+sg/gKrM977oFrYkdb4msM3hgUGonr7KlOsOFT5TU2rht9g=="],
"bl/buffer": ["buffer@5.7.1", "", { "dependencies": { "base64-js": "^1.3.1", "ieee754": "^1.1.13" } }, "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ=="],
@@ -3444,18 +3269,10 @@
"readdir-glob/minimatch": ["minimatch@5.1.9", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw=="],
"schema-utils/ajv": ["ajv@8.20.0", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2" } }, "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA=="],
"sharp/semver": ["semver@7.8.5", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA=="],
"source-map-loader/iconv-lite": ["iconv-lite@0.6.3", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw=="],
"source-map-support/source-map": ["source-map@0.6.1", "", {}, "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="],
"ssh-remote-port-forward/@types/ssh2": ["@types/ssh2@0.5.52", "", { "dependencies": { "@types/node": "*", "@types/ssh2-streams": "*" } }, "sha512-lbLLlXxdCZOSJMCInKH2+9V/77ET2J6NPQHpFI0kda61Dd1KglJs+fPQBchizmzYSOJBgdTajhPqBO1xxLywvg=="],
"terser/commander": ["commander@2.20.3", "", {}, "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ=="],
"thread-stream/real-require": ["real-require@1.0.0", "", {}, "sha512-P4nbQYQfePJxRSmY+v/KINxVucm4NF3p3s7pJveMTtom52FR4YGltUQLB8idDXwDDWW+eYrWDFbuzUnjoWHF7g=="],
"wrap-ansi/ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="],
@@ -3470,14 +3287,6 @@
"@isaacs/cliui/wrap-ansi/ansi-styles": ["ansi-styles@6.2.3", "", {}, "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg=="],
"@jsonjoy.com/fs-snapshot/@jsonjoy.com/json-pack/@jsonjoy.com/base64": ["@jsonjoy.com/base64@17.67.0", "", { "peerDependencies": { "tslib": "2" } }, "sha512-5SEsJGsm15aP8TQGkDfJvz9axgPwAEm98S5DxOuYe8e1EbfajcDmgeXXzccEjh+mLnjqEKrkBdjHWS5vFNwDdw=="],
"@jsonjoy.com/fs-snapshot/@jsonjoy.com/json-pack/@jsonjoy.com/codegen": ["@jsonjoy.com/codegen@17.67.0", "", { "peerDependencies": { "tslib": "2" } }, "sha512-idnkUplROpdBOV0HMcwhsCUS5TRUi9poagdGs70A6S4ux9+/aPuKbh8+UYRTLYQHtXvAdNfQWXDqZEx5k4Dj2Q=="],
"@jsonjoy.com/fs-snapshot/@jsonjoy.com/json-pack/@jsonjoy.com/json-pointer": ["@jsonjoy.com/json-pointer@17.67.0", "", { "dependencies": { "@jsonjoy.com/util": "17.67.0" }, "peerDependencies": { "tslib": "2" } }, "sha512-+iqOFInH+QZGmSuaybBUNdh7yvNrXvqR+h3wjXm0N/3JK1EyyFAeGJvqnmQL61d1ARLlk/wJdFKSL+LHJ1eaUA=="],
"@jsonjoy.com/fs-snapshot/@jsonjoy.com/util/@jsonjoy.com/codegen": ["@jsonjoy.com/codegen@17.67.0", "", { "peerDependencies": { "tslib": "2" } }, "sha512-idnkUplROpdBOV0HMcwhsCUS5TRUi9poagdGs70A6S4ux9+/aPuKbh8+UYRTLYQHtXvAdNfQWXDqZEx5k4Dj2Q=="],
"@prisma/streams-local/ajv/json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
"@prisma/studio-core/@radix-ui/react-toggle/@radix-ui/primitive": ["@radix-ui/primitive@1.1.3", "", {}, "sha512-JTF99U/6XIjCBo0wqkU5sK10glYe27MRRsfwoiq5zzOEZLHU3A3KCMa5X/azekYRCJ0HlwI0crAXS/5dEHTzDg=="],
@@ -3486,14 +3295,6 @@
"@prisma/studio-core/@radix-ui/react-toggle/@radix-ui/react-use-controllable-state": ["@radix-ui/react-use-controllable-state@1.2.2", "", { "dependencies": { "@radix-ui/react-use-effect-event": "0.0.2", "@radix-ui/react-use-layout-effect": "1.1.1" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-BjasUjixPFdS+NKkypcyyN5Pmg83Olst0+c6vGov0diwTEo6mgdqVR6hxcEgFuh4QrAs7Rc+9KuGJ9TVCj0Zzg=="],
"@shumai/core/@temporalio/activity/@temporalio/client": ["@temporalio/client@1.24.0", "", { "dependencies": { "@grpc/grpc-js": "^1.12.4", "@temporalio/common": "1.24.0", "@temporalio/proto": "1.24.0", "abort-controller": "^3.0.0", "long": "^5.3.2", "nexus-rpc": "^0.0.3", "uuid": "^11.1.0" } }, "sha512-/GGg6ZYl+pN/bQEvq414CyjDvyM+MM1WsMzi/7SCYb3UlivVXx9nOmH/6BGx8OfYFayp11fkmfSh6rt7vW/ePQ=="],
"@shumai/core/@temporalio/activity/@temporalio/common": ["@temporalio/common@1.24.0", "", { "dependencies": { "@temporalio/proto": "1.24.0", "long": "^5.3.2", "ms": "3.0.0-canary.1", "nexus-rpc": "^0.0.3", "protobufjs": "^8.7.1" } }, "sha512-jXp77fXwynBcVNc/CaGMT33TVYnhcN26S959HDv7Q71oc0rN6d8RHWR5z0nRCDAu5CQwZQRRhVK0TRdyAiEg7Q=="],
"@shumai/core/@temporalio/workflow/@temporalio/common": ["@temporalio/common@1.24.0", "", { "dependencies": { "@temporalio/proto": "1.24.0", "long": "^5.3.2", "ms": "3.0.0-canary.1", "nexus-rpc": "^0.0.3", "protobufjs": "^8.7.1" } }, "sha512-jXp77fXwynBcVNc/CaGMT33TVYnhcN26S959HDv7Q71oc0rN6d8RHWR5z0nRCDAu5CQwZQRRhVK0TRdyAiEg7Q=="],
"@shumai/core/@temporalio/workflow/@temporalio/proto": ["@temporalio/proto@1.24.0", "", { "dependencies": { "long": "^5.3.2", "protobufjs": "^8.7.1" } }, "sha512-vhlhB9GpoyJx+78r3lDahHywpdri6LKx7kt7djLIw6XzHyb8FQTIi4lX8DSJBqKp3+HVfL1CLwiqO26KFRzg/g=="],
"@spectrum-web-components/action-button/@spectrum-web-components/icon/@spectrum-web-components/iconset": ["@spectrum-web-components/iconset@0.37.0", "", { "dependencies": { "@spectrum-web-components/base": "^0.37.0" } }, "sha512-s1TBjWeQtGdGf6n+r+aG2glv77IgR0pNs0HLusGyYt6jzWFkP276fE7Neqq/2XvG9a9zvAwngffnWS3td/Gtmg=="],
"@spectrum-web-components/action-group/@spectrum-web-components/icons-workflow/@spectrum-web-components/icon": ["@spectrum-web-components/icon@0.37.0", "", { "dependencies": { "@spectrum-web-components/base": "^0.37.0", "@spectrum-web-components/iconset": "^0.37.0" } }, "sha512-DZ1yOKHxNQygzIJ7u9akYComDnMmxuTzfmYxxt9sHdUXmc1NbMkCJqEaAG/LYsdb+hc4xWaDTT9SzArLKZ/btA=="],
@@ -3578,10 +3379,6 @@
"@visx/vendor/@types/d3-scale/@types/d3-time": ["@types/d3-time@3.0.4", "", {}, "sha512-yuzZug1nkAAaBlBBikKZTgzCeA+k1uy4ZFwWANOfKw5z5LRhV0gNA7gNkKm7HoK+HRN0wX3EkxGk0fpbWhmB7g=="],
"ajv-formats/ajv/json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
"ajv-keywords/ajv/json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
"dockerode/tar-fs/tar-stream": ["tar-stream@2.2.0", "", { "dependencies": { "bl": "^4.0.3", "end-of-stream": "^1.4.1", "fs-constants": "^1.0.0", "inherits": "^2.0.3", "readable-stream": "^3.1.1" } }, "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ=="],
"eslint-plugin-react/minimatch/brace-expansion": ["brace-expansion@1.1.18", "", { "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw=="],
@@ -3596,28 +3393,12 @@
"readdir-glob/minimatch/brace-expansion": ["brace-expansion@2.1.4", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg=="],
"schema-utils/ajv/json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
"@prisma/studio-core/@radix-ui/react-toggle/@radix-ui/react-primitive/@radix-ui/react-slot": ["@radix-ui/react-slot@1.2.3", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.2" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A=="],
"@prisma/studio-core/@radix-ui/react-toggle/@radix-ui/react-use-controllable-state/@radix-ui/react-use-effect-event": ["@radix-ui/react-use-effect-event@0.0.2", "", { "dependencies": { "@radix-ui/react-use-layout-effect": "1.1.1" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-Qp8WbZOBe+blgpuUT+lw2xheLP8q0oatc9UpmiemEICxGvFLYmHm9QowVZGHtJlGbS6A6yJ3iViad/2cVjnOiA=="],
"@prisma/studio-core/@radix-ui/react-toggle/@radix-ui/react-use-controllable-state/@radix-ui/react-use-layout-effect": ["@radix-ui/react-use-layout-effect@1.1.1", "", { "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-RbJRS4UWQFkzHTTwVymMTUv8EqYhOp8dOOviLj2ugtTiXRaRQS7GLGxZTLL1jWhMeoSCf5zmcZkqTl9IiYfXcQ=="],
"@shumai/core/@temporalio/activity/@temporalio/client/@temporalio/proto": ["@temporalio/proto@1.24.0", "", { "dependencies": { "long": "^5.3.2", "protobufjs": "^8.7.1" } }, "sha512-vhlhB9GpoyJx+78r3lDahHywpdri6LKx7kt7djLIw6XzHyb8FQTIi4lX8DSJBqKp3+HVfL1CLwiqO26KFRzg/g=="],
"@shumai/core/@temporalio/activity/@temporalio/common/@temporalio/proto": ["@temporalio/proto@1.24.0", "", { "dependencies": { "long": "^5.3.2", "protobufjs": "^8.7.1" } }, "sha512-vhlhB9GpoyJx+78r3lDahHywpdri6LKx7kt7djLIw6XzHyb8FQTIi4lX8DSJBqKp3+HVfL1CLwiqO26KFRzg/g=="],
"@shumai/core/@temporalio/activity/@temporalio/common/ms": ["ms@3.0.0-canary.1", "", {}, "sha512-kh8ARjh8rMN7Du2igDRO9QJnqCb2xYTJxyQYK7vJJS4TvLLmsbyhiKpSW+t+y26gyOyMd0riphX0GeWKU3ky5g=="],
"@shumai/core/@temporalio/activity/@temporalio/common/protobufjs": ["protobufjs@8.8.0", "", { "dependencies": { "long": "^5.3.2" } }, "sha512-N3xhQ5yyBx3vQq4gubBfASzYhJGNzeDbjqBpu61g7UVylsN/qyffU96TKWD3GbbLOKF82VGNRNvv1+BFgE31Eg=="],
"@shumai/core/@temporalio/workflow/@temporalio/common/ms": ["ms@3.0.0-canary.1", "", {}, "sha512-kh8ARjh8rMN7Du2igDRO9QJnqCb2xYTJxyQYK7vJJS4TvLLmsbyhiKpSW+t+y26gyOyMd0riphX0GeWKU3ky5g=="],
"@shumai/core/@temporalio/workflow/@temporalio/common/protobufjs": ["protobufjs@8.8.0", "", { "dependencies": { "long": "^5.3.2" } }, "sha512-N3xhQ5yyBx3vQq4gubBfASzYhJGNzeDbjqBpu61g7UVylsN/qyffU96TKWD3GbbLOKF82VGNRNvv1+BFgE31Eg=="],
"@shumai/core/@temporalio/workflow/@temporalio/proto/protobufjs": ["protobufjs@8.8.0", "", { "dependencies": { "long": "^5.3.2" } }, "sha512-N3xhQ5yyBx3vQq4gubBfASzYhJGNzeDbjqBpu61g7UVylsN/qyffU96TKWD3GbbLOKF82VGNRNvv1+BFgE31Eg=="],
"@spectrum-web-components/action-group/@spectrum-web-components/icons-workflow/@spectrum-web-components/icon/@spectrum-web-components/iconset": ["@spectrum-web-components/iconset@0.37.0", "", { "dependencies": { "@spectrum-web-components/base": "^0.37.0" } }, "sha512-s1TBjWeQtGdGf6n+r+aG2glv77IgR0pNs0HLusGyYt6jzWFkP276fE7Neqq/2XvG9a9zvAwngffnWS3td/Gtmg=="],
"@spectrum-web-components/card/@spectrum-web-components/icons-workflow/@spectrum-web-components/icon/@spectrum-web-components/iconset": ["@spectrum-web-components/iconset@0.37.0", "", { "dependencies": { "@spectrum-web-components/base": "^0.37.0" } }, "sha512-s1TBjWeQtGdGf6n+r+aG2glv77IgR0pNs0HLusGyYt6jzWFkP276fE7Neqq/2XvG9a9zvAwngffnWS3td/Gtmg=="],
@@ -3639,7 +3420,5 @@
"readdir-glob/minimatch/brace-expansion/balanced-match": ["balanced-match@1.0.2", "", {}, "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="],
"@prisma/studio-core/@radix-ui/react-toggle/@radix-ui/react-primitive/@radix-ui/react-slot/@radix-ui/react-compose-refs": ["@radix-ui/react-compose-refs@1.1.2", "", { "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-z4eqJvfiNnFMHIIvXP3CY57y2WJs5g2v3X0zm9mEJkrkNv4rDxu+sg9Jh8EkXyeqBkB7SOcboo9dMVqhyrACIg=="],
"@shumai/core/@temporalio/activity/@temporalio/client/@temporalio/proto/protobufjs": ["protobufjs@8.8.0", "", { "dependencies": { "long": "^5.3.2" } }, "sha512-N3xhQ5yyBx3vQq4gubBfASzYhJGNzeDbjqBpu61g7UVylsN/qyffU96TKWD3GbbLOKF82VGNRNvv1+BFgE31Eg=="],
}
}
@@ -0,0 +1,70 @@
services:
postgres:
image: docker.m.daocloud.io/pgvector/pgvector:pg18
container_name: shumai_postgres
environment:
POSTGRES_USER: shumai
POSTGRES_PASSWORD: shumai_password
POSTGRES_DB: shumai_db
volumes:
- postgres_data:/var/lib/postgresql/18/docker
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U shumai -d shumai_db']
interval: 5s
timeout: 5s
retries: 5
embedding-server:
image: crpi-000nkafzu6xvpwsc.cn-hongkong.personal.cr.aliyuncs.com/shumai-one/embedding-server:latest
container_name: shumai_embedding
restart: unless-stopped
shumai:
image: crpi-000nkafzu6xvpwsc.cn-hongkong.personal.cr.aliyuncs.com/shumai-one/shumai:latest
cap_add:
- SYS_ADMIN
security_opt:
- apparmor=unconfined
- seccomp=unconfined
container_name: shumai_app
ports:
- '3000:3000'
volumes:
- ./data:/app/data
# Hardware Acceleration (NVENC / QuickSync / VA-API / RKMPP)
# Uncomment the extends section below for hardware acceleration:
# extends:
# file: hwaccel.transcoding.yaml
# service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
environment:
# Database Configuration
DATABASE_URL: postgres://shumai:shumai_password@shumai_postgres:5432/shumai_db?search_path=public&sslmode=disable
# Server Configuration
SHUMAI_SERVER_PORT: 3000
# S3 Configuration
STORAGE_BACKEND: local
AWS_ENDPOINT_URL_S3: http://localhost:3000
# Better Auth
BETTER_AUTH_SECRET: qSxs9DxzHDZBbeeTNPEwBuspYwipBqz5Gk5XdBjNhWw=
BETTER_AUTH_URL: http://localhost:3000
# Sandbox Configuration
ENABLE_WEAKER_NESTED_SANDBOX: 'true'
# Embedding Configuration
EMBEDDING_PROVIDER: gemma-embedding-2-openai
GEMMA_EMBEDDING_OPENAI_BASE_URL: http://embedding-server:9379/v1
ENABLE_EMBEDDING_AGENT: 'true'
CONCURRENCY_AGENT: 1
depends_on:
postgres:
condition: service_healthy
embedding-server:
condition: service_started
volumes:
postgres_data:
@@ -0,0 +1,90 @@
services:
postgres:
image: docker.m.daocloud.io/pgvector/pgvector:pg18
container_name: shumai_postgres
environment:
POSTGRES_USER: shumai
POSTGRES_PASSWORD: shumai_password
POSTGRES_DB: shumai_db
volumes:
- postgres_data:/var/lib/postgresql/18/docker
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U shumai -d shumai_db']
interval: 5s
timeout: 5s
retries: 5
embedding-server:
image: crpi-000nkafzu6xvpwsc.cn-hongkong.personal.cr.aliyuncs.com/shumai-one/embedding-server:latest
container_name: shumai_embedding
restart: unless-stopped
turntable-renderer:
image: crpi-000nkafzu6xvpwsc.cn-hongkong.personal.cr.aliyuncs.com/shumai-one/turntable-renderer:latest
container_name: shumai_turntable
restart: unless-stopped
gotenberg:
image: docker.m.daocloud.io/gotenberg/gotenberg:8
container_name: shumai_gotenberg
restart: unless-stopped
shumai:
image: crpi-000nkafzu6xvpwsc.cn-hongkong.personal.cr.aliyuncs.com/shumai-one/shumai:latest
cap_add:
- SYS_ADMIN
security_opt:
- apparmor=unconfined
- seccomp=unconfined
container_name: shumai_app
ports:
- '3000:3000'
volumes:
- ./data:/app/data
# Hardware Acceleration (NVENC / QuickSync / VA-API / RKMPP)
# Uncomment the extends section below for hardware acceleration:
# extends:
# file: hwaccel.transcoding.yaml
# service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
environment:
# Database Configuration
DATABASE_URL: postgres://shumai:shumai_password@shumai_postgres:5432/shumai_db?search_path=public&sslmode=disable
# Server Configuration
SHUMAI_SERVER_PORT: 3000
# S3 Configuration
STORAGE_BACKEND: local
AWS_ENDPOINT_URL_S3: http://localhost:3000
# Better Auth
BETTER_AUTH_SECRET: qSxs9DxzHDZBbeeTNPEwBuspYwipBqz5Gk5XdBjNhWw=
BETTER_AUTH_URL: http://localhost:3000
# Sandbox Configuration
ENABLE_WEAKER_NESTED_SANDBOX: 'true'
# Embedding Configuration
EMBEDDING_PROVIDER: gemma-embedding-2-openai
GEMMA_EMBEDDING_OPENAI_BASE_URL: http://embedding-server:9379/v1
ENABLE_EMBEDDING_AGENT: 'true'
CONCURRENCY_AGENT: 1
# 3D Turntable Renderer Configuration
TURNTABLE_RENDERER_URL: http://turntable-renderer:3000
# Gotenberg Document Converter Configuration
GOTENBERG_URL: http://gotenberg:3000
depends_on:
postgres:
condition: service_healthy
embedding-server:
condition: service_started
turntable-renderer:
condition: service_started
gotenberg:
condition: service_started
volumes:
postgres_data:
@@ -44,6 +44,7 @@ services:
# Better Auth
BETTER_AUTH_SECRET: qSxs9DxzHDZBbeeTNPEwBuspYwipBqz5Gk5XdBjNhWw=
BETTER_AUTH_URL: http://localhost:3000
# Sandbox Configuration
ENABLE_WEAKER_NESTED_SANDBOX: 'true'
@@ -0,0 +1,70 @@
services:
postgres:
image: pgvector/pgvector:pg18
container_name: shumai_postgres
environment:
POSTGRES_USER: shumai
POSTGRES_PASSWORD: shumai_password
POSTGRES_DB: shumai_db
volumes:
- postgres_data:/var/lib/postgresql/18/docker
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U shumai -d shumai_db']
interval: 5s
timeout: 5s
retries: 5
embedding-server:
image: shumaione/embedding-server:latest
container_name: shumai_embedding
restart: unless-stopped
shumai:
image: shumaione/shumai:latest
cap_add:
- SYS_ADMIN
security_opt:
- apparmor=unconfined
- seccomp=unconfined
container_name: shumai_app
ports:
- '3000:3000'
volumes:
- ./data:/app/data
# Hardware Acceleration (NVENC / QuickSync / VA-API / RKMPP)
# Uncomment the extends section below for hardware acceleration:
# extends:
# file: hwaccel.transcoding.yaml
# service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
environment:
# Database Configuration
DATABASE_URL: postgres://shumai:shumai_password@shumai_postgres:5432/shumai_db?search_path=public&sslmode=disable
# Server Configuration
SHUMAI_SERVER_PORT: 3000
# S3 Configuration
STORAGE_BACKEND: local
AWS_ENDPOINT_URL_S3: http://localhost:3000
# Better Auth
BETTER_AUTH_SECRET: qSxs9DxzHDZBbeeTNPEwBuspYwipBqz5Gk5XdBjNhWw=
BETTER_AUTH_URL: http://localhost:3000
# Sandbox Configuration
ENABLE_WEAKER_NESTED_SANDBOX: 'true'
# Embedding Configuration
EMBEDDING_PROVIDER: gemma-embedding-2-openai
GEMMA_EMBEDDING_OPENAI_BASE_URL: http://embedding-server:9379/v1
ENABLE_EMBEDDING_AGENT: 'true'
CONCURRENCY_AGENT: 1
depends_on:
postgres:
condition: service_healthy
embedding-server:
condition: service_started
volumes:
postgres_data:
@@ -0,0 +1,90 @@
services:
postgres:
image: pgvector/pgvector:pg18
container_name: shumai_postgres
environment:
POSTGRES_USER: shumai
POSTGRES_PASSWORD: shumai_password
POSTGRES_DB: shumai_db
volumes:
- postgres_data:/var/lib/postgresql/18/docker
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U shumai -d shumai_db']
interval: 5s
timeout: 5s
retries: 5
embedding-server:
image: shumaione/embedding-server:latest
container_name: shumai_embedding
restart: unless-stopped
turntable-renderer:
image: shumaione/turntable-renderer:latest
container_name: shumai_turntable
restart: unless-stopped
gotenberg:
image: gotenberg/gotenberg:8
container_name: shumai_gotenberg
restart: unless-stopped
shumai:
image: shumaione/shumai:latest
cap_add:
- SYS_ADMIN
security_opt:
- apparmor=unconfined
- seccomp=unconfined
container_name: shumai_app
ports:
- '3000:3000'
volumes:
- ./data:/app/data
# Hardware Acceleration (NVENC / QuickSync / VA-API / RKMPP)
# Uncomment the extends section below for hardware acceleration:
# extends:
# file: hwaccel.transcoding.yaml
# service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
environment:
# Database Configuration
DATABASE_URL: postgres://shumai:shumai_password@shumai_postgres:5432/shumai_db?search_path=public&sslmode=disable
# Server Configuration
SHUMAI_SERVER_PORT: 3000
# S3 Configuration
STORAGE_BACKEND: local
AWS_ENDPOINT_URL_S3: http://localhost:3000
# Better Auth
BETTER_AUTH_SECRET: qSxs9DxzHDZBbeeTNPEwBuspYwipBqz5Gk5XdBjNhWw=
BETTER_AUTH_URL: http://localhost:3000
# Sandbox Configuration
ENABLE_WEAKER_NESTED_SANDBOX: 'true'
# Embedding Configuration
EMBEDDING_PROVIDER: gemma-embedding-2-openai
GEMMA_EMBEDDING_OPENAI_BASE_URL: http://embedding-server:9379/v1
ENABLE_EMBEDDING_AGENT: 'true'
CONCURRENCY_AGENT: 1
# 3D Turntable Renderer Configuration
TURNTABLE_RENDERER_URL: http://turntable-renderer:3000
# Gotenberg Document Converter Configuration
GOTENBERG_URL: http://gotenberg:3000
depends_on:
postgres:
condition: service_healthy
embedding-server:
condition: service_started
turntable-renderer:
condition: service_started
gotenberg:
condition: service_started
volumes:
postgres_data:
+1
View File
@@ -44,6 +44,7 @@ services:
# Better Auth
BETTER_AUTH_SECRET: qSxs9DxzHDZBbeeTNPEwBuspYwipBqz5Gk5XdBjNhWw=
BETTER_AUTH_URL: http://localhost:3000
# Sandbox Configuration
ENABLE_WEAKER_NESTED_SANDBOX: 'true'
@@ -1,84 +0,0 @@
services:
# --- Shumai Application Services ---
postgres:
image: pgvector/pgvector:pg18
container_name: shumai_postgres
environment:
POSTGRES_USER: shumai
POSTGRES_PASSWORD: shumai_password
POSTGRES_DB: shumai_db
volumes:
- postgres_data:/var/lib/postgresql
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U shumai -d shumai_db']
interval: 5s
timeout: 5s
retries: 5
shumai:
image: shumaione/shumai:latest
container_name: shumai_app
ports:
- '3000:3000'
volumes:
- shumai_data:/app/data
environment:
DATABASE_URL: postgres://shumai:shumai_password@postgres:5432/shumai_db?search_path=public&sslmode=disable
STORAGE_BACKEND: s3
AWS_ENDPOINT_URL_S3: S3_ENDPOINT_URL
S3_REGION: S3_REGION
S3_BUCKET: BUCKET_NAME
S3_ACCESS_KEY_ID: ID
S3_SECRET_ACCESS_KEY: KEY
BETTER_AUTH_SECRET: qSxs9DxzHDZBbeeTNPEwBuspYwipBqz5Gk5XdBjNhWw=
WORKFLOW_EXECUTOR: temporal
TEMPORAL_ADDRESS: temporal:7233
GEMINI_API_KEY: KEY
ENABLE_WEAKER_NESTED_SANDBOX: 'true'
depends_on:
postgres:
condition: service_healthy
temporal:
condition: service_healthy
# --- Temporal Services ---
temporal:
image: temporalio/auto-setup:latest
container_name: temporal_server
environment:
- DB=postgres12
- DB_PORT=5432
- POSTGRES_USER=shumai
- POSTGRES_PWD=shumai_password
- POSTGRES_SEEDS=postgres
- BIND_ON_IP=0.0.0.0
ports:
- '7233:7233'
healthcheck:
test:
[
'CMD-SHELL',
'temporal operator cluster health --address localhost:7233 || temporal operator cluster health --address $$(hostname -i):7233',
]
interval: 5s
timeout: 5s
start_period: 30s
retries: 10
depends_on:
postgres:
condition: service_healthy
temporal-ui:
image: temporalio/ui:latest
container_name: temporal_ui
environment:
- TEMPORAL_ADDRESS=temporal:7233
ports:
- '8080:8080'
depends_on:
temporal:
condition: service_healthy
volumes:
postgres_data:
shumai_data:
+67
View File
@@ -3,6 +3,73 @@ title: "Changelog"
description: "Recent updates, new features, and improvements in Shumai"
---
<Update label="v0.6.2" description="October 29, 2026">
### Added
* **mcp**: Add a built-in MCP server supporting OAuth 2.1 and API tokens, allowing external AI agents (such as Claude Code, Cursor, or Kiro) to browse projects, manage and upload files, inspect media contents (images, video frames, PDF pages, 3D models, and text), search assets, manage review comments, update metadata, and organize version stacks
* **cli**: Add `shumai-cli` commands to download files (`download`), view and render media contents (`read`, `render`), search and copy files (`search`, `copy`), manage review comments (`comment`), view and update metadata (`field ls`, `meta set`), organize version stacks (`version`), and view folder instructions (`instructions`)
* **agent**: The built-in agent can now list accessible projects, search files by name, meaning, or metadata, read and post review comments, update metadata, copy files, stack and unstack versions, and read folder instructions (`AGENTS.md`), with configurable permissions per agent
### Fixed
### Changed
</Update>
<Update label="v0.6.1" description="October 24, 2026">
### Added
* **dashboard**: Add Workflow Tasks section to the Team Dashboard allowing team owners to monitor background workflow jobs, inspect execution payloads and outputs, and stop in-flight tasks
### Fixed
* **metadata**: Fix an issue where clicking to edit a metadata field on a card or list row inadvertently selected the file, and prevent expanded text overlays or date pickers from being clipped by container borders
### Changed
* **deps**: Upgrade Bun to 1.4.4
</Update>
<Update label="v0.6.0" description="October 20, 2026">
### Added
* **deploy**: Add dedicated `shumaione/shumai-transcode` Docker image and a complete AWS EKS deployment example (`eks/`) featuring KEDA queue-driven autoscaling, idle-timeout auto-drain worker mode, and Scale-to-Zero On-Demand Graviton5 instances for media processing
* **storage**: Support configuring a separate public endpoint (`AWS_PUBLIC_ENDPOINT_URL_S3`) for browser-facing presigned URLs while preserving internal cluster endpoints for backend workers
### Fixed
* **transcode**: Fix an issue where PDF, 3D model, and image background transcode workflows could fail with missing temporary file errors if a worker restarted or recovered midway through processing
* **webui**: Improve file list and detail loading with matching skeleton layouts, a persistent sidebar carousel to eliminate layout shift, and smoothed video poster previews
### Changed
* **workflow**: Migrate the background workflow engine to DBOS, unifying all-in-one and dedicated worker deployments using the existing PostgreSQL database without requiring a separate Temporal cluster
</Update>
<Update label="v0.5.3" description="October 16, 2026">
### Added
* **cli**: Add administrative `shumai regenerate-embeddings` command to regenerate multimodal vector embeddings for all existing media files across active teams
* **docker**: Provide three Docker Compose deployment tiers (Lite, with Embedding Server, and Full) with recommended memory specifications
* **agent**: Save video chunk embeddings incrementally to the database as each chunk finishes, preserving completed progress on failure and resuming from where it left off on retry
* **agent**: Add support for local LiteRT-LM Gemma Embedding 2 (`gemma-embedding-2-openai`) provider and environment-enforced read-only embedding agents with automatic 768-dimensional vector search indexing
### Fixed
### Changed
* **search**: Display search results in a responsive card grid with interactive hover video sprite scrubbing, semantic match chunk time range previews, and new-tab opening on click
* **search**: Significantly improve semantic search response times by generating query text embeddings directly with in-memory caching instead of dispatching background tasks
</Update>
<Update label="v0.5.2" description="October 13, 2026">
### Added
+173
View File
@@ -0,0 +1,173 @@
---
title: Deploy with Distributed Workers
description: Configure a high-scale production deployment using dedicated background workers, DBOS, and S3-compatible storage.
---
For production environments or workloads with high-volume video processing and heavy AI agent usage, running background tasks on a single server can cause bottlenecks. Shumai resolves this by decoupling the web dashboard from background processing through dedicated worker nodes orchestrated by **DBOS Transact**.
All background tasks (media transcoding, AI embeddings, agent tasks) are dispatched to durable task queues (`transcode_queue` and `agent_queue`) hosted directly in PostgreSQL. No separate external cluster (like Temporal) is required.
---
## How it Works
In a distributed deployment, the core Shumai web application handles user requests, database updates, and file uploads, while delegating durable background workflows to specialized worker instances via PostgreSQL task queues.
```mermaid
graph TD
UserUpload[User Uploads Video / Triggers Agent] --> WebApp[Shumai Web UI / API]
WebApp -->|Enqueue Task| DB[(PostgreSQL / DBOS Queues)]
DB -->|Queue: transcode_queue| TranscodeWorker[Transcode Worker Machine]
DB -->|Queue: agent_queue| AgentWorker[Agent Worker Machine]
```
- **Transcoding Workers**: Can be run on GPU-accelerated or high-CPU compute instances.
- **AI Agent Workers**: Can be run on isolated, sandboxed hosts to safely execute automation scripts.
> [!IMPORTANT]
> **Storage Requirement**: Because the core application and the background workers run on separate machines in a distributed setup, **you must configure an S3-compatible storage backend** (such as AWS S3, Cloudflare R2, or MinIO). Local storage (`STORAGE_BACKEND=local`) is not supported in this mode because the workers and the web application do not share a common filesystem.
---
## Step 1: Deploy the Core Web Application
On your primary host machine, run PostgreSQL and the main Shumai web application.
To instruct the main web application to handle only API and UI traffic without running background worker queues locally, set `SHUMAI_WORKERS=none`:
```env
DATABASE_URL=postgresql://shumai:shumai_password@localhost:5432/shumai_db?schema=public
STORAGE_BACKEND=s3
AWS_ENDPOINT_URL_S3=https://your-s3-endpoint.com
S3_BUCKET=shumai
S3_REGION=us-east-1
S3_ACCESS_KEY_ID=your-access-key-id
S3_SECRET_ACCESS_KEY=your-secret-access-key
SHUMAI_WORKERS=none
BETTER_AUTH_SECRET=your-random-32-character-secret-key
```
When started with `SHUMAI_WORKERS=none` (or `--workers=none`), the web server starts immediately without polling or consuming tasks from the transcode or agent queues.
---
## Step 2: Configure & Run Dedicated Workers
On your specialized worker machines, configure each worker with a `.env` file referencing the shared PostgreSQL database and S3 storage:
```env
DATABASE_URL=postgresql://shumai:shumai_password@<primary-host-ip>:5432/shumai_db?schema=public
STORAGE_BACKEND=s3
AWS_ENDPOINT_URL_S3=https://your-s3-endpoint.com
S3_BUCKET=shumai
S3_REGION=us-east-1
S3_ACCESS_KEY_ID=your-access-key-id
S3_SECRET_ACCESS_KEY=your-secret-access-key
CONCURRENCY_TRANSCODE=1
CONCURRENCY_AGENT=5
```
### Media Transcoding Worker
Run this on your media processing nodes (requires system installations of `ffmpeg` and `ffprobe`):
```bash
npm install -g @shumai-one/shumai-transcode
shumai-transcode
```
Alternatively, you can run the transcode worker using the dedicated lightweight Docker image:
```bash
docker run -d \
--name shumai-transcode-worker \
--env-file .env \
shumaione/shumai-transcode:latest
```
(You can also use the all-in-one image: `docker run -d --name shumai-transcode-worker --env-file .env shumaione/shumai:latest shumai-transcode`.)
### AI Agent Worker
Run this on your sandboxed agent execution nodes (requires sandbox dependencies like `bubblewrap` or `sandbox-exec`):
```bash
npm install -g @shumai-one/shumai-agent
shumai-agent
```
Alternatively, you can run the agent worker using the official Docker image:
```bash
docker run -d \
--name shumai-agent-worker \
--env-file .env \
--cap-add=SYS_ADMIN \
shumaione/shumai:latest shumai-agent
```
> [!IMPORTANT]
> **For Bun Users:** Since the worker package binaries contain a `#!/usr/bin/env node` shebang, running `shumai-transcode` or `shumai-agent` directly will run under Node.js. If you wish to run them using Bun, prefix the commands with `bun run --bun` (e.g., `bun run --bun shumai-transcode` or `bun run --bun shumai-agent`).
---
## Worker Concurrency & Multi-Instance Deployments
### Concurrency Tuning
Workers pull tasks from PostgreSQL queues based on configurable concurrency limits:
- `CONCURRENCY_TRANSCODE`: Maximum concurrent video transcoding jobs per worker (defaults to `1`).
- `CONCURRENCY_AGENT`: Maximum concurrent agent and embedding workflows per worker (defaults to `5`, recommend setting to `1` when paired with a local `embedding-server`).
### Replica Identity
When running multiple replicas of the transcode or agent worker across multiple machines or pods:
- `DbosExecutor` automatically derives a unique per-instance ID from the machine hostname and process ID to ensure startup recovery only re-enqueues tasks belonging to that specific instance.
- **Custom Worker ID**: Set `SHUMAI_WORKERS_ID` (or `SHUMAI_WORKER_ID`) if you wish to assign an explicit identifier.
- **Kubernetes**: In Kubernetes Pods, set `POD_NAME` (via Downward API `fieldRef: { fieldPath: metadata.name }`) to provide stable, unique per-pod identity across pod restarts.
---
## Scalable Deployment on Kubernetes & AWS EKS
For production cloud deployments requiring high-throughput media processing, Shumai can be deployed on Kubernetes or **AWS Elastic Kubernetes Service (AWS EKS)** with automated scale-to-zero queue-driven scaling via **KEDA (Kubernetes Event-driven Autoscaling)**.
```mermaid
graph TD
User([User / Web Browser]) -->|Port 80/3000| Server[Pod: shumai-server<br/>SHUMAI_WORKERS=agent]
Server -->|Enqueue to transcode_queue| DB[(PostgreSQL: pgvector18<br/>dbos.workflow_status)]
Server -->|Direct Uploads / Stream Proxies| Storage[(S3 / Garage Storage)]
KEDA[KEDA ScaledJob<br/>PostgreSQL Trigger<br/>min: 0, max: 10] -.->|Monitors Queue| DB
KEDA -->|Spawns Jobs for queue| Job1[Job: shumai-transcode-1<br/>Auto-drain worker]
KEDA -->|Spawns Jobs for queue| JobN[Job: shumai-transcode-N<br/>Auto-drain worker]
Job1 -->|Fetch Source / Store Proxies| Storage
JobN -->|Fetch Source / Store Proxies| Storage
Job1 -->|Mark Complete & Exit 0| DB
JobN -->|Mark Complete & Exit 0| DB
CA[Cluster Autoscaler / Karpenter] -.->|Scale-to-Zero On-Demand Nodes<br/>0 to 10 instances| JobN
```
### Key Architectural Highlights
- **Decoupled Stateless Workers**: The main web and API server, database, and storage run on reliable On-Demand compute (`c9g.large`, `SHUMAI_WORKERS=agent`), delegating media transcoding to background workers orchestrated via DBOS task queues in PostgreSQL.
- **Dedicated Graviton5 On-Demand Compute (`c9g.xlarge`)**: Media encoding runs on 4 vCPU / 8 GiB RAM AWS Graviton5 On-Demand instances (~$0.174/hr), utilizing ARM64 vector optimizations and high-speed DDR5 memory without involuntary Spot interruptions.
- **Queue-Driven Scale-to-Zero via KEDA**: KEDA monitors `dbos.workflow_status` for enqueued and pending transcode tasks and dynamically provisions Kubernetes `ScaledJob` resources (scaling 0 to 10). When the queue is empty, transcode nodes scale down to zero (`minSize: 0`), incurring **$0/hr** in worker costs.
- **Idle-Timeout Auto-Drain**: Worker pods continuously process queued tasks with concurrency `1`. When the queue is fully drained and a pod has been idle for 10 seconds (`SHUMAI_WORKER_IDLE_TIMEOUT_MS=10000`), it exits `0` cleanly so the node can scale down, processing batch uploads without cold-start pod churn.
- **Automated Stale Task Recovery**: The core web server runs an integrated recovery sweep that detects stale or orphaned tasks (e.g. from node crash) and resumes them automatically in DBOS, with a 3-attempt cap to safely handle poison-pill media.
### Complete Deployment Example & Source Code
For the full, production-ready manifests, declarative `eksctl` cluster configuration, and step-by-step walkthrough, see the **[EKS Deployment Example](https://github.com/shumaiOne/shumai/tree/main/eks)** in the Shumai repository:
👉 **[View the EKS Deployment Guide & Manifests on GitHub](https://github.com/shumaiOne/shumai/tree/main/eks)**
The repository includes:
- [`eks/eks-cluster.yaml`](https://github.com/shumaiOne/shumai/blob/main/eks/eks-cluster.yaml): Complete `eksctl` ClusterConfig with compute tiering.
- [`eks/kustomization.yaml`](https://github.com/shumaiOne/shumai/blob/main/eks/kustomization.yaml): Single-command Kustomize deployment for all services.
- Detailed instructions for setting up public endpoints, automated Cluster Autoscaler, and zero-downtime graceful shutdown.
+25 -12
View File
@@ -26,11 +26,11 @@ Shumai is configured via environment variables. You can define these variables i
## Authentication & Application Config
| Variable | Description | Example / Default |
| :------------------- | :--------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------- |
| `BETTER_AUTH_SECRET` | A secure, random 32-byte secret used to sign session cookies and JWTs. | Generate with `openssl rand -base64 32` |
| `BETTER_AUTH_URL` | The public URL of your Hono backend API. Used for redirect flows and notification email links fallback. | `http://localhost:3000` (respects `SHUMAI_SERVER_PORT` fallback) |
| `APP_URL` | The public URL of the web application. Used for notification email deep links (falls back to `BETTER_AUTH_URL`). | `https://shumai.example.com` |
| Variable | Description | Example / Default |
| :------------------- | :------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------- |
| `BETTER_AUTH_SECRET` | A secure, random 32-byte secret used to sign session cookies and JWTs. | Generate with `openssl rand -base64 32` |
| `BETTER_AUTH_URL` | The public URL of your Shumai server. Used for MCP OAuth 2.1 discovery, redirect flows, password reset links, and email notifications. | `http://localhost:3000` (respects `SHUMAI_SERVER_PORT` fallback) |
| `APP_URL` | The public URL of the web application. Used for notification email deep links (falls back to `BETTER_AUTH_URL`). | `https://shumai.example.com` |
---
@@ -64,14 +64,27 @@ For example, if you deploy Shumai on a remote server at `http://123.456.7.8` and
## Workflow Config
Configures whether background transcoding and AI agents are executed locally or offloaded to a Temporal cluster.
Configures background worker execution, concurrency limits, and worker identity for DBOS Transact queues.
| Variable | Description | Example / Default |
| :------------------------- | :------------------------------------------------------------------------------------------------- | :------------------------------ |
| `WORKFLOW_EXECUTOR` | Engine choice. Use `local` for in-process database polling, or `temporal` for distributed workers. | `local` (default) or `temporal` |
| `TEMPORAL_ADDRESS` | Host and port of the Temporal cluster gRPC service. | `localhost:7233` (default) |
| `EMBEDDING_CHUNK_DURATION` | The duration in seconds for each video chunk when generating video embeddings. | `60.0` (default) |
| `EMBEDDING_CHUNK_OVERLAP` | The duration in seconds to overlap video chunks when generating video embeddings. | `5.0` (default) |
| Variable | Description | Example / Default |
| :---------------------- | :-------------------------------------------------------------------------------------------------------------------------------- | :---------------- |
| `SHUMAI_WORKERS` | Queues listened to by the web server. Options: `all` (default), `none` (API/UI only), `agent` (or `ai`), `transcode`. | `all` (default) |
| `CONCURRENCY_TRANSCODE` | Maximum concurrent media transcoding tasks executed by workers. | `1` (default) |
| `CONCURRENCY_AGENT` | Maximum concurrent AI tasks executed by workers. Set to `1` when running local `embedding-server`. | `5` (default) |
| `SHUMAI_WORKER_ID` | Optional explicit instance ID for worker replicas in multi-node deployments (auto-derived from hostname and process ID if unset). | `worker-1` |
| `POD_NAME` | Kubernetes pod name, used to provide stable per-pod worker identity across StatefulSet restarts. | `transcode-pod-0` |
---
## Embedding Config
| Variable | Description | Example / Default |
| :-------------------------------- | :------------------------------------------------------------------------------------------------------------ | :-------------------------------- |
| `EMBEDDING_PROVIDER` | Multimodal embedding provider. Options: `gemini-embedding-2`, `gemma-embedding-2-openai`. | `gemini-embedding-2` (default) |
| `GEMMA_EMBEDDING_OPENAI_BASE_URL` | Base URL of the OpenAI-compatible LiteRT-LM embedding server. | `http://embedding-server:9379/v1` |
| `ENABLE_EMBEDDING_AGENT` | When set to `true`, automatically provisions and enables the system embedding agent for all teams on startup. | `false` (default) |
| `EMBEDDING_CHUNK_DURATION` | The duration in seconds for each video chunk when generating video embeddings. | `60.0` (default) |
| `EMBEDDING_CHUNK_OVERLAP` | The duration in seconds to overlap video chunks when generating video embeddings. | `5.0` (default) |
## Sandbox Config
-85
View File
@@ -1,85 +0,0 @@
---
title: Deploy with Temporal
description: Configure a high-scale production deployment using Temporal and S3-compatible storage.
---
For production environments or workloads with high-volume video processing and heavy AI agent usage, running background tasks on a single server can cause bottlenecks. Shumai resolves this by offloading task queue management, retries, and background executions to **Temporal**.
This allows you to decouple workloads and run specialized worker nodes on separate, dedicated machines.
---
## How it Works
When configured for Temporal, the core Shumai web application does not process background jobs itself. Instead, it publishes tasks to a Temporal Cluster queue.
```mermaid
graph TD
UserUpload[User Uploads Video] --> WebApp[Shumai Web UI / API]
WebApp -->|Register Task| Temporal[Temporal Cluster]
Temporal -->|Queue: Transcoding| TranscodeWorker[Transcode Worker Machine]
Temporal -->|Queue: AI Agents| AgentWorker[Agent Worker Machine]
```
- **Transcoding Workers**: Can be run on GPU-accelerated or high-CPU compute instances.
- **AI Agent Workers**: Can be run on isolated, sandboxed hosts to safely execute automation scripts.
> [!IMPORTANT]
> **Storage Requirement**: Because the core application and the background workers run on separate machines in a distributed setup, **you must configure an S3-compatible storage backend** (such as AWS S3, Cloudflare R2, or MinIO). Local storage (`STORAGE_BACKEND=local`) is not supported in this mode because the workers and the web application do not share a common filesystem.
---
## Step 1: Deploy the Core Stack
On your primary host machine, spin up the database, Temporal cluster services, and the main Shumai web application:
1. **Download the Temporal Stack Configuration**:
```bash
curl -o docker-compose.yaml https://raw.githubusercontent.com/shumaiOne/shumai/main/docker-compose/temporal/docker-compose.yaml
```
2. **Configure S3 Settings**:
Open the `docker-compose.yaml` file and set your S3 credentials and endpoint environment variables under the `shumai` service.
3. **Start the Services**:
```bash
docker compose up -d
```
This exposes the web application on port `3000`, the database on `5432`, the Temporal gRPC service on `7233`, and the Temporal management dashboard on `8080`.
---
## Step 2: Configure & Run Workers
On your specialized worker machines, you will run the dedicated background worker services. Each worker requires a `.env` file referencing the database, S3 storage, and the Temporal cluster:
```env
DATABASE_URL=postgresql://shumai:shumai_password@<primary-host-ip>:5432/shumai_db?schema=public
WORKFLOW_EXECUTOR=temporal
TEMPORAL_ADDRESS=<primary-host-ip>:7233
STORAGE_BACKEND=s3
AWS_ENDPOINT_URL_S3=https://your-s3-endpoint.com
S3_BUCKET=shumai
S3_REGION=us-east-1
S3_ACCESS_KEY_ID=your-access-key-id
S3_SECRET_ACCESS_KEY=your-secret-access-key
```
### Media Transcoding Worker
Run this on your media processing nodes (requires system installations of `ffmpeg` and `ffprobe`):
```bash
npm install -g @shumai-one/shumai-transcode
shumai-transcode
```
### AI Agent Worker
Run this on your sandboxed agent execution nodes (requires sandbox dependencies like `bubblewrap` or `sandbox-exec`):
```bash
npm install -g @shumai-one/shumai-agent
shumai-agent
```
> [!IMPORTANT]
> **For Bun Users:** Since the worker package binaries contain a `#!/usr/bin/env node` shebang, running `shumai-transcode` or `shumai-agent` directly will run under Node.js. If you wish to run them using Bun, prefix the commands with `bun run --bun` (e.g., `bun run --bun shumai-transcode` or `bun run --bun shumai-agent`).
+222
View File
@@ -0,0 +1,222 @@
---
title: Shumai MCP Server
description: Let external AI agents such as Claude Code, Cursor, or Kiro work with your Shumai projects.
---
Shumai includes a built-in [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server. Any MCP-compatible agent can connect to it and browse projects, look at images, videos, and documents, create folders, and organize assets on your behalf, using the same tools as Shumai's built-in agent.
<Note>
This page is about connecting **external agents to Shumai**. To connect Shumai's own agents to
other tools, see [MCP Servers](/using-shumai/mcp-servers).
</Note>
---
## Connecting a Client
The MCP server uses the Streamable HTTP transport at:
```
https://<your-shumai-host>/mcp
```
Shumai supports **OAuth 2.1** (recommended for seamless browser-based authentication) and **API tokens** (for headless environments or clients that do not support OAuth).
Pick your client below to get started:
### Claude Code
[Claude Code](https://docs.anthropic.com/en/docs/claude-code) natively supports remote MCP servers with OAuth authentication. Add Shumai to your Claude Code configuration by running:
```bash
claude mcp add shumai --transport http https://<your-shumai-host>/mcp
```
When you start a new conversation, Claude Code will open a browser window for you to sign in and authorize access to your Shumai account. No manual API token is required.
Alternatively, you can manually configure `.claude/settings.json`:
```json
{
"mcpServers": {
"shumai": {
"type": "http",
"url": "https://<your-shumai-host>/mcp"
}
}
}
```
Or connect stdio via `mcp-remote`:
```bash
claude mcp add shumai -- npx -y mcp-remote https://<your-shumai-host>/mcp
```
### Cursor
Add Shumai to your Cursor MCP configuration (`~/.cursor/mcp.json` or project `.cursor/mcp.json`):
```json
{
"mcpServers": {
"shumai": {
"url": "https://<your-shumai-host>/mcp"
}
}
}
```
When Cursor connects to the server, it will prompt you in the browser to complete the OAuth sign-in and authorize access.
To authenticate with an API token instead, pass the `Authorization` header:
```json
{
"mcpServers": {
"shumai": {
"url": "https://<your-shumai-host>/mcp",
"headers": {
"Authorization": "Bearer <your-api-token>"
}
}
}
}
```
### Codex
```bash
codex mcp add shumai --url https://<your-shumai-host>/mcp
codex mcp login shumai
```
### VS Code
```bash
code --add-mcp '{"name":"shumai","type":"http","url":"https://<your-shumai-host>/mcp"}'
```
Start the server from your **MCP Servers** list in VS Code and sign in to Shumai when prompted.
### Other Clients
**Remote (HTTP)**
If your client natively supports remote HTTP MCP servers:
```json
{
"mcpServers": {
"shumai": {
"url": "https://<your-shumai-host>/mcp"
}
}
}
```
**Local Bridge (`mcp-remote` / stdio)**
For clients that only support local (stdio) MCP servers, use `mcp-remote` to connect to Shumai's remote HTTP endpoint:
```json
{
"mcpServers": {
"shumai": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://<your-shumai-host>/mcp"]
}
}
}
```
---
## Authentication
Shumai's MCP server supports two authentication methods:
### OAuth 2.1 (Recommended)
Shumai implements OAuth 2.1 with Dynamic Client Registration ([RFC 7591](https://datatracker.ietf.org/doc/html/rfc7591)) and OAuth Protected Resource Metadata ([RFC 9728](https://datatracker.ietf.org/doc/html/rfc9728) / [RFC 8414](https://datatracker.ietf.org/doc/html/rfc8414)).
- **Seamless Sign-in**: Supported MCP clients automatically discover authorization endpoints and complete the OAuth handshake in your browser.
- **Access Control**: External agents act with your permissions in Shumai. Actions are attributed to your user account and logged in the team audit log with `via: mcp`.
- **Clearing OAuth Cache**: If you need to re-authenticate or clear stored credentials in CLI tools such as `mcp-remote` or Claude Code, remove the local authentication cache:
```bash
rm -rf ~/.mcp-auth
```
### API Tokens
API tokens are ideal for automated CI/CD pipelines, headless environments, or clients that do not support interactive OAuth.
1. In Shumai, open **Team Settings** → **API Tokens**.
2. Enter a name (for example, `ci-agent` or `cursor-token`) and click **Generate**.
3. Copy the token from the dialog. It is only shown once.
4. Pass the token in the `Authorization: Bearer <your-api-token>` header (or `x-api-key` header).
<Warning>
An API token acts as you: the agent can do anything your account can do in Shumai. Store it like a
password, use a separate token per client, and revoke tokens you no longer use from **Team
Settings** → **API Tokens**.
</Warning>
---
## Available Tools
| Tool | What it does |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| `list_projects` | Lists the projects you can access, with each project's root folder. |
| `list_assets` | Lists files and folders in a folder, page by page. |
| `search_assets` | Searches a folder and its subfolders by name, by meaning (when AI search is enabled), or by metadata. |
| `create_folder` | Creates a folder. |
| `rename_asset` | Renames a file or folder. |
| `move_assets` | Moves files or folders into another folder. |
| `copy_assets` | Copies files or folders into another folder of the same team. |
| `delete_asset` | Moves a file or folder to the project trash. Marked as destructive so clients can ask you to confirm. |
| `read_asset` | Looks at a file: an image, video frames, PDF pages, a 3D model view, or the text of a text file. |
| `get_asset_render` | Gets the result of a `read_asset` call that was still rendering. |
| `download_asset` | Gets download links for up to 50 files: the web preview version by default, or the original with `proxy: false`. |
| `get_folder_instructions` | Reads a folder's instructions for AI agents (its AGENTS.md). |
| `create_file` | Starts uploading a new file into a folder (see [Uploading Files](#uploading-files)). |
| `create_version` | Starts uploading a new version of a file. |
| `complete_upload` | Finishes an upload started with `create_file` or `create_version`. |
| `list_comments` | Lists the review comments on a file, with their replies. |
| `create_comment` | Comments on a file (optionally at a timecode) or replies to a comment. |
| `resolve_comment` | Marks a comment as resolved, or unresolved again. |
| `list_metadata_fields` | Lists a project's metadata fields, such as status, rating, and custom fields, with their choices. |
| `update_asset_metadata` | Sets metadata values on a file. |
| `create_version_stack` | Stacks files in the same folder as versions of one asset. |
| `list_versions` | Lists the versions in a version stack, latest first. |
| `remove_version` | Takes a version out of its stack. The file is kept. |
### Reading Files
`read_asset` attaches the images to the result so the AI model can see them: up to 8 images per call, each up to 2 MB. Any other images are listed as links only. Every result also includes a link to each image, valid for about an hour. Pass `inlineImages: false` to get links only, for example when your client can't show images.
Rendering video frames or PDF pages can take a while. If it takes longer than about 20 seconds, `read_asset` returns `status: "pending"` with a `taskId`, and the model calls `get_asset_render` with that `taskId` to get the result. Only the user who started the read can get its result.
### Uploading Files
Uploading takes three steps, so large files never pass through the AI model:
1. `create_file` (or `create_version`) returns an `uploadUrl` and an `uploadId`.
2. The agent uploads the file's bytes to `uploadUrl` with an HTTP `PUT`, for example `curl -T video.mp4 "<uploadUrl>"`.
3. `complete_upload` with the `uploadId` creates the file and starts processing it (previews, transcoding).
The upload URL and ID are valid for about an hour, and only you can complete your upload. If the project has **Creation Context** metadata fields (for example, the prompt or model used to make a file), pass their values as `metadata` to `create_file` or `create_version`; `list_metadata_fields` shows which fields they are.
The agent must be able to reach the upload URL. With Shumai's local storage, it points to your Shumai server; with S3 storage, to your S3 endpoint.
Every call runs with your permissions: for example, a **Reviewer** can list assets but cannot create or rename them. Actions are recorded in the team audit log and attributed to you, marked as coming from MCP.
---
## Troubleshooting
- **OAuth Authorization Expired or Invalid**: Clear your client's local OAuth session cache (`rm -rf ~/.mcp-auth`) and restart your MCP client to re-authenticate.
- **401 Unauthorized**: The API token or OAuth access token is missing, expired, mistyped, or revoked. For API tokens, generate a new token under **Team Settings** → **API Tokens** and update your client configuration.
- **Permission errors on a tool call**: Your role in that team or project does not allow the action.
+8 -3
View File
@@ -45,7 +45,8 @@
"using-shumai/share-links",
"using-shumai/nle-and-premiere",
"using-shumai/3d-asset-support",
"using-shumai/gotenberg"
"using-shumai/gotenberg",
"using-shumai/embedding-server"
]
},
{
@@ -70,13 +71,17 @@
"using-shumai/password-reset"
]
},
{
"group": "Developer",
"pages": ["developer/mcp-server"]
},
{
"group": "Configuration",
"pages": ["configuration/env-variables", "configuration/hardware-transcoding"]
},
{
"group": "Temporal Deployment",
"pages": ["configuration/temporal"]
"group": "Distributed Deployment",
"pages": ["configuration/distributed"]
},
{
"group": "Releases",
+1 -1
View File
@@ -32,6 +32,6 @@ Ideal for small teams, local development, or low-volume workflows. In this setup
### 2. High-Scale Distributed Deployment
Recommended for production environments with high-volume video uploads. In this setup, background tasks are managed via a centralized queue (Temporal). This allows you to offload heavy workloads to specialized worker machines (for example, putting video transcoding tasks on high-CPU/GPU machines and AI agents on separate sandboxed environments).
Recommended for production environments with high-volume video uploads. In this setup, background tasks are managed via durable queues (orchestrated by DBOS directly in PostgreSQL). This allows you to offload heavy workloads to specialized worker machines (for example, putting video transcoding tasks on high-CPU/GPU machines and AI agents on separate sandboxed environments).
_Note: S3-compatible cloud storage is required for distributed deployments so that all workers can access the uploaded files._
+104 -21
View File
@@ -9,27 +9,88 @@ We support three installation options. For most administrators, **Docker Compose
## Option 1: Docker Compose (Recommended)
Docker Compose automatically configures and spins up all required services (the web application, a database, and local storage).
Docker Compose is the fastest way to get Shumai running. You do not need to clone the repository or install packages manually. Ensure you have [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/) installed, then follow these steps:
1. **Download the Configuration**:
1. **Create Directory**:
Create and navigate to a new directory for your configuration and data volumes:
```bash
curl -o docker-compose.yaml https://raw.githubusercontent.com/shumaiOne/shumai/main/docker-compose/local/docker-compose.yaml
mkdir shumai && cd shumai
```
> [!TIP]
> **Hardware Acceleration:** By default, the standard Compose stack uses CPU-based software transcoding. If your server has a dedicated or integrated GPU (NVIDIA, Intel, AMD, or Rockchip), see the [Hardware Transcoding Guide](/configuration/hardware-transcoding) to enable GPU acceleration via the companion `hwaccel.transcoding.yaml`.
2. **Download the Configuration**:
Download your preferred `docker-compose.yaml` configuration based on your needs and available RAM:
- **Lite (Suggested RAM: 2 GB+)**: Minimal deployment containing Shumai and PostgreSQL database.
```bash
curl -o docker-compose.yaml https://raw.githubusercontent.com/shumaiOne/shumai/main/docker-compose/local/docker-compose.yaml
```
- **With Embedding Server (Suggested RAM: 4 GB+)**: Adds local multimodal semantic search powered by `shumaiOne/embedding-server` (`EmbeddingGemma 2 740M`).
```bash
curl -o docker-compose.yaml https://raw.githubusercontent.com/shumaiOne/shumai/main/docker-compose/local/docker-compose.embedding.yaml
```
- **Full (Suggested RAM: 8 GB+)**: All-in-one setup including `embedding-server`, `turntable-renderer` (3D previews), and `Gotenberg` (document PDF proxying).
```bash
curl -o docker-compose.yaml https://raw.githubusercontent.com/shumaiOne/shumai/main/docker-compose/local/docker-compose.full.yaml
```
> [!NOTE]
> By default, the Docker Compose setups use CPU software transcoding. If your server has a GPU (NVIDIA NVENC, Intel QuickSync, AMD/Intel VA-API, or Rockchip RKMPP) and you want to enable GPU hardware acceleration, check the [Hardware Transcoding Guide](/configuration/hardware-transcoding).
3. **Configure Environment Variables**:
Open `docker-compose.yaml` to adjust environment variables for your deployment:
- `BETTER_AUTH_URL`: The public base URL of your Shumai server (e.g., `https://shumai.example.com` or `http://12.34.56.78:3000`). This is required for remote servers and production deployments.
- `AWS_ENDPOINT_URL_S3`: By default, `AWS_ENDPOINT_URL_S3` is set to `http://localhost:{SHUMAI_SERVER_PORT}`. When you use local storage (the default storage backend with `STORAGE_BACKEND: local`) and expose Shumai on a remote server, custom domain, or custom host/port combination, set `AWS_ENDPOINT_URL_S3` to the external URL that client browsers will use to upload and download files.
For example, if you change the port mapping in `docker-compose.yaml` from `3000:3000` to `12345:3000` and deploy on a server with IP address `12.34.56.78`, set:
```yaml
AWS_ENDPOINT_URL_S3: http://12.34.56.78:12345
```
This value must be reachable from client browsers and should include the externally exposed port.
- `SHUMAI_SERVER_PORT`: Controls the port the Shumai server listens on. The default is `3000`.
- **External S3 Storage**: By default, Shumai uses the bundled local storage service in this Docker Compose setup. To use an external S3-compatible storage instead, configure the environment variables for your S3 provider. Here are examples for AWS S3 and Cloudflare R2:
**AWS S3 Example:**
```yaml
STORAGE_BACKEND: s3
S3_BUCKET: your-bucket-name
S3_ACCESS_KEY_ID: your-access-key-id
S3_SECRET_ACCESS_KEY: your-secret-access-key
AWS_ENDPOINT_URL_S3: https://s3.us-east-1.amazonaws.com
```
**Cloudflare R2 Example:**
```yaml
STORAGE_BACKEND: s3
S3_BUCKET: your-bucket-name
S3_REGION: auto
S3_ACCESS_KEY_ID: your-access-key-id
S3_SECRET_ACCESS_KEY: your-secret-access-key
AWS_ENDPOINT_URL_S3: https://<account-id>.r2.cloudflarestorage.com
```
4. **Start the Services**:
2. **Start the Services**:
```bash
docker compose up -d
```
3. **Access the Dashboard**:
Open your browser and navigate to **`http://localhost:3000`** to access the Shumai Web UI.
### Production Deployments (Temporal)
5. **Access the Dashboard**:
Open your browser and navigate to **`http://localhost:3000`** (or `http://<your-server-ip>:3000` for remote deployments) to access the Shumai Web UI.
If you are deploying Shumai for a production team with high-volume video uploads, we recommend setting up a distributed deployment using **Temporal** and an S3-compatible storage backend. This offloads resource-heavy video transcoding and AI agents to separate, dedicated worker nodes to keep your main dashboard fast and responsive. For setup instructions, see the [Deploy with Temporal](/configuration/temporal) guide.
### Production Deployments (Distributed Workers)
If you are deploying Shumai for a production team with high-volume video uploads, we recommend setting up a distributed deployment using dedicated workers and an S3-compatible storage backend. This offloads resource-heavy video transcoding and AI agents to separate, dedicated worker nodes to keep your main dashboard fast and responsive. For setup instructions, see the [Deploy with Distributed Workers](/configuration/distributed) guide.
---
@@ -79,12 +140,13 @@ To handle media processing and security isolation, the host machine must have th
```env
DATABASE_URL=postgresql://shumai:shumai_password@localhost:5432/shumai_db?schema=public
BETTER_AUTH_SECRET=your-random-32-character-secret-key
BETTER_AUTH_URL=http://localhost:3000
STORAGE_BACKEND=local
AWS_ENDPOINT_URL_S3=http://localhost:3000
```
> [!TIP]
> `AWS_ENDPOINT_URL_S3` must include the scheme and port (e.g. `http://localhost:3000`) where Shumai is publicly accessible. This URL is used directly by client browsers for file uploads.
> `BETTER_AUTH_URL` should be set to your public server address for remote or production deployments. `AWS_ENDPOINT_URL_S3` must include the scheme and port (e.g. `http://localhost:3000` or `http://12.34.56.78:3000`) where Shumai is publicly accessible, as client browsers use this URL directly for file uploads.
4. **Start Shumai**:
@@ -101,25 +163,46 @@ To handle media processing and security isolation, the host machine must have th
## Option 3: Run from Source (For Developers)
If you wish to run Shumai locally to customize the platform or contribute:
To set up Shumai locally for development:
1. **Clone the Repository**:
1. **Clone the Repository and Install Dependencies**:
```bash
git clone https://github.com/shumaiOne/shumai.git
cd shumai
```
2. **Install Dependencies**:
```bash
bun install
```
3. **Start a Database**:
Launch a local database container (as described in the NPM section above).
4. **Run Migrations**:
Set up your `.env` file at the root, then apply database migrations:
2. **Start a Database**:
Launch a local database container (as described in the NPM section above):
```bash
docker run --name shumai_postgres \
-e POSTGRES_USER=shumai \
-e POSTGRES_PASSWORD=shumai_password \
-e POSTGRES_DB=shumai_db \
-p 5432:5432 \
-d pgvector/pgvector:pg18
```
3. **Create Environment File**:
Create a `.env` file at the root of the workspace:
```env
DATABASE_URL=postgresql://shumai:shumai_password@localhost:5432/shumai_db?schema=public
BETTER_AUTH_SECRET=ySxs7DxzHDZBbeeHNPEwBuspYwipBqz5Gk5XdBjNhWw=
BETTER_AUTH_URL=http://localhost:3000
STORAGE_BACKEND=local
SHUMAI_SERVER_PORT=3000
AWS_ENDPOINT_URL_S3=http://localhost:3000
```
4. **Generate i18n Translations**:
```bash
bun run i18n:compile
```
> [!TIP]
> During frontend development, you can run `bun run i18n:watch` in a separate terminal to automatically recompile translation files whenever you edit strings in `packages/webui/messages/`.
5. **Run Migrations**:
Apply database schema migrations:
```bash
bun run db:migrate
```
5. **Start the Dev Server**:
6. **Start the Dev Server**:
```bash
bun run dev
```
+78 -12
View File
@@ -34,59 +34,125 @@ The following tools can be individually toggled in the agent configuration dialo
- **Description:** Allows the agent to inspect images, extract still frames from video files, render PDF document pages, and read text/markdown documents.
- **Why it matters:** Enables multimodal agents to view visual media assets uploaded to Shumai, extract frame-by-frame video screenshots, inspect document layouts, and answer questions about uploaded creative assets.
- **Limits:** Up to 20 video frames or PDF pages per call. If rendering takes longer than about a minute, the tool tells the agent the render is still in progress instead of failing.
### 4. Browse Shumai (`list_assets`)
### 4. Get Asset Render (`get_asset_render`)
- **Description:** Allows the agent to list folders and browse files in Shumai.
- **Description:** Allows the agent to pick up video frames or document pages that were still rendering when `read_asset` returned.
- **Why it matters:** Long videos and large documents can take a while to render. With this tool the agent can come back for the result instead of starting over. It only returns renders that `read_asset` started for the same user.
### 5. Browse Shumai (`list_assets`)
- **Description:** Allows the agent to list folders and browse files in Shumai. Large folders are returned page by page.
- **Why it matters:** Gives the agent visual mapping of the project structure so it can search for other files or locate related assets.
### 5. Create Folder (`create_folder`)
### 6. List Projects (`list_projects`)
- **Description:** Allows the agent to list the projects you have access to across your teams, including each project's root folder.
- **Why it matters:** Lets the agent find the right project and its root folder on its own before browsing or creating files.
### 7. Create Folder (`create_folder`)
- **Description:** Allows the agent to create new folders in Shumai.
- **Why it matters:** Needed if the agent organizes outputs or places files in custom subdirectory folders.
### 6. Create File (`create_file`)
### 8. Create File (`create_file`)
- **Description:** Allows the agent to create and upload new files to Shumai.
- **Why it matters:** Allows the agent to generate new assets (e.g. text logs, transcoded clips, reports) and save them directly back into your project.
### 7. Create Version (`create_version`)
### 9. Create Version (`create_version`)
- **Description:** Allows the agent to upload and stack a new version of an existing file in Shumai.
- **Why it matters:** Allows the agent to update files in a clean, non-destructive way by stacking revisions rather than creating duplicate files.
### 8. Generate Image (`generate_image`)
### 10. Generate Image (`generate_image`)
- **Description:** Allows the agent to generate still images from text prompts and reference images using configured AI image models.
- **Why it matters:** Enables agents to create concept art, mockups, textures, and illustrations directly inside Shumai.
- **Prerequisite:** This tool requires at least one image model to be configured and enabled in [Image / Video Generation](/using-shumai/image-video-generation). If no image models are enabled under a configured provider, this tool is omitted from the agent session even if enabled in the agent settings dialog.
### 9. Generate Video (`generate_video`)
### 11. Generate Video (`generate_video`)
- **Description:** Allows the agent to generate video clips from text prompts, image animation, or transition keyframes using configured AI video models.
- **Why it matters:** Enables agents to produce short animated clips, camera motion shots, and video transitions.
- **Prerequisite:** This tool requires at least one video model to be configured and enabled in [Image / Video Generation](/using-shumai/image-video-generation). If no video models are enabled under a configured provider, this tool is omitted from the agent session even if enabled in the agent settings dialog.
### 10. Download Asset (`download_asset`)
### 12. Download Asset (`download_asset`)
- **Description:** Allows the agent to download a workspace asset or specific storage S3 key to the local `.pi` directory for processing with local scripts or bash commands.
- **Description:** Allows the agent to download up to 50 workspace files, or a specific storage S3 key (such as a frame from `read_asset`), to the local `.pi` directory for processing with local scripts or bash commands. By default it downloads the web preview version when there is one (for example the transcoded video or the web image); the agent can ask for the original uploaded file instead. Folders are not supported.
- **Why it matters:** Enables agents executing custom skill scripts to fetch files or intermediate transcode artifacts to local disk.
### 11. Rename Asset (`rename_asset`)
### 13. Rename Asset (`rename_asset`)
- **Description:** Allows the agent to rename an existing file or folder in Shumai.
- **Why it matters:** Enables agents to keep project files neatly named and organized according to workspace naming conventions. Enabled by default.
### 12. Move Assets (`move_assets`)
### 14. Move Assets (`move_assets`)
- **Description:** Allows the agent to move one or more assets to a destination parent folder.
- **Why it matters:** Enables agents to reorganize workspace structures, relocate generated outputs, or tidy up project folders. Enabled by default.
### 13. Delete Asset (`delete_asset`)
### 15. Delete Asset (`delete_asset`)
- **Description:** Allows the agent to delete a single file or folder by moving it to the Trash bin.
- **Why it matters:** Provides agents with the ability to clean up outdated or redundant assets. To prevent accidental data loss, this tool is **disabled by default** and strictly limited to deleting one asset at a time. Team Owners must explicitly enable this tool for an agent.
### 16. Search Assets (`search_assets`)
- **Description:** Allows the agent to search a folder and its subfolders by name, by meaning (when AI search is enabled for the team), or by metadata such as status.
- **Why it matters:** Lets the agent find the files a request is about without browsing folder by folder.
### 17. Copy Assets (`copy_assets`)
- **Description:** Allows the agent to copy files or folders, with everything inside them, into another folder of the same team.
- **Why it matters:** Lets the agent reuse assets across projects or set up working copies while keeping the originals unchanged.
### 18. Read Folder Instructions (`get_folder_instructions`)
- **Description:** Allows the agent to read a folder's instructions for AI agents (its AGENTS.md).
- **Why it matters:** Lets the agent follow the team's conventions, such as naming rules or deliverable specs, before adding files to a folder.
### 19. Read Comments (`list_comments`)
- **Description:** Allows the agent to read the review comments and replies on a file, including their timecodes.
- **Why it matters:** Lets the agent act on review feedback, for example to summarize open notes or address them in a new version.
### 20. Post Comment (`create_comment`)
- **Description:** Allows the agent to comment on a file, optionally at a timecode, or reply to a comment. Comments are posted as the user the agent works for; the audit log records that the agent wrote them.
- **Why it matters:** Lets the agent take part in reviews like a teammate. Mentions in the agent's comments don't start other agents.
### 21. Resolve Comment (`resolve_comment`)
- **Description:** Allows the agent to mark comments as resolved, or reopen them.
- **Why it matters:** Lets the agent close the feedback it has addressed.
### 22. List Metadata Fields (`list_metadata_fields`)
- **Description:** Allows the agent to see a project's metadata fields, such as status, rating, and custom fields, with their choices.
- **Why it matters:** Tells the agent which values it can search by or set.
### 23. Update Metadata (`update_asset_metadata`)
- **Description:** Allows the agent to set metadata values on a file, such as its status or tags. Read-only fields can't be changed.
- **Why it matters:** Lets the agent keep a file's review status and other fields up to date.
### 24. Create Version Stack (`create_version_stack`)
- **Description:** Allows the agent to stack existing files in the same folder as versions of one asset.
- **Why it matters:** Lets the agent tidy up loose revisions (for example `cut_v1.mp4` and `cut_v2.mp4`) into one versioned asset.
### 25. List Versions (`list_versions`)
- **Description:** Allows the agent to list the versions in a version stack, latest first.
- **Why it matters:** Lets the agent compare a file with earlier versions.
### 26. Remove Version (`remove_version`)
- **Description:** Allows the agent to take a version out of its stack. The file isn't deleted; it goes back into the folder as a separate file.
- **Why it matters:** Lets the agent fix a version that was stacked by mistake.
---
## Restricting Tools
+131
View File
@@ -0,0 +1,131 @@
---
title: Embedding Server Setup (EmbeddingGemma 2)
description: Run local, offline multimodal vector embeddings for semantic search using shumaiOne/embedding-server.
---
Shumai supports local, self-hosted multimodal vector embeddings for semantic search through [shumaiOne/embedding-server](https://github.com/shumaiOne/embedding-server) — a standalone Docker service powered by Google AI Edge's **LiteRT-LM** and **EmbeddingGemma 2 740M**.
The embedding server provides a unified 768-dimensional vector space across text, images, and video frames with an OpenAI-compatible HTTP API (`/v1/embeddings`). Because the model weights are pre-baked directly into the Docker image, the server operates completely offline and air-gapped without requiring external network access or third-party cloud API keys.
---
## Model Architecture & Specs
| Property | Value |
| :------------------------ | :------------------------------------------------------- |
| **Model** | `EmbeddingGemma 2 740M` (`google/embeddinggemma-2-740m`) |
| **Runtime** | Google AI Edge LiteRT-LM (Python 3.14 Debian slim) |
| **Vector Dimensionality** | 768 dimensions (multimodal: text, image, and video) |
| **Context Window** | 2,048 tokens |
| **Network Mode** | Completely offline capable (`--network none`) |
| **API Standard** | OpenAI-compatible `/v1/embeddings` |
---
## Video Processing & Sampling
For video assets, Shumai breaks videos into standardized segments and extracts keyframes:
- **Chunking**: Videos are divided into **60-second chunks** with a **5-second overlap** at segment boundaries to preserve narrative and visual context.
- **Frame Extraction Rate**: Shumai extracts **15 frames per minute** from each chunk.
- **Adaptive Frame Bounding**:
- For standard aspect ratios (1:1, 4:3, 3:4, 16:9, 9:16, 21:9), Shumai extracts 15 frames, which produces ~1,982 prompt tokens and stays safely within the 2,048-token context window.
- For non-standard or custom aspect ratios (e.g. 5:3, 1.4:1), Shumai automatically samples 14 frames (~1,990 tokens) to mathematically guarantee that prompt length never exceeds 2,048 tokens, preventing out-of-memory errors on the embedding server.
---
## Important: Changing Embedding Providers Breaks Existing Embeddings
> [!WARNING]
> **Vector spaces from different embedding models are completely incompatible.**
>
> If you change your embedding provider (for example, switching from Google Gemini's 1536-dimensional embeddings to EmbeddingGemma's 768-dimensional embeddings, or vice versa), **all existing vector embeddings in your database become invalid**.
>
> To protect production databases from accidental corruption and search failures, **Shumai intentionally does not provide a WebUI toggle to change the embedding provider**. The provider can only be configured by an administrator via environment variables (`EMBEDDING_PROVIDER` and `GEMMA_EMBEDDING_OPENAI_BASE_URL`).
---
## Regenerating Embeddings via CLI
When you do switch embedding providers or configure the embedding server on an existing Shumai deployment, you can regenerate embeddings for all existing media files using the administrative CLI command:
### Inside Docker
```bash
docker exec -it <shumai-container-name> shumai regenerate-embeddings
```
### Local / Bare Metal
```bash
shumai regenerate-embeddings
```
_(Alternatively, `bun apps/web/src/index.ts regenerate-embeddings`)_
### What the Command Does
1. **Scans Teams**: Checks all teams in your workspace. If a team does not have an active (enabled) embedding agent, it logs a warning and safely skips that team.
2. **Clears Existing Embeddings**: Purges all previous embeddings and cancels any pending/in-progress embedding tasks for eligible assets to ensure a clean transition to the new provider.
3. **Enqueues Fresh Tasks**: Queues new background `ai_embedding` tasks for all eligible assets (images, videos, and 3D assets with rendered previews) across active teams.
4. **Background Execution**: Background workers process the queued tasks according to your configured concurrency limits.
---
## Deployment & Configuration
### Docker Quickstart
To run the standalone embedding server container:
```bash
docker run -d \
--name shumai_embedding \
-p 9379:9379 \
shumaione/embedding-server:latest
```
### Docker Compose Setup
In Docker Compose environments, add `embedding-server` to your `docker-compose.yaml` and configure Shumai to connect to it over Docker's internal network:
```yaml
services:
embedding-server:
image: shumaione/embedding-server:latest
container_name: shumai_embedding
restart: unless-stopped
shumai:
image: shumaione/shumai:latest
environment:
# Embedding Server Configuration
EMBEDDING_PROVIDER: gemma-embedding-2-openai
GEMMA_EMBEDDING_OPENAI_BASE_URL: http://embedding-server:9379/v1
ENABLE_EMBEDDING_AGENT: 'true'
CONCURRENCY_AGENT: 1
depends_on:
- embedding-server
```
> [!NOTE]
> Since Shumai communicates with `embedding-server` over Docker's internal network, `embedding-server` does not need to expose any ports to the host machine.
### Environment Variables
| Variable | Required | Description | Default |
| :-------------------------------- | :---------- | :---------------------------------------------------------------------------------------------------------------------------- | :------------------------- |
| `EMBEDDING_PROVIDER` | Yes | Set to `gemma-embedding-2-openai` to use the local LiteRT-LM server. | `gemini-embedding-2` |
| `GEMMA_EMBEDDING_OPENAI_BASE_URL` | Yes | HTTP base URL of the embedding server (e.g. `http://embedding-server:9379/v1`). | `http://localhost:9379/v1` |
| `ENABLE_EMBEDDING_AGENT` | No | Automatically provisions and enables the system embedding agent for all teams on startup. | `false` |
| `CONCURRENCY_AGENT` | Recommended | Maximum concurrent AI tasks executed by workers. **Set to `1`** when running `embedding-server` to prevent high memory usage. | `5` |
---
## Hardware & Resource Requirements
- **Memory (RAM)**:
- We recommend at least **4 GB+ of dedicated system RAM** for the `embedding-server` container.
- Overall host system memory should be **4 GB+** when running the Lite+Embedding compose stack, and **8 GB+** for the full stack.
- **Concurrency**:
- Always set `CONCURRENCY_AGENT=1` in your Shumai configuration when using `embedding-server`. Parallel multimodal embedding generations consume significant memory and can cause Docker containers to be terminated by the OS Out-Of-Memory (OOM) killer on low-resource machines.
+4 -5
View File
@@ -12,11 +12,10 @@ Traditional search relies on matching exact characters (e.g., searching "dog" wi
Semantic search translates text queries and file contents into conceptual profiles. Similar ideas and visuals are mapped near each other.
1. **Index Generation**: When you upload an asset, Shumai's background agent scans the file's visual elements, text contents, or descriptions, translating them into a concept profile.
- **Video Processing**: Shumai uses **gemini-embedding-2** for video indexing.
- **Chunking**: For long videos, Shumai breaks them into chunks to ensure high-quality indexing. By default, chunks are **60 seconds** long with a **5-second overlap** to ensure no context is lost at the boundaries.
- **Sampling**: The model processes a maximum of 32 frames per chunk: short chunks (≤32s) are sampled at 1 fps, while longer chunks are uniformly sampled to 32 frames.
- **Optimization**: To optimize processing, Shumai automatically transcodes each chunk to **1 FPS** and **removes the audio track** before sending it to the embedding agent.
- **Configuration**: Administrators can customize these settings using the `EMBEDDING_CHUNK_DURATION` and `EMBEDDING_CHUNK_OVERLAP` environment variables.
- **Multimodal Embedding Providers**: Shumai supports two embedding providers:
- **EmbeddingGemma 2 (Local)**: Powered by `shumaiOne/embedding-server` with 768-dimensional multimodal vectors running completely offline. Videos are sampled at **15 frames per minute** (14 frames for non-standard aspect ratios) per 60-second chunk. See the [Embedding Server Setup Guide](./embedding-server) for full details.
- **Gemini Embedding 2 (Cloud)**: Powered by Google's `gemini-embedding-2` API with 1536-dimensional vectors. Videos are chunked into 60-second segments (sampled up to 32 frames per chunk at 1 fps with audio stripped).
- **Chunking Configuration**: Administrators can customize chunk duration and overlap using the `EMBEDDING_CHUNK_DURATION` (default: 60s) and `EMBEDDING_CHUNK_OVERLAP` (default: 5s) environment variables.
2. **Concept Matching**: When you search with the "Semantic" toggle enabled, Shumai matches the conceptual meaning of your query against your assets.
3. **Result**: Searching "sunset at the beach" will successfully find a video file of ocean waves at dusk, even if the filename is `IMG_4029.mp4`.
+2 -2
View File
@@ -77,6 +77,6 @@ The **FFmpeg Threads** slider controls the maximum number of CPU threads used by
## Processing Architecture
Transcoding is resource-intensive. Depending on your scaling needs, your administrator can run the transcode engine on the main server (Single-Server mode) or delegate tasks to specialized transcoding worker machines (Temporal Worker mode).
Transcoding is resource-intensive. Depending on your scaling needs, your administrator can run the transcode engine on the main server (Single-Server mode) or delegate tasks to specialized transcoding worker machines (Dedicated Worker mode).
In all modes, the processing machine must have system media utilities (`ffmpeg` and `ffprobe`) installed. See the [Temporal Deployment Guide](/configuration/temporal) for setting up distributed transcoding workers.
In all modes, the processing machine must have system media utilities (`ffmpeg` and `ffprobe`) installed. See the [Distributed Deployment Guide](/configuration/distributed) for setting up dedicated transcoding workers.
+245
View File
@@ -0,0 +1,245 @@
# Shumai on AWS EKS with KEDA & Scale-to-Zero On-Demand Workers
This directory contains a complete, production-ready Kubernetes deployment example for running Shumai on **Amazon Elastic Kubernetes Service (Amazon EKS)**, using **KEDA (Kubernetes Event-driven Autoscaling)** and **Scale-to-Zero On-Demand AWS Graviton5 instances** for compute-intensive media processing.
The example should also be straightforward to adapt to any standard Kubernetes cluster.
To demonstrate a fully self-hosted setup, it uses Garage as an S3-compatible object storage solution. However, if you're deploying on AWS, consider using **Amazon S3** instead of running your own S3-compatible storage server, as it is managed and highly scalable.
---
## Architecture Overview
```text
[ User / Internet ]
│
┌────────────────────┴────────────────────┐
│ (Port 80/3000) │ (Port 3900)
▼ ▼
┌───────────────────────┐ ┌───────────────────────┐
│ shumai-server (ELB) │ │ garage-public (ELB) │
└───────────┬───────────┘ └───────────┬───────────┘
│ │ Direct Browser Uploads
│ ▼ (Presigned URLs)
┌───────────────────┼─────────────────────────────────────────────────────────────────┐
│ General Workload Node (c9g.large On-Demand, ~$0.087/hr) │
│ │ │
│ ▼ │
│ ┌───────────────────────┐ Enqueue DBOS Tasks ┌───────────────────┐ │
│ │ shumai-server ├────────────────────────►│ shumai-postgres │ │
│ │(SHUMAI_WORKERS=agent) │ (transcode_queue) │ (pgvector:pg18) │ │
│ │ [Stale Recovery Loop] │ │ │ │
│ └───────────┬───────────┘ └─────────┬─────────┘ │
│ │ Internal S3 Traffic │ │
│ ▼ │ │
│ ┌───────────────────────┐ │ │
│ │ garage-s3 │ │ │
│ │ (dxflrs/garage) │ │ │
│ └───────────▲───────────┘ │ │
└───────────────────┼───────────────────────────────────────────────┼─────────────────┘
│ Read Source / Write Proxies │
│ │ KEDA monitors
│ ▼ dbos.workflow_status
│ ┌───────────────────────────────────────┐
│ │ KEDA Controller: ScaledJob │
│ │ Spawns Jobs based on pending tasks │
│ └───────────────────┬───────────────────┘
│ │
│ ▼ Creates K8s Jobs
┌───────────────────┴─────────────────────────────────────────────────────────────────┐
│ Transcode Compute Pool (c9g.xlarge Graviton5 On-Demand, minSize: 0, maxSize: 5) │
│ │
│ ┌──────────────────────────┐ ┌──────────────────────────┐ ┌────────────────────┐ │
│ │ Job: transcode-job-1 │ │ Job: transcode-job-2 │ │Job: transcode-job-N│ │
│ │ (Auto-Drain Worker) │ │ (Auto-Drain Worker) │ │ (Auto-Drain Worker)│ │
│ └────────────┬─────────────┘ └────────────┬─────────────┘ └──────────┬─────────┘ │
│ ▼ ▼ ▼ │
│ ┌──────────────────────────┐ ┌──────────────────────────┐ ┌────────────────────┐ │
│ │ Node 1: c9g.xlarge │ │ Node 2: c9g.xlarge │ │ Node N: c9g.xlarge │ │
│ │ (On-Demand) │ │ (On-Demand) │ │ (On-Demand) │ │
│ └──────────────────────────┘ └──────────────────────────┘ └────────────────────┘ │
│ │
│ Scale-to-Zero: When queue is empty, 0 Jobs run and 0 EC2 instances are billed! │
└─────────────────────────────────────────────────────────────────────────────────────┘
```
---
## Core Design Principles
### 1. Scale-to-Zero On-Demand Instances (`minSize: 0`)
Media transcoding with FFmpeg is bursty: hours may pass with zero transcoding activity, followed by sudden batches of 4K video uploads.
- **Zero Idle Cost**: The transcode node group [`eks/eks-cluster.yaml`](./eks-cluster.yaml) is configured with `minSize: 0` and `desiredCapacity: 0`. When no media transcoding tasks are active, **zero transcode EC2 instances exist**, costing **$0/hr**.
- **No Spot Interruption Risk**: Transcoding jobs run on AWS Graviton5 **On-Demand** instances (`c9g.xlarge`, ~$0.174/hr). This eliminates the risk of Spot instances being reclaimed mid-encode by AWS, preventing wasted CPU cycles and avoiding unexpected transcoding delays.
### 2. KEDA `ScaledJob` vs. `Deployment` / `StatefulSet`
Standard Kubernetes Horizontal Pod Autoscaler (HPA) scales `Deployment` replicas based on metrics like CPU utilization. However, HPAs on Deployments suffer from severe limitations during video processing:
1. When a 1-minute video finishes on Pod A while a 30-minute video is still encoding on Pod B, CPU drops and HPA reduces replica count, which can arbitrarily terminate Pod B mid-encode.
2. StatefulSets scale down in strict ordinal order (`pod-4`, `pod-3`, etc.), which would terminate `pod-4` even if `pod-4` is the only pod currently transcoding!
**KEDA `ScaledJob` solves this natively**:
- KEDA queries PostgreSQL directly:
```sql
SELECT COUNT(*) FROM dbos.workflow_status WHERE queue_name = 'transcode_queue' AND status IN ('ENQUEUED', 'PENDING');
```
- KEDA spawns independent Kubernetes `Job` pods based on enqueued workload.
- Each Job runs the transcode worker with an idle timeout (`SHUMAI_WORKER_IDLE_TIMEOUT_MS=10000`).
- When the job drains its tasks and becomes idle, the pod exits `0` and Kubernetes marks the Job completed.
- Completing or terminating one job **never impacts any other job**!
### 3. Idle-Timeout Auto-Drain (10s Inactivity Shutdown)
In [`eks/shumai-transcode.yaml`](./shumai-transcode.yaml), the worker container runs with `SHUMAI_WORKER_IDLE_TIMEOUT_MS: "10000"`:
- **Concurrency Isolation**: Transcode concurrency is set to `1` per pod (`CONCURRENCY_TRANSCODE=1`). Each pod has exclusive access to the node's 4 vCPUs for FFmpeg.
- **Batch Processing Without Cold Starts**: Unlike single-task execution, a running worker continuously pulls tasks from `transcode_queue`. When a user uploads 100 images or multiple video files, a warm worker processes them back-to-back in seconds without restarting the container or control plane churn.
- **Automatic Scale-to-Zero**: When `activeWorkflows === 0` and no new task arrives within 10 consecutive seconds, the worker initiates graceful DBOS shutdown and exits with code `0`.
- The completed Job pod terminates, freeing the node so Cluster Autoscaler can terminate the EC2 instance down to zero.
---
## Step-by-Step Deployment Guide
### Prerequisites
- [AWS CLI](https://aws.amazon.com/cli/) installed and configured (`aws configure`).
- [`eksctl`](https://eksctl.io/) installed.
- [`kubectl`](https://kubernetes.io/docs/tasks/tools/) installed.
- [`helm`](https://helm.sh/) installed.
### Step 1: Provision the EKS Cluster
Create the cluster using the declarative [`eks/eks-cluster.yaml`](./eks-cluster.yaml) configuration:
```bash
eksctl create cluster -f eks/eks-cluster.yaml
```
This provisions:
- An EKS 1.31 control plane in `us-east-1` across multiple AZs. *(Note: AWS Graviton5 `c9g` instances are available in `us-east-1`. If deploying to a region where `c9g` is not yet offered, substitute `c7g.large` / `c7g.xlarge` or `c8g` in `eks/eks-cluster.yaml`.)*
- `shumai-general`: 1x `c9g.large` On-Demand instance (labeled `workload: general`) for API, database, and storage.
- `shumai-transcode`: Scale-to-zero `c9g.xlarge` On-Demand instance pool (`minSize: 0`, `maxSize: 5`, `desiredCapacity: 0`, tainted `dedicated=transcode:NoSchedule`).
- AWS EBS CSI Driver with IAM OIDC roles.
### Step 2: Install KEDA
Install KEDA using Helm:
```bash
helm repo add kedacore https://kedacore.github.io/charts
helm repo update
helm install keda kedacore/keda --namespace keda --create-namespace
```
Wait for the KEDA operator to reach `Running` state:
```bash
kubectl wait --namespace keda --for=condition=ready pod -l app.kubernetes.io/name=keda-operator --timeout=120s
```
### Step 3: Deploy the Shumai Stack
Deploy all components with Kustomize:
```bash
kubectl apply -k eks/
```
This applies:
- [`eks/storageclass.yaml`](./storageclass.yaml): Configures `gp3` as the default StorageClass using `ebs.csi.aws.com` with `WaitForFirstConsumer` binding and dynamic EBS volume expansion.
- PostgreSQL (`pgvector:pg18`) with durable EBS storage.
- Garage S3 object store with automatic bucket and CORS initialization (`garage-init` job).
- Shumai API & Web server.
- KEDA `ScaledJob` for transcode worker auto-scaling.
Wait for the core database and storage services to initialize:
```bash
# Wait for PostgreSQL and Garage S3 pods to become Ready
kubectl wait --namespace shumai --for=condition=ready pod -l app=shumai-postgres --timeout=180s
kubectl wait --namespace shumai --for=condition=ready pod -l app=garage --timeout=180s
# Wait for the bucket initialization job to complete
kubectl wait --namespace shumai --for=condition=complete job/garage-init --timeout=180s
# Verify all pods in the shumai namespace
kubectl get pods -n shumai -o wide
```
*(Note: On first startup, `shumai-server` automatically runs database migrations against PostgreSQL; this may take 30–60 seconds before the server reaches `Running (1/1)`.)*
### Step 4: Configure Public Access & S3 Endpoint
AWS automatically provisions external Elastic Load Balancers for `shumai-server` and `garage-public`. Because AWS takes 30–60 seconds to allocate external hostnames, wait for the hostnames to become available:
```bash
# Wait for AWS to assign external hostnames to the LoadBalancers
echo "Waiting for LoadBalancer external hostnames..."
until [ -n "$(kubectl get svc garage-public -n shumai -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')" ]; do
sleep 5
done
GARAGE_ELB=$(kubectl get svc garage-public -n shumai -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
SERVER_ELB=$(kubectl get svc shumai-server -n shumai -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
echo "Garage S3 Hostname: http://${GARAGE_ELB}:3900"
echo "Shumai Web UI: http://${SERVER_ELB}"
```
Inject the public Garage S3 hostname into `shumai-server` so that browsers generate correct presigned upload URLs:
```bash
kubectl set env deployment/shumai-server -n shumai AWS_PUBLIC_ENDPOINT_URL_S3="http://${GARAGE_ELB}:3900"
```
*(Note: In production with custom domains, point your DNS CNAME records to the load balancers and configure `AWS_PUBLIC_ENDPOINT_URL_S3: https://s3.mycompany.com` in [`eks/config.yaml`](./config.yaml).)*
### Step 5: Deploy Kubernetes Cluster Autoscaler
Deploy Cluster Autoscaler to dynamically provision `c9g.xlarge` EC2 nodes when KEDA jobs are created:
```bash
curl -s https://raw.githubusercontent.com/kubernetes/autoscaler/master/cluster-autoscaler/cloudprovider/aws/examples/cluster-autoscaler-autodiscover.yaml \
| sed 's/<YOUR CLUSTER NAME>/shumai-eks/g' \
| kubectl apply -f -
# Pin autoscaler to the general workload node
kubectl patch deployment cluster-autoscaler -n kube-system -p '{"spec":{"template":{"spec":{"nodeSelector":{"workload":"general"}}}}}'
```
### Step 6: Test Scale-to-Zero Queue-Driven Autoscaling
1. Open `http://${SERVER_ELB}` in your browser and register an account via **Sign Up**. *(The first registered account automatically becomes the instance administrator).*
2. Create a project and upload a batch of 5–10 video files simultaneously.
3. Observe KEDA detecting pending DBOS tasks and spawning individual Kubernetes Jobs:
```bash
kubectl get scaledjobs -n shumai
kubectl get jobs -n shumai -w
kubectl get pods -n shumai -l app=shumai-transcode -o wide
kubectl get nodes -L role,workload
```
4. Watch Cluster Autoscaler dynamically provision dedicated `c9g.xlarge` Graviton5 EC2 instances for the Jobs.
5. As each video finishes transcoding, its worker pod exits `0` and completes immediately.
6. Once all jobs are done, KEDA holds 0 jobs, and Cluster Autoscaler terminates all transcode EC2 instances, returning the transcode pool to **0 nodes ($0/hr)**!
### Step 7: Cluster Teardown & Cost Cleanup
When you are finished testing, delete all resources to prevent ongoing cloud charges:
```bash
# 1. Delete Kubernetes namespace first to release AWS ELB load balancers and EBS volumes
# (Important: Wait for this to complete so AWS SecurityGroups can be deleted without dependency conflicts)
kubectl delete namespace shumai
# 2. Uninstall KEDA
helm uninstall keda -n keda
kubectl delete namespace keda
# 3. Delete the EKS cluster and CloudFormation stacks
eksctl delete cluster -f eks/eks-cluster.yaml --wait
# 4. Confirm all AWS resources are released
aws eks list-clusters --region us-east-1
```
+31
View File
@@ -0,0 +1,31 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: shumai-config
namespace: shumai
data:
# S3 Storage Configuration (Garage S3)
STORAGE_BACKEND: 's3'
AWS_ENDPOINT_URL_S3: 'http://garage.shumai.svc.cluster.local:3900'
S3_BUCKET: 'shumai'
S3_REGION: 'garage'
S3_FORCE_PATH_STYLE: 'true'
# Server & Worker Configuration
SHUMAI_SERVER_PORT: '3000'
CONCURRENCY_TRANSCODE: '1'
SHUMAI_WORKER_DRAIN_TIMEOUT_MS: '290000'
---
apiVersion: v1
kind: Secret
metadata:
name: shumai-secret
namespace: shumai
type: Opaque
stringData:
DATABASE_URL: 'postgresql://shumai:shumai_password@shumai-postgres.shumai.svc.cluster.local:5432/shumai_db?schema=public'
KEDA_DATABASE_URL: 'postgresql://shumai:shumai_password@shumai-postgres.shumai.svc.cluster.local:5432/shumai_db?sslmode=disable'
BETTER_AUTH_SECRET: 'qSxs9DxzHDZBbeeTNPEwBuspYwipBqz5Gk5XdBjNhWw='
S3_ACCESS_KEY_ID: 'GKshumaiaccesskeyid001'
S3_SECRET_ACCESS_KEY: 'shumaisecretaccesskey00000000000000001'
GARAGE_ADMIN_TOKEN: 'admin-secret-token'
+57
View File
@@ -0,0 +1,57 @@
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: shumai-eks
region: us-east-1
version: '1.31'
iam:
withOIDC: true
addons:
- name: aws-ebs-csi-driver
wellKnownPolicies:
ebsCSIController: true
managedNodeGroups:
# General system workload: Web UI, REST API, DBOS PostgreSQL, and Garage S3
# Runs on On-Demand instances to guarantee database & storage durability without spot interruptions
- name: shumai-general
instanceType: c9g.large # 2 vCPU, 4 GiB RAM (Graviton5 On-Demand, ~$0.087/hr)
spot: false
minSize: 1
maxSize: 2
desiredCapacity: 1
amiFamily: AmazonLinux2023
volumeSize: 50
volumeType: gp3
labels:
workload: general
iam:
withAddonPolicies:
autoScaler: true
ebs: true
# Transcoding compute pool: High-CPU media processing
# Uses On-Demand instances with scale-to-zero (minSize: 0) managed by Cluster Autoscaler / Karpenter
- name: shumai-transcode
instanceType: c9g.xlarge # 4 vCPU, 8 GiB RAM (Graviton5 On-Demand, ~$0.174/hr)
spot: false
minSize: 0
maxSize: 5
desiredCapacity: 0
amiFamily: AmazonLinux2023
volumeSize: 50
volumeType: gp3
labels:
workload: transcode
role: transcode
taints:
- key: dedicated
value: transcode
effect: NoSchedule
iam:
withAddonPolicies:
autoScaler: true
ebs: true
+238
View File
@@ -0,0 +1,238 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: garage-config
namespace: shumai
data:
garage.toml: |
metadata_dir = "/var/lib/garage/meta"
data_dir = "/var/lib/garage/data"
db_engine = "sqlite"
replication_factor = 1
rpc_bind_addr = "0.0.0.0:3901"
rpc_secret = "c7d7e35b7501a91e5cfb3874026315579930f367fa3b7e4a1e94cf67484a86cf"
[s3_api]
s3_region = "garage"
api_bind_addr = "0.0.0.0:3900"
root_domain = ".s3.garage"
[admin]
api_bind_addr = "0.0.0.0:3903"
admin_token = "admin-secret-token"
---
apiVersion: v1
kind: Service
metadata:
name: garage
namespace: shumai
labels:
app: garage
spec:
ports:
- port: 3900
name: s3-api
- port: 3901
name: rpc
- port: 3903
name: admin
selector:
app: garage
---
apiVersion: v1
kind: Service
metadata:
name: garage-public
namespace: shumai
labels:
app: garage
spec:
type: LoadBalancer
ports:
- port: 3900
targetPort: 3900
name: s3-api
selector:
app: garage
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: garage
namespace: shumai
spec:
serviceName: garage
replicas: 1
selector:
matchLabels:
app: garage
template:
metadata:
labels:
app: garage
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: eks.amazonaws.com/nodegroup
operator: In
values:
- shumai-general
- shumai-general-spot
- matchExpressions:
- key: workload
operator: In
values:
- general
containers:
- name: garage
image: dxflrs/garage:v2.4.1
imagePullPolicy: IfNotPresent
command: ['/garage', 'server']
ports:
- containerPort: 3900
name: s3-api
- containerPort: 3901
name: rpc
- containerPort: 3903
name: admin
volumeMounts:
- name: config
mountPath: /etc/garage.toml
subPath: garage.toml
- name: garage-meta
mountPath: /var/lib/garage/meta
- name: garage-data
mountPath: /var/lib/garage/data
volumes:
- name: config
configMap:
name: garage-config
volumeClaimTemplates:
- metadata:
name: garage-meta
spec:
accessModes: ['ReadWriteOnce']
resources:
requests:
storage: 1Gi
- metadata:
name: garage-data
spec:
accessModes: ['ReadWriteOnce']
resources:
requests:
storage: 10Gi
---
apiVersion: batch/v1
kind: Job
metadata:
name: garage-init
namespace: shumai
spec:
backoffLimit: 10
template:
metadata:
labels:
app: garage-init
spec:
restartPolicy: OnFailure
containers:
- name: init
image: alpine:3.20
env:
- name: S3_BUCKET
valueFrom:
configMapKeyRef:
name: shumai-config
key: S3_BUCKET
- name: S3_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: shumai-secret
key: S3_ACCESS_KEY_ID
- name: S3_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: shumai-secret
key: S3_SECRET_ACCESS_KEY
- name: GARAGE_ADMIN_TOKEN
valueFrom:
secretKeyRef:
name: shumai-secret
key: GARAGE_ADMIN_TOKEN
command:
- /bin/sh
- -c
- |
set -e
apk add --no-cache curl jq aws-cli >/dev/null 2>&1
echo "Waiting for Garage Admin API to respond..."
until curl -s -f -H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" http://garage:3903/v2/GetClusterStatus >/dev/null 2>&1; do
sleep 2
done
echo "Garage Admin API is online. Retrieving cluster status..."
STATUS=$(curl -s -H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" http://garage:3903/v2/GetClusterStatus)
NODE_ID=$(echo "$STATUS" | jq -r '.nodes[0].id // empty')
if [ -z "$NODE_ID" ]; then
echo "Error: Node ID not found"
exit 1
fi
echo "Discovered Node ID: $NODE_ID"
ROLE=$(echo "$STATUS" | jq -r '.nodes[0].role // empty')
if [ -z "$ROLE" ] || [ "$ROLE" = "null" ]; then
echo "Assigning layout role to node..."
curl -s -f -X POST http://garage:3903/v2/UpdateClusterLayout \
-H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"roles\": [{\"id\": \"$NODE_ID\", \"zone\": \"dc1\", \"capacity\": 10737418240, \"tags\": []}]}" >/dev/null
echo "Applying cluster layout (version 1)..."
curl -s -f -X POST http://garage:3903/v2/ApplyClusterLayout \
-H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"version": 1}' >/dev/null || true
fi
echo "Importing S3 Access Key..."
curl -s -f -X POST http://garage:3903/v2/ImportKey \
-H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"name\": \"shumai-key\", \"accessKeyId\": \"${S3_ACCESS_KEY_ID}\", \"secretAccessKey\": \"${S3_SECRET_ACCESS_KEY}\"}" >/dev/null || true
echo "Creating S3 bucket '${S3_BUCKET}'..."
BUCKET_RESP=$(curl -s -X POST http://garage:3903/v2/CreateBucket \
-H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"globalAlias\": \"${S3_BUCKET}\"}")
echo "$BUCKET_RESP"
BUCKET_ID=$(echo "$BUCKET_RESP" | jq -r '.id // empty')
if [ -z "$BUCKET_ID" ]; then
# Fetch existing bucket ID if already created
BUCKET_ID=$(curl -s -H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" "http://garage:3903/v2/GetBucketInfo?globalAlias=${S3_BUCKET}" | jq -r '.id // empty')
fi
if [ -n "$BUCKET_ID" ]; then
echo "Granting bucket permissions for key on bucket ID $BUCKET_ID..."
curl -s -f -X POST http://garage:3903/v2/AllowBucketKey \
-H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"bucketId\": \"${BUCKET_ID}\", \"accessKeyId\": \"${S3_ACCESS_KEY_ID}\", \"permissions\": {\"read\": true, \"write\": true, \"owner\": true}}" >/dev/null || true
fi
echo "Configuring S3 bucket CORS for web uploads..."
AWS_ACCESS_KEY_ID=${S3_ACCESS_KEY_ID} \
AWS_SECRET_ACCESS_KEY=${S3_SECRET_ACCESS_KEY} \
AWS_DEFAULT_REGION=garage \
aws --endpoint-url http://garage:3900 s3api put-bucket-cors \
--bucket "${S3_BUCKET}" \
--cors-configuration '{"CORSRules":[{"AllowedHeaders":["*"],"AllowedMethods":["GET","PUT","POST","DELETE","HEAD"],"AllowedOrigins":["*"],"ExposeHeaders":["ETag"],"MaxAgeSeconds":3000}]}' || true
echo "✅ Garage S3 storage cluster initialized successfully!"
+11
View File
@@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- storageclass.yaml
- config.yaml
- postgres.yaml
- garage.yaml
- shumai-server.yaml
- shumai-transcode.yaml
+4
View File
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: shumai
+79
View File
@@ -0,0 +1,79 @@
apiVersion: v1
kind: Service
metadata:
name: shumai-postgres
namespace: shumai
labels:
app: shumai-postgres
spec:
ports:
- port: 5432
name: postgres
selector:
app: shumai-postgres
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: shumai-postgres
namespace: shumai
spec:
serviceName: shumai-postgres
replicas: 1
selector:
matchLabels:
app: shumai-postgres
template:
metadata:
labels:
app: shumai-postgres
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: eks.amazonaws.com/nodegroup
operator: In
values:
- shumai-general
- shumai-general-spot
- matchExpressions:
- key: workload
operator: In
values:
- general
containers:
- name: postgres
image: pgvector/pgvector:pg18
ports:
- containerPort: 5432
name: postgres
env:
- name: POSTGRES_USER
value: 'shumai'
- name: POSTGRES_PASSWORD
value: 'shumai_password'
- name: POSTGRES_DB
value: 'shumai_db'
- name: PGDATA
value: '/var/lib/postgresql/18/docker/pgdata'
readinessProbe:
exec:
command:
- sh
- -c
- pg_isready -U shumai -d shumai_db
initialDelaySeconds: 5
periodSeconds: 5
volumeMounts:
- name: postgres-data
mountPath: /var/lib/postgresql/18/docker
volumeClaimTemplates:
- metadata:
name: postgres-data
spec:
accessModes: ['ReadWriteOnce']
resources:
requests:
storage: 5Gi
+85
View File
@@ -0,0 +1,85 @@
apiVersion: v1
kind: Service
metadata:
name: shumai-server
namespace: shumai
labels:
app: shumai-server
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 3000
name: http
- port: 3000
targetPort: 3000
name: http-alt
selector:
app: shumai-server
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: shumai-server
namespace: shumai
labels:
app: shumai-server
spec:
replicas: 1
selector:
matchLabels:
app: shumai-server
template:
metadata:
labels:
app: shumai-server
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: eks.amazonaws.com/nodegroup
operator: In
values:
- shumai-general
- shumai-general-spot
- matchExpressions:
- key: workload
operator: In
values:
- general
containers:
- name: server
image: shumaione/shumai:latest
imagePullPolicy: Always
env:
- name: SHUMAI_WORKERS
value: 'agent'
envFrom:
- configMapRef:
name: shumai-config
- secretRef:
name: shumai-secret
ports:
- containerPort: 3000
name: http
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: 2000m
memory: 2Gi
readinessProbe:
httpGet:
path: /
port: 3000
initialDelaySeconds: 10
periodSeconds: 5
livenessProbe:
tcpSocket:
port: 3000
initialDelaySeconds: 15
periodSeconds: 10
+90
View File
@@ -0,0 +1,90 @@
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-postgres-auth
namespace: shumai
spec:
secretTargetRef:
- parameter: connection
name: shumai-secret
key: KEDA_DATABASE_URL
---
apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
name: shumai-transcode-scaler
namespace: shumai
labels:
app: shumai-transcode
spec:
jobTargetRef:
parallelism: 1
completions: 1
backoffLimit: 0
template:
metadata:
labels:
app: shumai-transcode
spec:
restartPolicy: Never
terminationGracePeriodSeconds: 300
tolerations:
- key: dedicated
operator: Equal
value: transcode
effect: NoSchedule
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: role
operator: In
values:
- transcode
- matchExpressions:
- key: workload
operator: In
values:
- transcode
- matchExpressions:
- key: eks.amazonaws.com/nodegroup
operator: In
values:
- shumai-transcode
containers:
- name: worker
image: shumaione/shumai-transcode:latest
imagePullPolicy: Always
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: SHUMAI_WORKER_IDLE_TIMEOUT_MS
value: '10000'
envFrom:
- configMapRef:
name: shumai-config
- secretRef:
name: shumai-secret
resources:
requests:
cpu: 3000m
memory: 4Gi
limits:
cpu: 3900m
memory: 6Gi
pollingInterval: 10
successfulJobsHistoryLimit: 5
failedJobsHistoryLimit: 10
maxReplicaCount: 5
scalingStrategy:
strategy: default
triggers:
- type: postgresql
metadata:
query: "SELECT COUNT(*) FROM dbos.workflow_status WHERE queue_name = 'transcode_queue' AND status IN ('ENQUEUED', 'PENDING');"
targetQueryValue: '1'
authenticationRef:
name: keda-postgres-auth
+12
View File
@@ -0,0 +1,12 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: gp3
annotations:
storageclass.kubernetes.io/is-default-class: 'true'
provisioner: ebs.csi.aws.com
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
parameters:
type: gp3
fsType: ext4
+20
View File
@@ -92,6 +92,26 @@ export default tseslint.config(
'@typescript-eslint/naming-convention': baseNamingConvention,
},
},
{
// Operations hold policy and orchestration only; data access belongs in core services.
files: ['packages/core/src/operations/**/*.ts'],
ignores: ['**/*.test.ts'],
rules: {
'@typescript-eslint/no-restricted-imports': [
'error',
{
paths: [
{
name: '@shumai/db',
importNames: ['prisma'],
message: 'Operations must call core services instead of the Prisma client.',
allowTypeImports: true,
},
],
},
],
},
},
{
files: ['**/*.test.ts', '**/*.test.tsx'],
rules: {
+4 -5
View File
@@ -1,6 +1,6 @@
{
"name": "shumai",
"version": "0.5.2",
"version": "0.6.2",
"private": true,
"type": "module",
"repository": {
@@ -24,7 +24,7 @@
"test:e2e:workflow": "bun --bun vitest run -c packages/e2e/vitest.config.ts",
"test:e2e:install": "playwright install --with-deps",
"harness:dev": "bun run packages/webui/e2e/harness/serve.ts",
"format": "prettier --write .",
"format": "bun fmt",
"db:migrate": "bun run prisma migrate dev",
"db:deploy": "bun run prisma migrate deploy",
"db:generate": "cd packages/db && bunx prisma generate",
@@ -50,14 +50,13 @@
"@testcontainers/postgresql": "12.1.0",
"@testing-library/dom": "10.4.1",
"@testing-library/react": "16.3.3",
"@types/bun": "1.4.0",
"@types/bun": "1.4.3",
"@types/node": "25.9.1",
"bun-plugin-pino": "1.5.0",
"bun-plugin-tailwind": "0.1.2",
"bun-types": "1.4.0",
"bun-types": "1.4.3",
"eslint": "10.9.1",
"eslint-config-prettier": "10.1.8",
"eslint-plugin-prettier": "5.5.6",
"eslint-plugin-react": "7.37.5",
"globals": "17.11.0",
"happy-dom": "20.12.0",
+4 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/agent",
"version": "0.5.2",
"version": "0.6.2",
"private": true,
"type": "module",
"main": "./src/index.ts",
@@ -9,16 +9,15 @@
"@anthropic-ai/sandbox-runtime": "0.0.74",
"@earendil-works/pi-agent-core": "0.82.1",
"@earendil-works/pi-ai": "0.82.1",
"@google/genai": "2.19.0",
"@google/genai": "2.28.0",
"@shumai/core": "workspace:*",
"@shumai/db": "workspace:*",
"@shumai/dtos": "workspace:*",
"@shumai/operations": "workspace:*",
"@shumai/workflow-core": "workspace:*",
"@temporalio/activity": "1.23.0",
"@temporalio/worker": "1.23.0",
"@temporalio/workflow": "1.23.0",
"adm-zip": "0.6.0",
"jittered-fractional-indexing": "1.0.1",
"sharp": "0.35.4",
"typebox": "1.3.22",
"ulid": "3.0.2",
"zod": "4.5.4"
+30 -46
View File
@@ -23,8 +23,7 @@ import {
import * as piAgent from '../index'
import { type AgentHarness, type Session } from '@earendil-works/pi-agent-core'
import { DatabaseSessionStorage, type DatabaseSessionMetadata } from '../database-session-storage'
import { triggerLocalCancel } from '@shumai/workflow-core'
import { Context } from '@temporalio/activity'
import { triggerLocalCancel, runInLocalTaskContext } from '@shumai/workflow-core'
import { logger } from '@shumai/core/src/logger'
import {
@@ -50,9 +49,6 @@ vi.mock('../index', async () => {
describe('Agent Activities', () => {
beforeEach(() => {
vi.clearAllMocks()
vi.spyOn(Context, 'current').mockImplementation(() => {
throw new Error('Not in Temporal')
})
})
it('should call agentChatActivity and prompt the harness', async () => {
@@ -240,13 +236,7 @@ describe('Agent Activities', () => {
await executionPromise
})
it('should listen to Temporal cancellation signal and call harness.abort when cancelled in Temporal mode', async () => {
const mockTemporalContext = {
cancellationSignal: new EventTarget(),
heartbeat: vi.fn(),
} as unknown as Context
vi.spyOn(Context, 'current').mockReturnValue(mockTemporalContext)
it('should listen to abort signal and call harness.abort when cancelled', async () => {
let resolvePrompt!: (value: {
content: Array<{ type: string; text: string } | { type: string }>
usage: { input: number; output: number }
@@ -280,42 +270,36 @@ describe('Agent Activities', () => {
allowedDomains: [],
} as unknown as AgentExecutionContext
const addEventListenerSpy = vi.spyOn(mockTemporalContext.cancellationSignal, 'addEventListener')
const removeEventListenerSpy = vi.spyOn(
mockTemporalContext.cancellationSignal,
'removeEventListener',
)
const taskId = 'test-abort-task'
const abortController = new AbortController()
const executionPromise = agentChatActivity({
teamId: 't1',
agentId: 'b1',
message: 'Hi',
imageUrls: [],
projectId: 'p1',
folderId: 'f1',
sessionId: 'mock-session-id',
context,
await runInLocalTaskContext({ taskId, abortController }, async () => {
const executionPromise = agentChatActivity({
taskId,
teamId: 't1',
agentId: 'b1',
message: 'Hi',
imageUrls: [],
projectId: 'p1',
folderId: 'f1',
sessionId: 'mock-session-id',
context,
})
// Yield to let the asynchronous setup add the abort event listener
await new Promise((resolve) => setTimeout(resolve, 50))
abortController.abort()
expect(mockHarness.abort).toHaveBeenCalled()
// Resolve the prompt promise to allow the activity to finish clean
resolvePrompt({
content: [{ type: 'text', text: 'AI response' }],
usage: { input: 10, output: 20 },
})
await executionPromise
})
// Yield to let the asynchronous setup add the abort event listener
await new Promise((resolve) => setTimeout(resolve, 50))
expect(addEventListenerSpy).toHaveBeenCalledWith('abort', expect.any(Function), { once: true })
// Simulate Temporal cancellation event
mockTemporalContext.cancellationSignal.dispatchEvent(new Event('abort'))
expect(mockHarness.abort).toHaveBeenCalled()
// Resolve the prompt promise to allow the activity to finish clean
resolvePrompt({
content: [{ type: 'text', text: 'AI response' }],
usage: { input: 10, output: 20 },
})
await executionPromise
expect(removeEventListenerSpy).toHaveBeenCalledWith('abort', expect.any(Function))
addEventListenerSpy.mockRestore()
removeEventListenerSpy.mockRestore()
})
it('should include error message in text when stopReason is error', async () => {
File diff suppressed because it is too large Load Diff
+493 -30
View File
@@ -1,17 +1,19 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
import {
generateTextEmbeddingActivity,
extractAiMetadataActivity,
getEmbeddingContextActivity,
saveAssetEmbeddingsActivity,
deleteAssetEmbeddingsActivity,
generateImageEmbeddingActivity,
generateVideoChunkEmbeddingActivity,
generateEmbeddingActivity,
getGemmaEmbeddingTargetFrameCount,
} from './ai'
import { s3Service } from '@shumai/core/src/s3/s3'
import { transcodeService } from '@shumai/core'
import { prisma, AssetType, AssetStatus } from '@shumai/db'
import { setupTestDbHooks } from '@shumai/db/test'
import sharp from 'sharp'
vi.mock('fs', async (importOriginal) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- importOriginal returns the raw fs module, typed dynamically as any here
@@ -54,7 +56,6 @@ vi.mock('child_process', () => {
const execFileMock: any = vi.fn((file: any, args: any, cb: any) => {
cb(null, '120.0\n', '')
})
// Setup custom promisify behavior to return { stdout, stderr }
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- mock functions dynamically return varying types based on test command calls
execFileMock[Symbol.for('nodejs.util.promisify.custom')] = vi.fn(async (file: any) => {
if (file === 'ffprobe') {
@@ -90,6 +91,14 @@ describe('AI Activities Unit Tests', () => {
beforeEach(() => {
vi.clearAllMocks()
process.env.GEMINI_API_KEY = 'test-key'
delete process.env.EMBEDDING_PROVIDER
delete process.env.GEMMA_EMBEDDING_OPENAI_BASE_URL
})
afterEach(() => {
vi.unstubAllGlobals()
delete process.env.EMBEDDING_PROVIDER
delete process.env.GEMMA_EMBEDDING_OPENAI_BASE_URL
})
it('should generate image embedding', async () => {
@@ -126,33 +135,6 @@ describe('AI Activities Unit Tests', () => {
)
})
it('should resolve video input via resolveInput and avoid downloadToFile in generateEmbeddingActivity', async () => {
vi.mocked(s3Service.downloadToFile).mockClear()
vi.mocked(s3Service.resolveInput).mockClear()
vi.mocked(s3Service.resolveInput).mockResolvedValue(
'https://mock-storage/files/asset-123/video.mp4',
)
const res = await generateEmbeddingActivity({
teamId: 't1',
assetId: 'asset-123',
context: {
agent: {},
asset: {
mediaType: 'video/mp4',
name: 'sample.mp4',
storageKey: { key: 'files/asset-123/video.mp4' },
media: { proxyType: 'video' },
},
},
})
expect(s3Service.resolveInput).toHaveBeenCalledWith('shumai', 'files/asset-123/video.mp4')
expect(s3Service.downloadToFile).not.toHaveBeenCalled()
expect(s3Service.getObject).not.toHaveBeenCalledWith('shumai', 'files/asset-123/video.mp4')
expect(res.embeddings.length).toBeGreaterThan(0)
})
it('should generate text embedding successfully', async () => {
const res = await generateTextEmbeddingActivity({
text: 'Search query',
@@ -172,6 +154,356 @@ describe('AI Activities Unit Tests', () => {
)
})
it('should generate text embedding successfully with gemma-embedding-2-openai', async () => {
process.env.EMBEDDING_PROVIDER = 'gemma-embedding-2-openai'
const mockFetch = vi.fn().mockResolvedValue({
ok: true,
json: async () => ({
model: 'embeddinggemma-2',
data: [{ embedding: Array(768).fill(0.1) }],
// eslint-disable-next-line @typescript-eslint/naming-convention
usage: { prompt_tokens: 15 },
}),
})
vi.stubGlobal('fetch', mockFetch)
const res = await generateTextEmbeddingActivity({
text: 'Search query',
teamId: 't1',
})
expect(res.embedding).toHaveLength(768)
expect(res.usage.model).toBe('embeddinggemma-2')
expect(res.usage.inputTokens).toBe(15)
expect(mockFetch).toHaveBeenCalledWith(
'http://localhost:9379/v1/embeddings',
expect.objectContaining({
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model: 'embeddinggemma-2',
input: 'task: search query | text: Search query',
}),
}),
)
})
it('should generate image embedding successfully with gemma-embedding-2-openai', async () => {
process.env.EMBEDDING_PROVIDER = 'gemma-embedding-2-openai'
const mockFetch = vi.fn().mockResolvedValue({
ok: true,
json: async () => ({
model: 'embeddinggemma-2',
data: [{ embedding: Array(768).fill(0.2) }],
// eslint-disable-next-line @typescript-eslint/naming-convention
usage: { prompt_tokens: 140 },
}),
})
vi.stubGlobal('fetch', mockFetch)
vi.mocked(s3Service.getObject).mockResolvedValue({
buffer: Buffer.from('test-image'),
contentType: 'image/png',
} as unknown as { buffer: Buffer; contentType: string })
const res = await generateImageEmbeddingActivity({
teamId: 't1',
assetKey: 'img.png',
mediaType: 'image/png',
})
expect(res.embedding).toHaveLength(768)
expect(res.usage.model).toBe('embeddinggemma-2')
expect(res.usage.inputTokens).toBe(140)
expect(mockFetch).toHaveBeenCalledWith(
'http://localhost:9379/v1/embeddings',
expect.objectContaining({
method: 'POST',
body: JSON.stringify({
model: 'embeddinggemma-2',
input: [
{
type: 'image_url',
// eslint-disable-next-line @typescript-eslint/naming-convention
image_url: {
url: `data:image/png;base64,${Buffer.from('test-image').toString('base64')}`,
},
},
],
}),
}),
)
})
it('should respect custom GEMMA_EMBEDDING_OPENAI_BASE_URL with or without /v1 suffix', async () => {
process.env.EMBEDDING_PROVIDER = 'gemma-embedding-2-openai'
const mockFetch = vi.fn().mockResolvedValue({
ok: true,
json: async () => ({
model: 'embeddinggemma-2',
data: [{ embedding: Array(768).fill(0.2) }],
// eslint-disable-next-line @typescript-eslint/naming-convention
usage: { prompt_tokens: 10 },
}),
})
vi.stubGlobal('fetch', mockFetch)
// Test with /v1
process.env.GEMMA_EMBEDDING_OPENAI_BASE_URL = 'http://custom-host:9379/v1'
await generateTextEmbeddingActivity({ text: 'test query', teamId: 't1' })
expect(mockFetch).toHaveBeenLastCalledWith(
'http://custom-host:9379/v1/embeddings',
expect.anything(),
)
// Test without /v1
process.env.GEMMA_EMBEDDING_OPENAI_BASE_URL = 'http://custom-host:9379'
await generateTextEmbeddingActivity({ text: 'test query', teamId: 't1' })
expect(mockFetch).toHaveBeenLastCalledWith(
'http://custom-host:9379/v1/embeddings',
expect.anything(),
)
})
it('should convert webp image to jpeg with gemma-embedding-2-openai', async () => {
process.env.EMBEDDING_PROVIDER = 'gemma-embedding-2-openai'
const mockFetch = vi.fn().mockResolvedValue({
ok: true,
json: async () => ({
model: 'embeddinggemma-2',
data: [{ embedding: Array(768).fill(0.2) }],
// eslint-disable-next-line @typescript-eslint/naming-convention
usage: { prompt_tokens: 140 },
}),
})
vi.stubGlobal('fetch', mockFetch)
const webpBuffer = await sharp({
create: { width: 10, height: 10, channels: 3, background: { r: 255, g: 0, b: 0 } },
})
.webp()
.toBuffer()
vi.mocked(s3Service.getObject).mockResolvedValue({
buffer: webpBuffer,
contentType: 'image/webp',
} as unknown as { buffer: Buffer; contentType: string })
const res = await generateImageEmbeddingActivity({
teamId: 't1',
assetKey: 'img.webp',
mediaType: 'image/webp',
})
expect(res.embedding).toHaveLength(768)
expect(mockFetch).toHaveBeenCalledWith(
'http://localhost:9379/v1/embeddings',
expect.objectContaining({
method: 'POST',
body: expect.stringContaining('data:image/jpeg;base64,'),
}),
)
})
it('should generate video chunk embedding from tar archive with gemma-embedding-2-openai', async () => {
process.env.EMBEDDING_PROVIDER = 'gemma-embedding-2-openai'
const mockFetch = vi.fn().mockResolvedValue({
ok: true,
json: async () => ({
model: 'embeddinggemma-2',
data: [{ embedding: Array(768).fill(0.3) }],
// eslint-disable-next-line @typescript-eslint/naming-convention
usage: { prompt_tokens: 140 },
}),
})
vi.stubGlobal('fetch', mockFetch)
const sampleArchive = new Bun.Archive({
'frame_0001.jpg': Buffer.from('frame-1'),
})
const archiveBytes = await sampleArchive.bytes()
vi.mocked(s3Service.getObject).mockResolvedValue({
buffer: Buffer.from(archiveBytes.buffer, archiveBytes.byteOffset, archiveBytes.byteLength),
contentType: 'application/x-tar',
} as unknown as { buffer: Buffer; contentType: string })
const res = await generateVideoChunkEmbeddingActivity({
teamId: 't1',
chunkKey: 'files/asset-1/tmp-embedding-chunks/frames-0-60.tar',
})
expect(res.embedding).toHaveLength(768)
expect(res.usage.model).toBe('embeddinggemma-2')
expect(mockFetch).toHaveBeenCalled()
})
describe('getGemmaEmbeddingTargetFrameCount', () => {
it('should return 15 for standard aspect ratios', () => {
// 16:9
expect(getGemmaEmbeddingTargetFrameCount(1920, 1080)).toBe(15)
expect(getGemmaEmbeddingTargetFrameCount(1280, 720)).toBe(15)
expect(getGemmaEmbeddingTargetFrameCount(854, 480)).toBe(15)
// 9:16
expect(getGemmaEmbeddingTargetFrameCount(1080, 1920)).toBe(15)
// 1:1
expect(getGemmaEmbeddingTargetFrameCount(1080, 1080)).toBe(15)
expect(getGemmaEmbeddingTargetFrameCount(480, 480)).toBe(15)
// 4:3
expect(getGemmaEmbeddingTargetFrameCount(1440, 1080)).toBe(15)
expect(getGemmaEmbeddingTargetFrameCount(640, 480)).toBe(15)
// 3:4
expect(getGemmaEmbeddingTargetFrameCount(1080, 1440)).toBe(15)
// 21:9
expect(getGemmaEmbeddingTargetFrameCount(2560, 1080)).toBe(15)
expect(getGemmaEmbeddingTargetFrameCount(3440, 1440)).toBe(15)
})
it('should return 14 for non-standard aspect ratios and missing/invalid dimensions', () => {
expect(getGemmaEmbeddingTargetFrameCount(1000, 600)).toBe(14) // 5:3
expect(getGemmaEmbeddingTargetFrameCount(700, 500)).toBe(14) // 1.4:1
expect(getGemmaEmbeddingTargetFrameCount(854, 672)).toBe(14) // ~1.27:1
expect(getGemmaEmbeddingTargetFrameCount(undefined, undefined)).toBe(14)
expect(getGemmaEmbeddingTargetFrameCount(0, 0)).toBe(14)
expect(getGemmaEmbeddingTargetFrameCount(-100, 100)).toBe(14)
})
})
it('should sample uniform 15 frames when chunk archive contains standard 16:9 frames', async () => {
process.env.EMBEDDING_PROVIDER = 'gemma-embedding-2-openai'
const mockFetch = vi.fn().mockResolvedValue({
ok: true,
json: async () => ({
model: 'embeddinggemma-2',
data: [{ embedding: Array(768).fill(0.3) }],
// eslint-disable-next-line @typescript-eslint/naming-convention
usage: { prompt_tokens: 140 },
}),
})
vi.stubGlobal('fetch', mockFetch)
const sampleJpg = await sharp({
create: {
width: 160,
height: 90,
channels: 3,
background: { r: 0, g: 0, b: 0 },
},
})
.jpeg()
.toBuffer()
const frames: Record<string, Buffer> = {}
for (let i = 1; i <= 30; i++) {
frames[`frame_${String(i).padStart(4, '0')}.jpg`] = sampleJpg
}
const sampleArchive = new Bun.Archive(frames)
const archiveBytes = await sampleArchive.bytes()
vi.mocked(s3Service.getObject).mockResolvedValue({
buffer: Buffer.from(archiveBytes.buffer, archiveBytes.byteOffset, archiveBytes.byteLength),
contentType: 'application/x-tar',
} as unknown as { buffer: Buffer; contentType: string })
const res = await generateVideoChunkEmbeddingActivity({
teamId: 't1',
chunkKey: 'files/asset-1/tmp-embedding-chunks/frames-0-60.tar',
})
expect(res.embedding).toHaveLength(768)
const requestBody = JSON.parse(mockFetch.mock.calls[0][1].body)
expect(requestBody.input).toHaveLength(15)
})
it('should fallback to 14 frames when chunk archive contains non-standard or unparseable frames', async () => {
process.env.EMBEDDING_PROVIDER = 'gemma-embedding-2-openai'
const mockFetch = vi.fn().mockResolvedValue({
ok: true,
json: async () => ({
model: 'embeddinggemma-2',
data: [{ embedding: Array(768).fill(0.3) }],
// eslint-disable-next-line @typescript-eslint/naming-convention
usage: { prompt_tokens: 140 },
}),
})
vi.stubGlobal('fetch', mockFetch)
const frames: Record<string, Buffer> = {}
for (let i = 1; i <= 30; i++) {
frames[`frame_${String(i).padStart(4, '0')}.jpg`] = Buffer.from(`frame-${i}`)
}
const sampleArchive = new Bun.Archive(frames)
const archiveBytes = await sampleArchive.bytes()
vi.mocked(s3Service.getObject).mockResolvedValue({
buffer: Buffer.from(archiveBytes.buffer, archiveBytes.byteOffset, archiveBytes.byteLength),
contentType: 'application/x-tar',
} as unknown as { buffer: Buffer; contentType: string })
const res = await generateVideoChunkEmbeddingActivity({
teamId: 't1',
chunkKey: 'files/asset-1/tmp-embedding-chunks/frames-0-60.tar',
})
expect(res.embedding).toHaveLength(768)
const requestBody = JSON.parse(mockFetch.mock.calls[0][1].body)
expect(requestBody.input).toHaveLength(14)
})
it('should throw non-retryable ApplicationFailure when chunk archive contains no valid frames', async () => {
process.env.EMBEDDING_PROVIDER = 'gemma-embedding-2-openai'
const sampleArchive = new Bun.Archive({
'info.txt': Buffer.from('not an image'),
})
const archiveBytes = await sampleArchive.bytes()
vi.mocked(s3Service.getObject).mockResolvedValue({
buffer: Buffer.from(archiveBytes.buffer, archiveBytes.byteOffset, archiveBytes.byteLength),
contentType: 'application/x-tar',
} as unknown as { buffer: Buffer; contentType: string })
await expect(
generateVideoChunkEmbeddingActivity({
teamId: 't1',
chunkKey: 'files/asset-1/tmp-embedding-chunks/frames-0-60.tar',
}),
).rejects.toThrow('No extracted frames found in chunk archive')
})
it('should throw non-retryable ApplicationFailure when chunk archive data is corrupted', async () => {
process.env.EMBEDDING_PROVIDER = 'gemma-embedding-2-openai'
vi.mocked(s3Service.getObject).mockResolvedValue({
buffer: Buffer.from('corrupted non-tar bytes'),
contentType: 'application/x-tar',
} as unknown as { buffer: Buffer; contentType: string })
await expect(
generateVideoChunkEmbeddingActivity({
teamId: 't1',
chunkKey: 'files/asset-1/tmp-embedding-chunks/frames-0-60.tar',
}),
).rejects.toThrow('Failed to read chunk archive')
})
it('should throw non-retryable ApplicationFailure when an extracted frame is empty (0 bytes)', async () => {
process.env.EMBEDDING_PROVIDER = 'gemma-embedding-2-openai'
const sampleArchive = new Bun.Archive({
'frame_0001.jpg': Buffer.alloc(0),
})
const archiveBytes = await sampleArchive.bytes()
vi.mocked(s3Service.getObject).mockResolvedValue({
buffer: Buffer.from(archiveBytes.buffer, archiveBytes.byteOffset, archiveBytes.byteLength),
contentType: 'application/x-tar',
} as unknown as { buffer: Buffer; contentType: string })
await expect(
generateVideoChunkEmbeddingActivity({
teamId: 't1',
chunkKey: 'files/asset-1/tmp-embedding-chunks/frames-0-60.tar',
}),
).rejects.toThrow('is empty (0 bytes)')
})
describe('extractAiMetadataActivity', () => {
it('should return existing images if they are already in S3 storage', async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- mock returned object cast as any due to partial implementation
@@ -331,6 +663,18 @@ describe('AI Database Activities Integration', () => {
expect(ctx.agent.id).toBe(user.id)
expect(ctx.asset.id).toBe(asset.id)
expect(ctx.asset.mediaType).toBe('video/mp4')
process.env.ENABLE_EMBEDDING_AGENT = 'false'
try {
await expect(
getEmbeddingContextActivity({
teamId: team.id,
assetId: asset.id,
}),
).rejects.toThrow('embedding feature is disabled or agent not found')
} finally {
delete process.env.ENABLE_EMBEDDING_AGENT
}
})
it('should parse valid positive chunk duration and fallback on invalid or negative ones', async () => {
@@ -389,6 +733,45 @@ describe('AI Database Activities Integration', () => {
delete process.env.EMBEDDING_CHUNK_DURATION
delete process.env.EMBEDDING_CHUNK_OVERLAP
})
it('should return existing embeddings for the asset', async () => {
// Ensure agent exists
await prisma.agent.upsert({
where: { id: user.id },
update: {},
create: {
id: user.id,
teamId: team.id,
type: 'embedding',
enabled: true,
config: { provider: 'openai', model: 'gpt-4' },
},
})
await saveAssetEmbeddingsActivity({
assetId: asset.id,
embeddings: [
{ embedding: Array(1536).fill(0.01), startTime: 0.0, endTime: 60.0 },
{ embedding: Array(768).fill(0.02), startTime: 55.0, endTime: 115.0 },
],
})
const ctx = await getEmbeddingContextActivity({
teamId: team.id,
assetId: asset.id,
})
expect(ctx.existingEmbeddings).toHaveLength(2)
const chunk1 = ctx.existingEmbeddings.find((e) => e.startTime === 0)
expect(chunk1).toBeDefined()
expect(chunk1?.has1536).toBe(true)
expect(chunk1?.has768).toBe(false)
const chunk2 = ctx.existingEmbeddings.find((e) => e.startTime === 55)
expect(chunk2).toBeDefined()
expect(chunk2?.has1536).toBe(false)
expect(chunk2?.has768).toBe(true)
})
})
describe('saveAssetEmbeddingsActivity', () => {
@@ -423,5 +806,85 @@ describe('AI Database Activities Integration', () => {
expect(dbEmbeddings[0].endTime).toBe(60.0)
expect(dbEmbeddings[1].startTime).toBeNull()
})
it('should save 768-dim embeddings to embedding_768 column in database', async () => {
const embeddings = [
{
embedding: Array(768).fill(0.01),
startTime: 0.0,
endTime: 60.0,
},
{
embedding: Array(768).fill(0.02),
},
]
await saveAssetEmbeddingsActivity({
assetId: asset.id,
embeddings,
})
// Query raw embeddings from DB
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- db query output is a raw postgres result array typed as any
const dbEmbeddings: any[] = await prisma.$queryRaw`
SELECT id, asset_id as "assetId", (embedding_768 IS NOT NULL) as "has768", (embedding IS NOT NULL) as "has1536"
FROM asset_embeddings
WHERE asset_id = ${asset.id}
`
expect(dbEmbeddings.length).toBe(2)
expect(dbEmbeddings[0].has768).toBe(true)
expect(dbEmbeddings[0].has1536).toBe(false)
expect(dbEmbeddings[1].has768).toBe(true)
expect(dbEmbeddings[1].has1536).toBe(false)
})
})
describe('deleteAssetEmbeddingsActivity', () => {
it('should delete specific embeddings by id', async () => {
await saveAssetEmbeddingsActivity({
assetId: asset.id,
embeddings: [
{ embedding: Array(1536).fill(0.01), startTime: 0, endTime: 60 },
{ embedding: Array(1536).fill(0.02), startTime: 55, endTime: 115 },
],
})
const before = await prisma.assetEmbedding.findMany({
where: { assetId: asset.id },
})
expect(before).toHaveLength(2)
const targetId = before[0].id
await deleteAssetEmbeddingsActivity({
assetId: asset.id,
ids: [targetId],
})
const after = await prisma.assetEmbedding.findMany({
where: { assetId: asset.id },
})
expect(after).toHaveLength(1)
expect(after[0].id).not.toBe(targetId)
})
it('should delete all embeddings for an asset when ids is not provided', async () => {
await saveAssetEmbeddingsActivity({
assetId: asset.id,
embeddings: [
{ embedding: Array(1536).fill(0.01), startTime: 0, endTime: 60 },
{ embedding: Array(1536).fill(0.02), startTime: 55, endTime: 115 },
],
})
await deleteAssetEmbeddingsActivity({
assetId: asset.id,
})
const after = await prisma.assetEmbedding.findMany({
where: { assetId: asset.id },
})
expect(after).toHaveLength(0)
})
})
})
+575 -293
View File
@@ -1,15 +1,15 @@
import { GoogleGenAI } from '@google/genai'
import { s3Service } from '@shumai/core/src/s3/s3'
import { transcodeService } from '@shumai/core'
import { execFile } from 'child_process'
import * as fs from 'fs'
import * as os from 'os'
import * as path from 'path'
import { execFile } from 'child_process'
import { promisify } from 'util'
import { ApplicationFailure } from '@temporalio/activity'
import { prisma } from '@shumai/db'
import { getProxyType } from '@shumai/core/src/utils/mime'
import { ulid } from 'ulid'
import { ApplicationFailure, defineStep } from '@shumai/workflow-core'
import { prisma } from '@shumai/db'
import sharp from 'sharp'
const execFileAsync = promisify(execFile)
@@ -25,15 +25,6 @@ export interface GeneratedEmbedding {
endTime?: number
}
export interface GenerateEmbeddingParams {
teamId: string
assetId: string
context: {
agent: unknown
asset: unknown
}
}
async function generateMultimodalEmbedding(
ai: GoogleGenAI,
buffer: Buffer,
@@ -62,183 +53,109 @@ async function generateMultimodalEmbedding(
return values
}
export async function generateEmbeddingActivity(params: GenerateEmbeddingParams): Promise<{
embeddings: GeneratedEmbedding[]
interface OpenAiEmbeddingItem {
type?: string
// eslint-disable-next-line @typescript-eslint/naming-convention
image_url?: {
url: string
}
}
async function callGemmaEmbeddingServer(input: string | OpenAiEmbeddingItem[]): Promise<{
embedding: number[]
usage: Usage
}> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- context properties are fetched as JSON from the DB activity
const { asset } = params.context as any
const rawBaseUrl = process.env.GEMMA_EMBEDDING_OPENAI_BASE_URL || 'http://localhost:9379/v1'
if (!asset.mediaType) {
throw ApplicationFailure.create({ message: 'asset has no media type', nonRetryable: true })
}
const normalized = rawBaseUrl.replace(/\/+$/, '')
const endpoint = normalized.endsWith('/embeddings')
? normalized
: normalized.endsWith('/v1')
? `${normalized}/embeddings`
: `${normalized}/v1/embeddings`
const apiKey = process.env.GEMINI_API_KEY
if (!apiKey) {
const response = await fetch(endpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model: 'embeddinggemma-2',
input,
}),
})
if (!response.ok) {
const errorText = await response.text()
throw ApplicationFailure.create({
message: 'GEMINI_API_KEY environment variable is not configured',
nonRetryable: true,
message: `Embedding server returned status ${response.status}: ${errorText}`,
nonRetryable: false,
})
}
const resolvedApiKey = process.env[apiKey] || apiKey
const ai = new GoogleGenAI({ apiKey: resolvedApiKey })
const usage: Usage = {
model: 'gemini-embedding-2',
inputTokens: 0,
outputTokens: 0,
}
const proxyType =
(asset.media as PrismaJson.MediaInfo | null)?.proxyType ||
getProxyType(asset.mediaType, asset.name)
const isImage = proxyType === 'image'
const isVideo = proxyType === 'video'
if (!isImage && !isVideo) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- response json shape is dynamic from external endpoint
const json: any = await response.json()
const embedding = json.data?.[0]?.embedding
if (!embedding || !Array.isArray(embedding)) {
throw ApplicationFailure.create({
message: `unsupported media type for embeddings: ${asset.mediaType}`,
nonRetryable: true,
message: 'Invalid embedding returned from embedding server',
nonRetryable: false,
})
}
const key = asset.storageKey?.key
if (!key) {
throw ApplicationFailure.create({ message: 'asset has no key', nonRetryable: true })
}
const bucket = process.env.S3_BUCKET || 'shumai'
const results: GeneratedEmbedding[] = []
if (isImage) {
const { buffer: data } = await s3Service.getObject(bucket, key)
const embVec = await generateMultimodalEmbedding(ai, data, asset.mediaType)
results.push({ embedding: embVec })
} else if (isVideo) {
const inputSource = await s3Service.resolveInput(bucket, key)
const isRemote = inputSource.startsWith('http://') || inputSource.startsWith('https://')
const { stdout } = await execFileAsync('ffprobe', [
'-v',
'error',
'-show_entries',
'format=duration',
'-of',
'default=noprint_wrappers=1:nokey=1',
inputSource,
])
const duration = parseFloat(stdout.trim())
if (isNaN(duration)) {
throw ApplicationFailure.create({
message: 'failed to parse video duration',
nonRetryable: true,
})
}
const chunkSize = 60.0
for (let start = 0.0; start < duration; start += chunkSize) {
let end = start + chunkSize
if (end > duration) end = duration
const chunkTmp = path.join(os.tmpdir(), `video-chunk-${Date.now()}-${ulid()}.mp4`)
try {
await execFileAsync('ffmpeg', [
'-y',
'-loglevel',
'warning',
...(isRemote
? ['-reconnect', '1', '-reconnect_streamed', '1', '-reconnect_delay_max', '5']
: []),
'-ss',
start.toString(),
'-i',
inputSource,
'-map',
'0:V:0',
'-map',
'0:a:0?',
'-t',
(end - start).toString(),
'-c',
'copy',
chunkTmp,
])
const chunkData = fs.readFileSync(chunkTmp)
try {
const embVec = await generateMultimodalEmbedding(ai, chunkData, 'video/mp4')
results.push({ embedding: embVec, startTime: start, endTime: end })
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
console.error(
`failed to generate video embedding for chunk ${start}-${end}: ${e.message}`,
)
}
} finally {
if (fs.existsSync(chunkTmp)) {
fs.unlinkSync(chunkTmp)
}
}
}
}
return {
embeddings: results,
usage,
embedding,
usage: {
model: json.model || 'gemma-embedding-2-openai',
inputTokens: json.usage?.prompt_tokens ?? 0,
outputTokens: 0,
},
}
}
import { textEmbeddingService } from '@shumai/core/src/search/text-embedding'
export interface GenerateTextEmbeddingParams {
text: string
teamId: string
}
export async function generateTextEmbeddingActivity(params: GenerateTextEmbeddingParams): Promise<{
embedding: number[]
usage: Usage
}> {
const apiKey = process.env.GEMINI_API_KEY
if (!apiKey) {
throw ApplicationFailure.create({
message: 'GEMINI_API_KEY environment variable is not configured',
nonRetryable: true,
})
}
export const generateTextEmbeddingActivity = defineStep(
async function generateTextEmbeddingActivity(params: GenerateTextEmbeddingParams): Promise<{
embedding: number[]
usage: Usage
}> {
const provider = process.env.EMBEDDING_PROVIDER || 'gemini-embedding-2'
if (provider !== 'gemma-embedding-2-openai' && !process.env.GEMINI_API_KEY) {
throw ApplicationFailure.create({
message: 'GEMINI_API_KEY environment variable is not configured',
nonRetryable: true,
})
}
const resolvedApiKey = process.env[apiKey] || apiKey
const ai = new GoogleGenAI({ apiKey: resolvedApiKey })
try {
const result = await textEmbeddingService.generateEmbedding(params.text, {
teamId: params.teamId,
skipCache: true,
})
const usage: Usage = {
model: 'gemini-embedding-2',
inputTokens: 0,
outputTokens: 0,
}
const response = await ai.models.embedContent({
model: 'gemini-embedding-2',
contents: [
{
parts: [{ text: params.text }],
role: 'user',
},
],
config: {
outputDimensionality: 1536,
},
})
const values = response.embeddings?.[0]?.values
if (!values) {
throw new Error('No embedding values returned from gemini-embedding-2')
}
return {
embedding: values,
usage,
}
}
return {
embedding: result.embedding,
usage: {
model: result.usage?.model || provider,
inputTokens: result.usage?.inputTokens ?? 0,
outputTokens: result.usage?.outputTokens ?? 0,
},
}
} catch (err) {
if (err instanceof ApplicationFailure) {
throw err
}
throw ApplicationFailure.create({
message: err instanceof Error ? err.message : String(err),
nonRetryable: false,
})
}
},
)
export interface ExtractAiMetadataParams {
assetKey: string
@@ -247,7 +164,7 @@ export interface ExtractAiMetadataParams {
isImage: boolean
}
export async function extractAiMetadataActivity(
export const extractAiMetadataActivity = defineStep(async function extractAiMetadataActivity(
params: ExtractAiMetadataParams,
): Promise<string[]> {
const bucket = process.env.S3_BUCKET || 'shumai'
@@ -298,119 +215,232 @@ export async function extractAiMetadataActivity(
}
return generatedFiles
}
})
export async function getEmbeddingContextActivity(params: { teamId: string; assetId: string }) {
const team = await prisma.team.findUnique({
where: { id: params.teamId },
})
if (!team) {
throw ApplicationFailure.create({ message: 'failed to get team', nonRetryable: true })
}
const agent = await prisma.agent.findFirst({
where: {
type: 'embedding',
enabled: true,
user: { teamMembers: { some: { teamId: params.teamId } } },
},
})
if (!agent) {
throw ApplicationFailure.create({
message: 'embedding feature is disabled or agent not found',
nonRetryable: true,
export const getEmbeddingContextActivity = defineStep(
async function getEmbeddingContextActivity(params: { teamId: string; assetId: string }) {
const team = await prisma.team.findUnique({
where: { id: params.teamId },
})
}
const asset = await prisma.asset.findUnique({
where: { id: params.assetId },
include: { storageKey: true },
})
if (!asset) {
throw ApplicationFailure.create({ message: 'failed to get asset', nonRetryable: true })
}
if (!asset.mediaType) {
throw ApplicationFailure.create({ message: 'asset has no media type', nonRetryable: true })
}
const parsedDuration = parseFloat(process.env.EMBEDDING_CHUNK_DURATION || '')
const chunkDuration =
Number.isFinite(parsedDuration) && parsedDuration > 0 ? parsedDuration : 60.0
const parsedOverlap = parseFloat(process.env.EMBEDDING_CHUNK_OVERLAP || '')
const chunkOverlap = Number.isFinite(parsedOverlap) && parsedOverlap >= 0 ? parsedOverlap : 5.0
return {
agent,
asset,
chunkDuration,
chunkOverlap,
}
}
export async function saveAssetEmbeddingsActivity(params: {
assetId: string
embeddings: Array<{
embedding: number[]
startTime?: number
endTime?: number
}>
}) {
for (const item of params.embeddings) {
const embVec = JSON.stringify(item.embedding)
if (item.startTime !== undefined && item.endTime !== undefined) {
await prisma.$executeRaw`
INSERT INTO asset_embeddings (id, asset_id, embedding, start_time, end_time, updated_at)
VALUES (gen_random_uuid()::text, ${params.assetId}, ${embVec}::vector, ${item.startTime}, ${item.endTime}, NOW())
`
} else {
await prisma.$executeRaw`
INSERT INTO asset_embeddings (id, asset_id, embedding, updated_at)
VALUES (gen_random_uuid()::text, ${params.assetId}, ${embVec}::vector, NOW())
`
if (!team) {
throw ApplicationFailure.create({ message: 'failed to get team', nonRetryable: true })
}
}
const agent = await prisma.agent.findFirst({
where: {
type: 'embedding',
enabled: true,
user: { teamMembers: { some: { teamId: params.teamId } } },
},
})
if (!agent || process.env.ENABLE_EMBEDDING_AGENT === 'false') {
throw ApplicationFailure.create({
message: 'embedding feature is disabled or agent not found',
nonRetryable: true,
})
}
const asset = await prisma.asset.findUnique({
where: { id: params.assetId },
include: { storageKey: true },
})
if (!asset) {
throw ApplicationFailure.create({ message: 'failed to get asset', nonRetryable: true })
}
if (!asset.mediaType) {
throw ApplicationFailure.create({ message: 'asset has no media type', nonRetryable: true })
}
const parsedDuration = parseFloat(process.env.EMBEDDING_CHUNK_DURATION || '')
const chunkDuration =
Number.isFinite(parsedDuration) && parsedDuration > 0 ? parsedDuration : 60.0
const parsedOverlap = parseFloat(process.env.EMBEDDING_CHUNK_OVERLAP || '')
const chunkOverlap = Number.isFinite(parsedOverlap) && parsedOverlap >= 0 ? parsedOverlap : 5.0
const embeddingProvider = process.env.EMBEDDING_PROVIDER || 'gemini-embedding-2'
const existingEmbeddings = await prisma.$queryRaw<ExistingAssetEmbeddingInfo[]>`
SELECT
id,
start_time as "startTime",
end_time as "endTime",
(embedding IS NOT NULL) as "has1536",
(embedding_768 IS NOT NULL) as "has768"
FROM asset_embeddings
WHERE asset_id = ${params.assetId}
`
return {
agent,
asset,
chunkDuration,
chunkOverlap,
embeddingProvider,
existingEmbeddings,
}
},
)
export interface ExistingAssetEmbeddingInfo {
id: string
startTime: number | null
endTime: number | null
has1536: boolean
has768: boolean
}
export const deleteAssetEmbeddingsActivity = defineStep(
async function deleteAssetEmbeddingsActivity(params: { assetId: string; ids?: string[] }) {
if (params.ids && params.ids.length > 0) {
await prisma.assetEmbedding.deleteMany({
where: {
assetId: params.assetId,
id: { in: params.ids },
},
})
} else {
await prisma.assetEmbedding.deleteMany({
where: {
assetId: params.assetId,
},
})
}
},
)
export const saveAssetEmbeddingsActivity = defineStep(
async function saveAssetEmbeddingsActivity(params: {
assetId: string
embeddings: Array<{
embedding: number[]
startTime?: number
endTime?: number
}>
}) {
for (const item of params.embeddings) {
const embVec = JSON.stringify(item.embedding)
const is768 = item.embedding.length === 768
if (item.startTime !== undefined && item.endTime !== undefined) {
if (is768) {
await prisma.$executeRaw`
INSERT INTO asset_embeddings (id, asset_id, embedding_768, start_time, end_time, updated_at)
VALUES (gen_random_uuid()::text, ${params.assetId}, ${embVec}::vector, ${item.startTime}, ${item.endTime}, NOW())
`
} else {
await prisma.$executeRaw`
INSERT INTO asset_embeddings (id, asset_id, embedding, start_time, end_time, updated_at)
VALUES (gen_random_uuid()::text, ${params.assetId}, ${embVec}::vector, ${item.startTime}, ${item.endTime}, NOW())
`
}
} else {
if (is768) {
await prisma.$executeRaw`
INSERT INTO asset_embeddings (id, asset_id, embedding_768, updated_at)
VALUES (gen_random_uuid()::text, ${params.assetId}, ${embVec}::vector, NOW())
`
} else {
await prisma.$executeRaw`
INSERT INTO asset_embeddings (id, asset_id, embedding, updated_at)
VALUES (gen_random_uuid()::text, ${params.assetId}, ${embVec}::vector, NOW())
`
}
}
}
},
)
export interface GenerateImageEmbeddingParams {
teamId: string
assetKey: string
mediaType: string
}
export async function generateImageEmbeddingActivity(
params: GenerateImageEmbeddingParams,
): Promise<{
embedding: number[]
usage: Usage
}> {
const apiKey = process.env.GEMINI_API_KEY
if (!apiKey) {
throw ApplicationFailure.create({
message: 'GEMINI_API_KEY environment variable is not configured',
nonRetryable: true,
})
export const generateImageEmbeddingActivity = defineStep(
async function generateImageEmbeddingActivity(params: GenerateImageEmbeddingParams): Promise<{
embedding: number[]
usage: Usage
}> {
const provider = process.env.EMBEDDING_PROVIDER || 'gemini-embedding-2'
const { buffer: data } = await s3Service.getObject(
process.env.S3_BUCKET || 'shumai',
params.assetKey,
)
if (provider === 'gemma-embedding-2-openai') {
let imgData = data
let mimeType = params.mediaType || 'image/jpeg'
if (mimeType !== 'image/jpeg' && mimeType !== 'image/png') {
imgData = await sharp(data).jpeg().toBuffer()
mimeType = 'image/jpeg'
}
return callGemmaEmbeddingServer([
{
type: 'image_url',
// eslint-disable-next-line @typescript-eslint/naming-convention
image_url: {
url: `data:${mimeType};base64,${imgData.toString('base64')}`,
},
},
])
}
const apiKey = process.env.GEMINI_API_KEY
if (!apiKey) {
throw ApplicationFailure.create({
message: 'GEMINI_API_KEY environment variable is not configured',
nonRetryable: true,
})
}
const resolvedApiKey = process.env[apiKey] || apiKey
const ai = new GoogleGenAI({ apiKey: resolvedApiKey })
const usage: Usage = {
model: 'gemini-embedding-2',
inputTokens: 0,
outputTokens: 0,
}
const embVec = await generateMultimodalEmbedding(ai, data, params.mediaType)
return {
embedding: embVec,
usage,
}
},
)
/**
* Standard aspect ratios for video embedding:
* 1:1, 4:3, 3:4, 16:9, 9:16, 21:9 (including ultrawide 64:27), and 9:21.
*
* For these standard ratios, 15 frames guarantees that total input tokens stay strictly
* within the 2048 token signature bucket (<= 1982 tokens). For non-standard or custom
* aspect ratios (e.g. 5:3, 1.4:1), 14 frames is used to mathematically guarantee
* that sequence length never exceeds 2048 tokens (<= 1990 tokens), preventing OOM errors.
*/
export function getGemmaEmbeddingTargetFrameCount(width?: number, height?: number): number {
if (!width || !height || width <= 0 || height <= 0) {
return 14
}
const resolvedApiKey = process.env[apiKey] || apiKey
const ai = new GoogleGenAI({ apiKey: resolvedApiKey })
const ratio = width / height
const standardRatios = [
1 / 1, // 1:1
4 / 3, // 4:3
3 / 4, // 3:4
16 / 9, // 16:9
9 / 16, // 9:16
21 / 9, // 21:9
64 / 27, // 21:9 ultrawide (2560x1080, 3440x1440)
9 / 21, // 9:21
27 / 64, // 9:21 ultrawide portrait
]
const usage: Usage = {
model: 'gemini-embedding-2',
inputTokens: 0,
outputTokens: 0,
}
const { buffer: data } = await s3Service.getObject(
process.env.S3_BUCKET || 'shumai',
params.assetKey,
)
const embVec = await generateMultimodalEmbedding(ai, data, params.mediaType)
return {
embedding: embVec,
usage,
}
// Allow up to 3% relative tolerance for minor encoder rounding (e.g. 854x480 vs 16:9)
const isStandard = standardRatios.some((std) => Math.abs(ratio - std) / std <= 0.03)
return isStandard ? 15 : 14
}
export interface GenerateVideoChunkEmbeddingParams {
@@ -418,44 +448,296 @@ export interface GenerateVideoChunkEmbeddingParams {
chunkKey: string
}
export async function generateVideoChunkEmbeddingActivity(
params: GenerateVideoChunkEmbeddingParams,
): Promise<{
embedding: number[]
usage: Usage
}> {
const apiKey = process.env.GEMINI_API_KEY
if (!apiKey) {
export const generateVideoChunkEmbeddingActivity = defineStep(
async function generateVideoChunkEmbeddingActivity(
params: GenerateVideoChunkEmbeddingParams,
): Promise<{
embedding: number[]
usage: Usage
}> {
const provider = process.env.EMBEDDING_PROVIDER || 'gemini-embedding-2'
const isGemma = provider === 'gemma-embedding-2-openai' || params.chunkKey.endsWith('.tar')
if (isGemma) {
const { buffer: data } = await s3Service.getObject(
process.env.S3_BUCKET || 'shumai',
params.chunkKey,
)
let filesMap: Map<string, File>
try {
const archive = new Bun.Archive(data)
filesMap = await archive.files()
} catch (err) {
throw ApplicationFailure.create({
message: `Failed to read chunk archive ${params.chunkKey}: ${err instanceof Error ? err.message : String(err)}`,
nonRetryable: true,
})
}
const frameFiles = Array.from(filesMap.keys())
.filter((f) => /\.(jpe?g|png|webp)$/i.test(f))
.sort()
if (frameFiles.length === 0) {
throw ApplicationFailure.create({
message: `No extracted frames found in chunk archive ${params.chunkKey}`,
nonRetryable: true,
})
}
let targetFrameCount = 14
try {
const firstFile = filesMap.get(frameFiles[0])
if (firstFile) {
const firstFileBytes = await firstFile.bytes()
if (firstFileBytes.byteLength > 0) {
const meta = await sharp(Buffer.from(firstFileBytes)).metadata()
targetFrameCount = getGemmaEmbeddingTargetFrameCount(meta.width, meta.height)
}
}
} catch {
targetFrameCount = 14
}
let selectedFrames = frameFiles
if (selectedFrames.length > targetFrameCount) {
const step = (selectedFrames.length - 1) / (targetFrameCount - 1)
selectedFrames = Array.from(
{ length: targetFrameCount },
(_, i) => selectedFrames[Math.round(i * step)],
)
}
const input: OpenAiEmbeddingItem[] = await Promise.all(
selectedFrames.map(async (f) => {
const file = filesMap.get(f)!
const fileBytes = await file.bytes()
if (fileBytes.byteLength === 0) {
throw ApplicationFailure.create({
message: `Extracted frame ${f} in chunk archive ${params.chunkKey} is empty (0 bytes)`,
nonRetryable: true,
})
}
return {
type: 'image_url',
// eslint-disable-next-line @typescript-eslint/naming-convention
image_url: {
url: `data:image/jpeg;base64,${Buffer.from(fileBytes).toString('base64')}`,
},
}
}),
)
return await callGemmaEmbeddingServer(input)
}
const apiKey = process.env.GEMINI_API_KEY
if (!apiKey) {
throw ApplicationFailure.create({
message: 'GEMINI_API_KEY environment variable is not configured',
nonRetryable: true,
})
}
const resolvedApiKey = process.env[apiKey] || apiKey
const ai = new GoogleGenAI({ apiKey: resolvedApiKey })
const usage: Usage = {
model: 'gemini-embedding-2',
inputTokens: 0,
outputTokens: 0,
}
try {
const { buffer: data } = await s3Service.getObject(
process.env.S3_BUCKET || 'shumai',
params.chunkKey,
)
const embVec = await generateMultimodalEmbedding(ai, data, 'video/mp4')
return {
embedding: embVec,
usage,
}
} catch (err) {
throw ApplicationFailure.create({
message: `Failed to generate video chunk embedding for key ${params.chunkKey}: ${err instanceof Error ? err.message : String(err)}`,
nonRetryable: false,
})
}
},
)
export interface TranscodeVideoChunkParams {
assetId: string
assetKey?: string
filePath?: string
startTime: number
endTime: number
format?: 'video' | 'frames'
}
export const transcodeVideoChunkActivity = defineStep(async function transcodeVideoChunkActivity(
params: TranscodeVideoChunkParams,
): Promise<{ chunkKey: string }> {
if (!params.filePath && !params.assetKey) {
throw ApplicationFailure.create({
message: 'GEMINI_API_KEY environment variable is not configured',
message: 'Neither filePath nor assetKey was provided for video chunk transcoding',
nonRetryable: true,
})
}
const resolvedApiKey = process.env[apiKey] || apiKey
const ai = new GoogleGenAI({ apiKey: resolvedApiKey })
if (params.format === 'frames') {
const tmpDir = transcodeService.createTempDir('video-chunk-frames-')
try {
const bucket = process.env.S3_BUCKET || 'shumai'
const inputSource =
params.filePath ||
(params.assetKey ? await s3Service.resolveInput(bucket, params.assetKey) : '')
if (!inputSource) {
throw ApplicationFailure.create({
message: 'Neither filePath nor assetKey was provided for video chunk transcoding',
nonRetryable: true,
})
}
const isRemote = inputSource.startsWith('http://') || inputSource.startsWith('https://')
const usage: Usage = {
model: 'gemini-embedding-2',
inputTokens: 0,
outputTokens: 0,
const duration = Math.max(0.1, params.endTime - params.startTime)
const fpsFilter = duration > 16 ? `fps=${16 / duration}` : 'fps=1'
const vframesArgs = duration > 16 ? ['-vframes', '16'] : []
await execFileAsync('ffmpeg', [
'-y',
'-loglevel',
'warning',
...(isRemote
? ['-reconnect', '1', '-reconnect_streamed', '1', '-reconnect_delay_max', '5']
: []),
'-ss',
params.startTime.toString(),
'-i',
inputSource,
'-map',
'0:V:0',
'-t',
duration.toString(),
'-vf',
fpsFilter,
...vframesArgs,
'-q:v',
'2',
path.join(tmpDir, 'frame_%04d.jpg'),
])
const frameFiles = fs
.readdirSync(tmpDir)
.filter((f) => /\.(jpe?g|png|webp)$/i.test(f))
.sort()
const archiveEntries: Record<string, Buffer> = {}
for (const file of frameFiles) {
archiveEntries[file] = fs.readFileSync(path.join(tmpDir, file))
}
const archive = new Bun.Archive(archiveEntries)
const archiveBytes = await archive.bytes()
const archiveData = Buffer.from(
archiveBytes.buffer,
archiveBytes.byteOffset,
archiveBytes.byteLength,
)
const key = `files/${params.assetId}/tmp-embedding-chunks/frames-${params.startTime}-${params.endTime}-${ulid()}.tar`
await s3Service.putObject(bucket, key, archiveData, archiveData.length, 'application/x-tar')
return { chunkKey: key }
} catch (err) {
if (err instanceof ApplicationFailure) {
throw err
}
throw ApplicationFailure.create({
message: `Failed to extract video chunk frames for ${params.startTime}-${params.endTime}: ${err instanceof Error ? err.message : String(err)}`,
nonRetryable: false,
})
} finally {
transcodeService.removeDir(tmpDir)
}
}
const chunkTmp = path.join(os.tmpdir(), `video-chunk-${Date.now()}-${ulid()}.mp4`)
try {
const { buffer: data } = await s3Service.getObject(
process.env.S3_BUCKET || 'shumai',
params.chunkKey,
)
const embVec = await generateMultimodalEmbedding(ai, data, 'video/mp4')
return {
embedding: embVec,
usage,
const bucket = process.env.S3_BUCKET || 'shumai'
const inputSource =
params.filePath ||
(params.assetKey ? await s3Service.resolveInput(bucket, params.assetKey) : '')
if (!inputSource) {
throw ApplicationFailure.create({
message: 'Neither filePath nor assetKey was provided for video chunk transcoding',
nonRetryable: true,
})
}
const isRemote = inputSource.startsWith('http://') || inputSource.startsWith('https://')
// Slice video segment using ffmpeg, force 1fps and remove audio for gemini-embedding-2 optimization
// Note: -ss placed before -i for fast input seeking via demuxer Range requests
await execFileAsync('ffmpeg', [
'-y',
'-loglevel',
'warning',
...(isRemote
? ['-reconnect', '1', '-reconnect_streamed', '1', '-reconnect_delay_max', '5']
: []),
'-ss',
params.startTime.toString(),
'-i',
inputSource,
'-map',
'0:V:0',
'-t',
(params.endTime - params.startTime).toString(),
'-vf',
'fps=1',
'-c:v',
'libx264',
'-preset',
'ultrafast',
'-crf',
'28',
'-an',
chunkTmp,
])
const chunkData = fs.readFileSync(chunkTmp)
// Upload to S3
const key = `files/${params.assetId}/tmp-embedding-chunks/chunk-${params.startTime}-${params.endTime}-${ulid()}.mp4`
await s3Service.putObject(bucket, key, chunkData, chunkData.length, 'video/mp4')
return { chunkKey: key }
} catch (err) {
if (err instanceof ApplicationFailure) {
throw err
}
throw ApplicationFailure.create({
message: `Failed to generate video chunk embedding for key ${params.chunkKey}: ${err instanceof Error ? err.message : String(err)}`,
message: `Failed to transcode video chunk for ${params.startTime}-${params.endTime}: ${err instanceof Error ? err.message : String(err)}`,
nonRetryable: false,
})
} finally {
if (fs.existsSync(chunkTmp)) {
try {
fs.unlinkSync(chunkTmp)
} catch (e) {
console.error('Failed to cleanup local chunk file:', e)
}
}
}
}
})
export const deleteS3ObjectActivity = defineStep(
async function deleteS3ObjectActivity(params: { key: string }): Promise<void> {
const bucket = process.env.S3_BUCKET || 'shumai'
await s3Service.deleteObject(bucket, params.key)
},
{ runOnCancel: true },
)
@@ -1,8 +1,8 @@
import { describe, it, expect, beforeEach } from 'vitest'
import { prisma } from '@shumai/db'
import { setupTestDbHooks } from '@shumai/db/test'
import { resolveAnnotationsById } from './annotation-resolver'
import { DatabaseSessionStorage } from '../database-session-storage'
import { resolveAnnotationsById } from '@shumai/core/src/asset-read/annotations'
import { DatabaseSessionStorage } from './database-session-storage'
import type { SessionTreeEntry } from '@earendil-works/pi-agent-core'
import { degreeToSecond } from '@shumai/core/src/utils/model3d'
@@ -7,7 +7,7 @@ import { DatabaseSessionStorage } from './database-session-storage'
import { agentService } from '@shumai/core/src/agent/agent'
import { createAgentSession, type DbProviderInfo } from './index'
import * as sandboxedBashModule from './tools/sandboxed-bash'
import * as readAssetModule from './tools/read-asset'
import * as operationToolsModule from './operation-tools'
describe('DatabaseSessionStorage', () => {
setupTestDbHooks()
@@ -450,8 +450,8 @@ describe('DatabaseSessionStorage', () => {
})
const sessionId = initialStorage.sessionId
// 2. Spy on media tool constructor
const createReadAssetToolSpy = vi.spyOn(readAssetModule, 'createReadAssetTool')
// 2. Spy on the Operation tools builder (read_asset comes from the Operation registry)
const buildOperationToolsSpy = vi.spyOn(operationToolsModule, 'buildOperationTools')
// 3. Resume the session via createAgentSession with a NEW comment ID
await createAgentSession({
@@ -468,8 +468,11 @@ describe('DatabaseSessionStorage', () => {
providers: mockProviders,
})
// 4. Assert that the tool was instantiated using user ID
expect(createReadAssetToolSpy).toHaveBeenCalledWith(user.id)
// 4. Assert that the tools were built for the user
expect(buildOperationToolsSpy).toHaveBeenCalledWith(
expect.objectContaining({ userId: user.id }),
expect.objectContaining({}),
)
})
it('should instantiate media tools with user ID in subsequent turns (video)', async () => {
@@ -502,8 +505,8 @@ describe('DatabaseSessionStorage', () => {
})
const sessionId = initialStorage.sessionId
// 2. Spy on media tool constructor
const createReadAssetToolSpy = vi.spyOn(readAssetModule, 'createReadAssetTool')
// 2. Spy on the Operation tools builder (read_asset comes from the Operation registry)
const buildOperationToolsSpy = vi.spyOn(operationToolsModule, 'buildOperationTools')
// 3. Resume the session via createAgentSession with a NEW comment ID
await createAgentSession({
@@ -520,8 +523,11 @@ describe('DatabaseSessionStorage', () => {
providers: mockProviders,
})
// 4. Assert that the tool was instantiated using user ID
expect(createReadAssetToolSpy).toHaveBeenCalledWith(user.id)
// 4. Assert that the tools were built for the user
expect(buildOperationToolsSpy).toHaveBeenCalledWith(
expect.objectContaining({ userId: user.id }),
expect.objectContaining({}),
)
})
describe('P1 Bug Reproductions', () => {
+16 -39
View File
@@ -18,20 +18,13 @@ import * as fs from 'fs'
import * as path from 'path'
import { DatabaseSessionStorage } from './database-session-storage'
import { metadataService } from '@shumai/core/src/metadata/metadata'
import { createCreateFileTool } from './tools/create-file'
import { createCreateFolderTool } from './tools/create-folder'
import { createCreateVersionTool } from './tools/create-version'
import { createDownloadAssetTool } from './tools/download-asset'
import { createListAssetsTool } from './tools/list-assets'
import { createReadAssetTool } from './tools/read-asset'
import { createReadSkillTool } from './tools/read-skill'
import { createReadThreadTool } from './tools/read-thread'
import { createSandboxedBashTool } from './tools/sandboxed-bash'
import { createGenerateImageTool } from './tools/generate-image'
import { createGenerateVideoTool } from './tools/generate-video'
import { createRenameAssetTool } from './tools/rename-asset'
import { createMoveAssetsTool } from './tools/move-assets'
import { createDeleteAssetTool } from './tools/delete-asset'
import { buildOperationTools } from './operation-tools'
import { createAutofillReadAssetTool } from './operation-extensions'
import { mediaGenerationService } from '@shumai/core/src/media-generation/media-generation'
import { serializeContextToXml } from './context/serialize-context'
import { DEFAULT_DENIED_TOOLS, type ShumaiMessageContext } from '@shumai/dtos'
@@ -271,13 +264,12 @@ export async function createAgentSession(params: CreateAgentSessionParams) {
const deniedTools = agentConfig?.deniedTools ?? [...DEFAULT_DENIED_TOOLS]
const mediaTools: AgentTool[] = []
if (userId) {
mediaTools.push(createReadAssetTool(userId))
} else if (agent?.type === 'autofill' && assetId) {
// Agents acting for a user get read_asset / get_asset_render from the Operation registry
// (see systemTools below); the autofill system agent has its own team-scoped read_asset.
if (!userId && agent?.type === 'autofill' && assetId) {
mediaTools.push(
createReadAssetTool({
createAutofillReadAssetTool({
teamId,
agentType: 'autofill',
targetAssetId: assetId,
}),
)
@@ -338,21 +330,15 @@ export async function createAgentSession(params: CreateAgentSessionParams) {
const systemTools: AgentTool[] = []
if (userId) {
const metadataSchema = await buildProjectMetadataSchema(projectId)
const agentContext = { teamId, agentId }
const creationMetadataSchema = await buildProjectMetadataSchema(projectId)
systemTools.push(
createListAssetsTool(userId),
createCreateFolderTool(userId, agentContext),
createCreateFileTool(userId, metadataSchema, agentContext),
createCreateVersionTool(userId, metadataSchema, agentContext),
createDownloadAssetTool(userId),
createRenameAssetTool(userId, agentContext),
createMoveAssetsTool(userId, agentContext),
createDeleteAssetTool(userId, agentContext),
// Shared Operations (also exposed via MCP and the CLI): browsing, searching, organizing,
// reading and downloading assets, creating files and versions, comments and metadata
...buildOperationTools({ userId, agentId, teamId, projectId }, { creationMetadataSchema }),
)
}
const readThread = createReadThreadTool()
const readThread = createReadThreadTool({ userId, teamId })
const rawTools = [
...mediaTools,
readSkill,
@@ -604,44 +590,35 @@ export function formatSkillsForPrompt(
}
import { WorkflowTaskType } from '@shumai/db'
import { registerActivities, registerWorkflow } from '@shumai/workflow-core'
import * as agentActivities from './activities/agent'
import * as aiActivities from './activities/ai'
import { registerWorkflow } from '@shumai/workflow-core'
import { agentAutofillMedia } from './workflows/agent-autofill'
import { agentChat } from './workflows/agent-chat'
import { agentEmbeddingMedia } from './workflows/agent-embedding'
import { queryEmbeddingForSearch } from './workflows/query-embedding-for-search'
export function initAgentWorkflows() {
registerWorkflow(WorkflowTaskType.ai_embedding, agentEmbeddingMedia)
registerWorkflow(WorkflowTaskType.query_embedding_for_search, queryEmbeddingForSearch)
registerWorkflow(WorkflowTaskType.ai_metadata_autofill, agentAutofillMedia)
registerWorkflow(WorkflowTaskType.chat, agentChat)
registerActivities(agentActivities)
registerActivities(aiActivities)
}
export * from './activities/agent'
export {
extractAiMetadataActivity,
generateEmbeddingActivity,
generateImageEmbeddingActivity,
generateTextEmbeddingActivity,
generateVideoChunkEmbeddingActivity,
saveAssetEmbeddingsActivity,
deleteAssetEmbeddingsActivity,
type ExtractAiMetadataParams,
type GeneratedEmbedding,
type GenerateEmbeddingParams,
type GenerateTextEmbeddingParams,
type ExistingAssetEmbeddingInfo,
} 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/query-embedding-for-search'
export * from './tools/generate-image'
export * from './tools/generate-video'
export * from './tools/rename-asset'
export * from './tools/move-assets'
export * from './tools/delete-asset'
export * from './operation-tools'
@@ -0,0 +1,294 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
import * as fs from 'fs'
import * as path from 'path'
import { prisma, type Asset, type StorageKey } from '@shumai/db'
import { s3Service } from '@shumai/core/src/s3/s3'
import { authzService } from '@shumai/core/src/authz/authz'
import { getOperation } from '@shumai/core/src/operations'
import { toAgentTool } from '../operation-tools'
import './download-asset'
vi.mock('@shumai/db', async (importOriginal) => {
const actual = await importOriginal<typeof import('@shumai/db')>()
return {
...actual,
prisma: {
asset: { findUnique: vi.fn(), findFirst: vi.fn() },
storageKey: { findFirst: vi.fn(), findUnique: vi.fn() },
},
}
})
vi.mock('@shumai/core/src/s3/s3', async (importOriginal) => {
const actual = await importOriginal<typeof import('@shumai/core/src/s3/s3')>()
return {
...actual,
s3Service: {
headObject: vi.fn(),
downloadToFile: vi.fn(),
presign: vi.fn().mockResolvedValue('https://signed.example/file'),
},
}
})
vi.mock('@shumai/core/src/authz/authz', async (importOriginal) => {
const actual = await importOriginal<typeof import('@shumai/core/src/authz/authz')>()
return { ...actual, authzService: { hasPermission: vi.fn() } }
})
type Head = Awaited<ReturnType<typeof s3Service.headObject>>
type Saved = { filePath: string; absolutePath: string; contentType: string; size: number }
const piDir = path.join(process.cwd(), '.pi')
function downloadTool(userId = 'user-1') {
return toAgentTool(getOperation('download_asset')!, { userId })
}
function textOf(result: { content: unknown[] }): string {
return (result.content[0] as { text: string }).text
}
function mockAssets(...assets: Array<Record<string, unknown>>) {
vi.mocked(prisma.asset.findUnique).mockImplementation(
(async (args: { where: { id: string } }) =>
assets.find((a) => a.id === args.where.id) ?? null) as never,
)
}
function mockStorage(contentType: string, write = 'bytes') {
vi.mocked(s3Service.headObject).mockResolvedValue({ size: 1234, contentType } as Head)
vi.mocked(s3Service.downloadToFile).mockImplementation(async (_bucket, _key, dest) => {
await fs.promises.writeFile(dest, write)
})
}
const photo = {
id: 'img-1',
name: 'sample_photo.jpg',
type: 'file',
isDeleted: false,
storageKey: { key: 'files/up-1/sample_photo.jpg' },
media: { proxyType: 'image', imageTranscodes: [{ key: 'files/img-1/proxy.webp' }] },
}
describe('download_asset agent tool', () => {
const created: string[] = []
beforeEach(() => {
vi.clearAllMocks()
vi.mocked(authzService.hasPermission).mockResolvedValue()
})
afterEach(() => {
for (const file of created.splice(0)) fs.rmSync(file, { force: true })
})
it('offers assetIds, proxy, and the agent-only key parameter', () => {
const tool = downloadTool()
const schema = tool.parameters as { properties: Record<string, unknown>; required?: string[] }
expect(Object.keys(schema.properties)).toEqual(['assetIds', 'proxy', 'key'])
expect(schema.required ?? []).not.toContain('assetIds')
expect(tool.description).toContain('.pi directory')
})
it('saves the web preview into .pi by default, named after the asset', async () => {
mockAssets(photo)
mockStorage('image/webp', 'proxy-bytes')
const result = await downloadTool().execute('call-1', { assetIds: ['img-1'] })
const expectedPath = path.join(piDir, 'img-1_sample_photo.webp')
created.push(expectedPath)
expect(authzService.hasPermission).toHaveBeenCalledWith({
user: { id: 'user-1' },
permission: 'Read',
type: 'asset',
id: 'img-1',
})
expect(s3Service.downloadToFile).toHaveBeenCalledWith(
'shumai',
'files/img-1/proxy.webp',
expectedPath,
)
expect(fs.readFileSync(expectedPath, 'utf-8')).toBe('proxy-bytes')
expect(textOf(result)).toBe(
[
`Downloaded "sample_photo.webp" (ID: img-1, proxy, image/webp, 11 B) to "${path.join('.pi', 'img-1_sample_photo.webp')}".`,
'Remember to delete these temporary files when finished.',
].join('\n'),
)
const details = result.details as { files: Saved[] }
expect(details.files[0]).toMatchObject({
filePath: path.join('.pi', 'img-1_sample_photo.webp'),
contentType: 'image/webp',
size: 11,
})
})
it('saves the original with proxy false', async () => {
mockAssets(photo)
mockStorage('image/jpeg')
await downloadTool().execute('call-1', { assetIds: ['img-1'], proxy: false })
const expectedPath = path.join(piDir, 'img-1_sample_photo.jpg')
created.push(expectedPath)
expect(s3Service.downloadToFile).toHaveBeenCalledWith(
'shumai',
'files/up-1/sample_photo.jpg',
expectedPath,
)
})
it('downloads several files and the latest version of a version stack', async () => {
mockAssets(photo, { id: 'stack-1', name: 'banana', type: 'version_stack', isDeleted: false })
vi.mocked(prisma.asset.findFirst).mockResolvedValue({
id: 'file-v2',
name: 'banana_pig.png',
type: 'file',
isDeleted: false,
storageKey: { key: 'files/up-2/banana_pig.png' },
media: { proxyType: 'image', imageTranscodes: [{ key: 'files/file-v2/proxy.webp' }] },
} as unknown as Asset)
mockStorage('image/webp')
const result = await downloadTool().execute('call-1', {
assetIds: ['img-1', 'stack-1'],
key: null,
})
created.push(
path.join(piDir, 'img-1_sample_photo.webp'),
path.join(piDir, 'file-v2_banana_pig.webp'),
)
expect(prisma.asset.findFirst).toHaveBeenCalledWith({
where: { parentId: 'stack-1', isDeleted: false },
orderBy: { sortIndex: 'asc' },
include: { storageKey: true },
})
expect(s3Service.downloadToFile).toHaveBeenCalledTimes(2)
expect(textOf(result)).toContain('Downloaded "banana_pig.webp" (ID: file-v2, proxy')
})
it('rejects folders', async () => {
mockAssets({ id: 'folder-1', name: 'Renders', type: 'folder', isDeleted: false })
await expect(downloadTool().execute('call-1', { assetIds: ['folder-1'] })).rejects.toThrow(
'Asset folder-1 ("Renders") is a folder. Download the files inside it instead.',
)
expect(s3Service.downloadToFile).not.toHaveBeenCalled()
})
it('checks Read on every asset before downloading anything', async () => {
mockAssets(photo)
vi.mocked(authzService.hasPermission).mockImplementation(async ({ id }) => {
if (id === 'secret') throw new Error('Forbidden')
})
await expect(
downloadTool().execute('call-1', { assetIds: ['img-1', 'secret'] }),
).rejects.toThrow('Forbidden')
expect(s3Service.downloadToFile).not.toHaveBeenCalled()
})
it('requires assetIds or key', async () => {
await expect(downloadTool().execute('call-1', { assetIds: null, key: null })).rejects.toThrow(
'Invalid input for download_asset',
)
})
it('rejects assetIds and key together', async () => {
await expect(
downloadTool().execute('call-1', { assetIds: ['img-1'], key: 'files/img-1/a.webp' }),
).rejects.toThrow('Provide either "assetIds" or "key", not both.')
})
describe('by storage key', () => {
it('requires a user', async () => {
await expect(
downloadTool('').execute('call-1', { key: 'files/ast-1/shot.webp' }),
).rejects.toThrow('User ID is required for authorization.')
})
it('rejects keys outside files/ and path traversal', async () => {
await expect(downloadTool().execute('call-1', { key: 'avatars/user-1.png' })).rejects.toThrow(
'Invalid storage key format: key must start with "files/"',
)
await expect(
downloadTool().execute('call-1', { key: 'files/../../etc/passwd' }),
).rejects.toThrow('cannot contain ".."')
})
it('rejects keys that belong to no asset', async () => {
vi.mocked(prisma.asset.findUnique).mockResolvedValue(null)
vi.mocked(prisma.storageKey.findFirst).mockResolvedValue(null)
vi.mocked(prisma.storageKey.findUnique).mockResolvedValue(null)
await expect(
downloadTool().execute('call-1', { key: 'files/nope/shot.webp' }),
).rejects.toThrow('does not belong to any valid asset or the asset has been deleted')
})
it('checks Read on the owning asset', async () => {
mockAssets({ id: 'other-project-asset' })
vi.mocked(authzService.hasPermission).mockRejectedValue(new Error('Forbidden'))
await expect(
downloadTool().execute('call-1', { key: 'files/other-project-asset/shots/a.webp' }),
).rejects.toThrow('Forbidden')
expect(authzService.hasPermission).toHaveBeenCalledWith({
user: { id: 'user-1' },
permission: 'Read',
type: 'asset',
id: 'other-project-asset',
})
expect(s3Service.downloadToFile).not.toHaveBeenCalled()
})
it('downloads a read_asset artifact into .pi', async () => {
mockAssets({ id: 'ast-123' })
mockStorage('image/webp', 'frame-bytes')
const result = await downloadTool().execute('call-1', {
key: 'files/ast-123/screenshots/shot_5.0s.webp',
})
const expectedPath = path.join(piDir, 'shot_5.0s.webp')
created.push(expectedPath)
expect(fs.readFileSync(expectedPath, 'utf-8')).toBe('frame-bytes')
expect(textOf(result)).toBe(
`Downloaded storage key "files/ast-123/screenshots/shot_5.0s.webp" to "${path.join('.pi', 'shot_5.0s.webp')}". Remember to delete this temporary file when finished.`,
)
expect(result.details).toMatchObject({
key: 'files/ast-123/screenshots/shot_5.0s.webp',
assetId: 'ast-123',
size: Buffer.from('frame-bytes').length,
})
})
it('resolves original upload keys through the storage key', async () => {
vi.mocked(prisma.asset.findUnique).mockResolvedValue(null)
vi.mocked(prisma.storageKey.findFirst).mockResolvedValue({
id: 'sk-1',
key: 'files/upload-ulid-456/photo.png',
assets: [{ id: 'asset-photo-1' }],
} as unknown as StorageKey & { assets: Asset[] })
const pngHeader = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])
vi.mocked(s3Service.headObject).mockResolvedValue({
size: 8,
contentType: 'application/octet-stream',
} as Head)
vi.mocked(s3Service.downloadToFile).mockImplementation(async (_b, _k, dest) => {
await fs.promises.writeFile(dest, pngHeader)
})
const result = await downloadTool().execute('call-1', {
key: 'files/upload-ulid-456/photo.png',
})
created.push(path.join(piDir, 'photo.png'))
expect(authzService.hasPermission).toHaveBeenCalledWith(
expect.objectContaining({ id: 'asset-photo-1' }),
)
// Falls back to detecting the type from the bytes
expect(result.details).toMatchObject({ assetId: 'asset-photo-1', contentType: 'image/png' })
})
})
})
@@ -0,0 +1,124 @@
import * as fs from 'fs'
import * as path from 'path'
import { z } from 'zod'
import type { AgentToolResult } from '@earendil-works/pi-agent-core'
import { downloadAsset, MAX_DOWNLOAD_ASSETS, type DownloadAssetOutput } from '@shumai/operations'
import type { User } from '@shumai/db'
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
import { storageBucket } from '@shumai/core/src/asset-read'
import { s3Service } from '@shumai/core/src/s3/s3'
import { sanitizeFilename } from '@shumai/core/src/utils/filename'
import { readFileMimeType } from '@shumai/core/src/utils/file-mime'
import { resolveAssetIdFromKey } from '../tools/download-asset'
import { registerAgentToolExtension, type AgentToolExtension } from '../operation-tools'
const CLEANUP_REMINDER = 'Remember to delete these temporary files when finished.'
/** The agent's sandbox, where downloaded files are saved for local scripts and bash. */
function sandboxDir(): string {
const dir = path.join(process.cwd(), '.pi')
fs.mkdirSync(dir, { recursive: true })
return dir
}
function formatSize(bytes: number): string {
if (bytes < 1024) return `${bytes} B`
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`
}
/** Saves a storage object into the sandbox; returns the paths and detected content type. */
async function saveToSandbox(key: string, filename: string) {
const dir = sandboxDir()
const absolutePath = path.join(dir, filename)
const bucket = storageBucket()
const info = await s3Service.headObject(bucket, key).catch(() => null)
await s3Service.downloadToFile(bucket, key, absolutePath)
const size = await fs.promises
.stat(absolutePath)
.then((s) => s.size)
.catch(() => info?.size ?? 0)
const contentType =
info?.contentType && info.contentType !== 'application/octet-stream'
? info.contentType
: readFileMimeType(absolutePath)
return { absolutePath, filePath: path.join('.pi', filename), size, contentType }
}
/** Downloads one storage key (e.g. a frame from read_asset) after checking Read on its asset. */
async function downloadKey(key: string, userId: string): Promise<AgentToolResult<unknown>> {
const owningAssetId = await resolveAssetIdFromKey(key)
await authzService.hasPermission({
user: { id: userId } as User,
permission: Permission.Read,
type: ResourceType.Asset,
id: owningAssetId,
})
const filename = sanitizeFilename(path.basename(key)) || 'downloaded_file'
const saved = await saveToSandbox(key, filename)
return {
content: [
{
type: 'text',
text: `Downloaded storage key "${key}" to "${saved.filePath}". Remember to delete this temporary file when finished.`,
},
],
details: { key, assetId: owningAssetId, ...saved },
}
}
/** Saves each file of a download_asset result into the sandbox. */
export async function presentDownloadOutput(
output: DownloadAssetOutput,
): Promise<AgentToolResult<unknown>> {
const lines: string[] = []
const files = []
for (const file of output.files) {
if (!file.key) throw new Error(`download_asset returned no storage key for ${file.assetId}`)
const saved = await saveToSandbox(
file.key,
`${file.assetId}_${sanitizeFilename(file.name) || 'file'}`,
)
lines.push(
`Downloaded "${file.name}" (ID: ${file.assetId}, ${file.kind}, ${saved.contentType}, ${formatSize(saved.size)}) to "${saved.filePath}".`,
)
files.push({ assetId: file.assetId, name: file.name, kind: file.kind, ...saved })
}
lines.push(CLEANUP_REMINDER)
return { content: [{ type: 'text', text: lines.join('\n') }], details: { files } }
}
const downloadAssetExtension: AgentToolExtension = {
description:
`Downloads up to ${MAX_DOWNLOAD_ASSETS} workspace files into the local .pi directory, for processing with local scripts or bash commands. ` +
'By default it saves the web preview version (proxy) when there is one, e.g. the transcoded video or the web image; set proxy to false for the original uploaded file. ' +
'A version stack downloads its latest version; folders are not supported. ' +
'To download a specific artifact from read_asset (e.g. a frame or page), pass its storage key as "key" instead of assetIds. ' +
'Remember to delete the downloaded files when finished.',
parameterOverrides: z.object({
assetIds: downloadAsset.input.shape.assetIds
.optional()
.describe(
`IDs of the files or version stacks to download (1 to ${MAX_DOWNLOAD_ASSETS}). Omit when passing "key".`,
),
}),
extraParameters: z.object({
key: z
.string()
.optional()
.describe(
'Storage S3 key of a specific media artifact to download instead of assetIds, e.g. a screenshot or page key from read_asset.',
),
}),
async intercept(input, extra, ctx) {
if (typeof extra.key !== 'string') return undefined
if (Array.isArray(input.assetIds) && input.assetIds.length > 0) {
throw new Error('Provide either "assetIds" or "key", not both.')
}
if (!ctx.userId) throw new Error('User ID is required for authorization.')
return downloadKey(extra.key, ctx.userId)
},
present: (output) => presentDownloadOutput(output as DownloadAssetOutput),
}
registerAgentToolExtension('download_asset', downloadAssetExtension)
@@ -0,0 +1,4 @@
// Registers agent-specific presentation for Operations. Import once before building tools.
export { createAutofillReadAssetTool, presentReadOutput } from './read-asset'
export { presentDownloadOutput } from './download-asset'
import './upload'
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,155 @@
import { z } from 'zod'
import { type AgentTool, type AgentToolResult } from '@earendil-works/pi-agent-core'
import { type ImageContent, type TextContent } from '@earendil-works/pi-ai'
import { readAsset, type AssetReadOutput } from '@shumai/operations'
import { assetReadService, toAssetReadOutput } from '@shumai/core/src/asset-read'
import { getOperation, READ_WAIT_BUDGET_MS } from '@shumai/core/src/operations'
import { s3Service } from '@shumai/core/src/s3/s3'
import { getFileMimeType } from '@shumai/core/src/utils/file-mime'
import { MAX_TEXT_BYTES, MAX_TEXT_LINES } from '@shumai/core/src/asset-read'
import {
registerAgentToolExtension,
splitAgentParams,
toToolParameters,
type AgentToolExtension,
} from '../operation-tools'
const extraParameters = z.object({
s3KeyOnly: z
.boolean()
.optional()
.describe(
'When true, returns only the storage S3 key(s) and MIME types of the asset/frames without attaching base64 image or text content to the agent context. Use this to obtain S3 keys for generate_image or generate_video references without consuming context tokens.',
),
})
/** Details kept compatible with the previous tool; `sourceKeys` drives session image storage. */
interface ReadAssetDetails {
assetId: string
name: string
mediaType: string | null
key?: string
keys: string[]
downloadUrl?: string
results: Array<{ key: string; label: string; downloadUrl?: string }>
sourceKeys: string[]
size?: number
isTruncated?: boolean
}
/** Render a read_asset / get_asset_render output as agent content (text plus image blocks). */
export async function presentReadOutput(
output: AssetReadOutput,
opts: { s3KeyOnly: boolean },
): Promise<AgentToolResult<ReadAssetDetails | { taskId?: string; status: 'pending' }>> {
if (output.status === 'pending') {
const retry = output.retryAfterSeconds ?? 5
return {
content: [
{
type: 'text',
text: `${output.summary} Call get_asset_render with taskId "${output.taskId}" in about ${retry} seconds to get the result.`,
},
],
details: { taskId: output.taskId, status: 'pending' },
}
}
const bucket = process.env.S3_BUCKET || 'shumai'
const imageBlocks: ImageContent[] = []
const imageLines: string[] = []
for (const image of output.images) {
const key = image.key ?? ''
let mimeType = image.mimeType
if (!opts.s3KeyOnly && key) {
const { buffer, contentType } = await s3Service.getObject(bucket, key)
mimeType =
contentType && contentType !== 'application/octet-stream'
? contentType
: getFileMimeType(buffer, key, image.mimeType)
imageBlocks.push({ type: 'image', data: buffer.toString('base64'), mimeType })
}
imageLines.push(`- ${image.label} (S3 Key: "${key}", MIME: ${mimeType})`)
}
const lines = [output.summary, ...output.details, ...imageLines]
if (output.text) {
lines.push(`- Source file (S3 Key: "${output.text.key ?? ''}", MIME: ${output.text.mimeType})`)
}
let text = lines.join('\n')
if (output.text && !opts.s3KeyOnly) {
text += `\n\n${output.text.content}`
if (output.text.truncated) {
text += `\n\n[Content truncated to ${MAX_TEXT_LINES} lines / ${MAX_TEXT_BYTES / 1024}KB limit. Use download_asset to process the full file.]`
}
}
const imageKeys = output.images.map((i) => i.key ?? '')
const content: Array<TextContent | ImageContent> = [{ type: 'text', text }, ...imageBlocks]
return {
content,
details: {
assetId: output.asset.id,
name: output.asset.name,
mediaType: output.asset.mediaType,
key: imageKeys[0] ?? output.text?.key,
keys: imageKeys,
downloadUrl: output.images[0]?.url ?? output.text?.url,
results: output.images.map((i) => ({ key: i.key ?? '', label: i.label, downloadUrl: i.url })),
sourceKeys: output.text?.key && imageKeys.length === 0 ? [output.text.key] : imageKeys,
...(output.text ? { size: output.text.size, isTruncated: output.text.truncated } : {}),
},
}
}
const readAssetExtension: AgentToolExtension = {
extraParameters,
// s3KeyOnly also means "don't read text content", as before.
toInput: (input, extra) => (extra.s3KeyOnly ? { ...input, includeContent: false } : input),
present: (output, extra) =>
presentReadOutput(output as AssetReadOutput, { s3KeyOnly: extra.s3KeyOnly === true }),
}
const getAssetRenderExtension: AgentToolExtension = {
present: (output) => presentReadOutput(output as AssetReadOutput, { s3KeyOnly: false }),
}
registerAgentToolExtension('read_asset', readAssetExtension)
registerAgentToolExtension('get_asset_render', getAssetRenderExtension)
/** Longer than the chat budget: autofill can't poll get_asset_render (it has no user). */
const AUTOFILL_WAIT_BUDGET_MS = 2 * READ_WAIT_BUDGET_MS.agent
/**
* `read_asset` for the autofill system agent, which runs without a user. It uses the same
* pipeline and presentation, but access is confined to the agent's team and target asset.
*/
export function createAutofillReadAssetTool(access: {
teamId?: string
targetAssetId?: string
}): AgentTool {
const op = getOperation(readAsset.name)!
return {
name: readAsset.name,
label: readAsset.title,
description: readAsset.description,
parameters: toToolParameters(op, readAssetExtension),
execute: async (_toolCallId, params) => {
const { input, extra } = splitAgentParams(op, readAssetExtension, params)
const parsed = readAsset.input.safeParse(input)
if (!parsed.success) {
throw new Error(`Invalid input for read_asset: ${z.prettifyError(parsed.error)}`)
}
const { maxWaitSeconds, ...request } = parsed.data
const budget =
maxWaitSeconds === undefined
? AUTOFILL_WAIT_BUDGET_MS
: Math.min(AUTOFILL_WAIT_BUDGET_MS, maxWaitSeconds * 1000)
const outcome = await assetReadService.read({ kind: 'autofill', ...access }, request, {
waitBudgetMs: budget,
})
const output = await toAssetReadOutput(outcome, { includeKeys: true })
return presentReadOutput(output, { s3KeyOnly: extra.s3KeyOnly === true })
},
}
}
@@ -0,0 +1,447 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { Value } from 'typebox/value'
import { validateToolArguments } from '@earendil-works/pi-ai'
import * as fs from 'fs'
import * as os from 'os'
import * as path from 'path'
import { AuditAction, type AssetInfo } from '@shumai/dtos'
import { assetService } from '@shumai/core/src/asset/asset'
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
import { metadataService } from '@shumai/core/src/metadata/metadata'
import { getOperation } from '@shumai/core/src/operations'
import { s3Service } from '@shumai/core/src/s3/s3'
import { fieldsToTypeBoxSchema } from '../index'
import { toAgentTool, type AgentToolOptions } from '../operation-tools'
import './upload'
const ctx = { userId: 'user-1', agentId: 'agent-1', teamId: 'team-1', projectId: 'proj-1' }
const bucket = process.env.S3_BUCKET || 'shumai'
function tool(name: 'create_file' | 'create_version', options: AgentToolOptions = {}) {
return toAgentTool(getOperation(name)!, ctx, options)
}
function assetInfo(overrides: Partial<AssetInfo>): AssetInfo {
return {
id: 'file-1',
name: 'test',
sizeByte: 100,
fileCount: 0,
type: 'file',
status: 'uploaded',
createdAt: '2026-01-01T00:00:00.000Z',
updatedAt: '2026-01-01T00:00:00.000Z',
projectId: 'proj-1',
...overrides,
}
}
function outputOf(result: { content: unknown[] }) {
return JSON.parse((result.content[0] as { text: string }).text) as unknown
}
const promptField = {
field: {
id: 'f1',
key: 'prompt',
scope: 'PROJECT',
readOnly: false,
description: '',
config: { name: 'Prompt', type: 'text', autofillSource: 'CREATION_CONTEXT' },
},
visible: true,
}
describe('create_file and create_version agent tools', () => {
const tempFiles: string[] = []
const tempFile = (content: string, filename: string): string => {
const filePath = path.join(os.tmpdir(), filename)
fs.writeFileSync(filePath, content)
tempFiles.push(filePath)
return filePath
}
beforeEach(() => {
vi.spyOn(authzService, 'hasPermission').mockResolvedValue(undefined)
vi.spyOn(auditLogService, 'logAction').mockResolvedValue(null)
vi.spyOn(assetService, 'getAssetContext').mockResolvedValue({
teamId: 'team-1',
projectId: 'proj-1',
})
vi.spyOn(assetService, 'getAssetMeta').mockImplementation(async (id) => ({
id,
name: id,
type: id.startsWith('folder') ? 'folder' : 'file',
parentId: 'root',
teamId: 'team-1',
projectId: 'proj-1',
}))
vi.spyOn(assetService, 'findAssetByStorageKey').mockResolvedValue(null)
vi.spyOn(assetService, 'createFile').mockResolvedValue(assetInfo({}))
vi.spyOn(assetService, 'createVersion').mockResolvedValue(assetInfo({ name: 'v2' }))
vi.spyOn(metadataService, 'listProjectFields').mockResolvedValue([promptField] as never)
vi.spyOn(s3Service, 'presign').mockResolvedValue('https://storage.example/upload')
// Read file streams to the end, as real storage would.
vi.spyOn(s3Service, 'putObject').mockImplementation(async (_bucket, _key, body) => {
if (body && typeof body === 'object' && Symbol.asyncIterator in body) {
for await (const chunk of body as AsyncIterable<unknown>) void chunk
}
})
vi.spyOn(s3Service, 'headObject').mockImplementation(async (_bucket, key) => ({
key,
size: 17,
lastModified: new Date(),
contentType: 'text/markdown',
eTag: '',
}))
})
afterEach(() => {
vi.restoreAllMocks()
for (const f of tempFiles.splice(0)) fs.rmSync(f, { force: true })
})
describe('create_file', () => {
it('uploads a local file to storage and creates the file as the agent', async () => {
const filePath = tempFile('# Hello from disk', 'agent-create-file.md')
const result = await tool('create_file').execute('call-1', {
parent: 'folder-1',
path: filePath,
} as never)
expect(authzService.hasPermission).toHaveBeenCalledWith({
user: { id: 'user-1' },
permission: Permission.Edit,
type: ResourceType.Asset,
id: 'folder-1',
})
const [putBucket, key, , size, contentType] = vi.mocked(s3Service.putObject).mock.calls[0]
expect(putBucket).toBe(bucket)
expect(key).toMatch(/^files\/.+\/agent-create-file\.md$/)
expect(size).toBe(Buffer.byteLength('# Hello from disk'))
expect(contentType).toBe('text/markdown')
expect(assetService.createFile).toHaveBeenCalledWith({
parentId: 'folder-1',
name: 'agent-create-file.md',
key,
sizeByte: 17,
contentType: 'text/markdown',
creatorId: 'user-1',
agentId: 'agent-1',
metadata: undefined,
})
expect(auditLogService.logAction).toHaveBeenCalledWith(
expect.objectContaining({
action: AuditAction.file_create,
teamId: 'team-1',
projectId: 'proj-1',
userId: 'user-1',
agentId: 'agent-1',
itemId: 'file-1',
via: 'agent',
}),
)
expect(result.details).toEqual({})
expect(outputOf(result)).toEqual({
id: 'file-1',
name: 'test',
type: 'file',
size: 100,
projectId: 'proj-1',
})
})
it('creates a text file from name and content', async () => {
await tool('create_file').execute('call-1', {
parent: 'folder-1',
name: 'notes.md',
content: '# Notes\n\nHello',
} as never)
const [, key, body, size, contentType] = vi.mocked(s3Service.putObject).mock.calls[0]
expect(key).toMatch(/^files\/.+\/notes\.md$/)
expect((body as Buffer).toString('utf-8')).toBe('# Notes\n\nHello')
expect(size).toBe(Buffer.byteLength('# Notes\n\nHello'))
expect(contentType).toBe('text/markdown')
expect(assetService.createFile).toHaveBeenCalledWith(
expect.objectContaining({ name: 'notes.md', contentType: 'text/markdown' }),
)
})
it('defaults unknown extensions to text/plain when creating from content', async () => {
await tool('create_file').execute('call-1', {
parent: 'folder-1',
name: 'script.ts',
content: 'const x = 1',
} as never)
expect(vi.mocked(s3Service.putObject).mock.calls[0][4]).toBe('text/plain')
expect(assetService.createFile).toHaveBeenCalledWith(
expect.objectContaining({ contentType: 'text/plain' }),
)
})
it('sanitizes the name', async () => {
await tool('create_file').execute('call-1', {
parent: 'folder-1',
name: 'my/notes.md',
content: 'hello',
} as never)
expect(vi.mocked(s3Service.putObject).mock.calls[0][1]).toContain('my_notes.md')
expect(assetService.createFile).toHaveBeenCalledWith(
expect.objectContaining({ name: 'my_notes.md' }),
)
})
it('forwards Creation Context metadata, including new select options', async () => {
const filePath = tempFile('# Hello', 'agent-create-file-meta.md')
await tool('create_file').execute('call-1', {
parent: 'folder-1',
path: filePath,
metadata: { prompt: { newOption: { value: 'Kling' } } },
} as never)
expect(assetService.createFile).toHaveBeenCalledWith(
expect.objectContaining({ metadata: { prompt: { newOption: { value: 'Kling' } } } }),
)
})
it('treats null metadata as omitted', async () => {
const filePath = tempFile('# Hello', 'agent-create-file-null.md')
await tool('create_file').execute('call-1', {
parent: 'folder-1',
path: filePath,
metadata: null,
} as never)
expect(vi.mocked(assetService.createFile).mock.calls[0][0].metadata).toBeUndefined()
})
it('rejects metadata keys that are not Creation Context fields before uploading', async () => {
const filePath = tempFile('# Hello', 'agent-create-file-bad-meta.md')
await expect(
tool('create_file').execute('call-1', {
parent: 'folder-1',
path: filePath,
metadata: { status: 'approved' },
} as never),
).rejects.toThrow(/not allowed: status/)
expect(s3Service.putObject).not.toHaveBeenCalled()
expect(assetService.createFile).not.toHaveBeenCalled()
})
it('rejects a call with neither or both of "path" and "content"', async () => {
await expect(
tool('create_file').execute('call-1', { parent: 'folder-1' } as never),
).rejects.toThrow('Provide exactly one of "path" (a local file) or "content" (with "name").')
await expect(
tool('create_file').execute('call-1', {
parent: 'folder-1',
path: '/some/file.md',
name: 'notes.md',
content: 'hello',
} as never),
).rejects.toThrow('Provide exactly one of')
expect(s3Service.putObject).not.toHaveBeenCalled()
})
it('requires a name with "content"', async () => {
await expect(
tool('create_file').execute('call-1', { parent: 'folder-1', content: 'x' } as never),
).rejects.toThrow('"name" is required')
})
it('fails when the local file does not exist, without touching storage', async () => {
await expect(
tool('create_file').execute('call-1', {
parent: 'folder-1',
path: '/nonexistent/file.md',
} as never),
).rejects.toThrow('Local file not found at path: /nonexistent/file.md')
expect(s3Service.putObject).not.toHaveBeenCalled()
expect(assetService.createFile).not.toHaveBeenCalled()
})
it('does not write to storage when the user lacks Edit permission', async () => {
vi.mocked(authzService.hasPermission).mockRejectedValue(
new Error('User is not a member of the team'),
)
const filePath = tempFile('# Not allowed', 'agent-create-file-denied.md')
await expect(
tool('create_file').execute('call-1', { parent: 'folder-1', path: filePath } as never),
).rejects.toThrow('User is not a member of the team')
await expect(
tool('create_file').execute('call-1', {
parent: 'folder-1',
name: 'notes.md',
content: 'x',
} as never),
).rejects.toThrow('User is not a member of the team')
expect(s3Service.putObject).not.toHaveBeenCalled()
expect(s3Service.presign).not.toHaveBeenCalled()
expect(assetService.createFile).not.toHaveBeenCalled()
})
it('passes harness validation with only one source set', async () => {
const t = tool('create_file')
const validated = validateToolArguments(
{ name: t.name, description: '', parameters: t.parameters } as Parameters<
typeof validateToolArguments
>[0],
{
type: 'toolCall',
id: 'call-1',
name: t.name,
arguments: { parent: 'folder-1', name: 'random.txt', content: 'hello' },
} as Parameters<typeof validateToolArguments>[1],
)
await t.execute('call-1', validated as never)
expect(assetService.createFile).toHaveBeenCalledWith(
expect.objectContaining({ name: 'random.txt' }),
)
})
it('shows the agent its own parameters', () => {
const properties = Object.keys(
(tool('create_file').parameters as unknown as { properties: object }).properties,
)
expect(properties.sort()).toEqual(['content', 'name', 'parent', 'path'])
})
})
describe('create_version', () => {
it('uploads a local file and creates a version as the agent', async () => {
const filePath = tempFile('# Hello from disk', 'agent-create-version.md')
const result = await tool('create_version').execute('call-1', {
parent: 'file-1',
path: filePath,
} as never)
const key = vi.mocked(s3Service.putObject).mock.calls[0][1]
expect(assetService.createVersion).toHaveBeenCalledWith({
parentId: 'file-1',
name: 'agent-create-version.md',
key,
sizeByte: 17,
contentType: 'text/markdown',
creatorId: 'user-1',
agentId: 'agent-1',
metadata: undefined,
})
expect(outputOf(result)).toMatchObject({ id: 'file-1', name: 'v2' })
expect(auditLogService.logAction).toHaveBeenCalledWith(
expect.objectContaining({ action: AuditAction.file_create, agentId: 'agent-1' }),
)
})
it('forwards Creation Context metadata', async () => {
const filePath = tempFile('# Hello', 'agent-create-version-meta.md')
await tool('create_version').execute('call-1', {
parent: 'file-1',
path: filePath,
metadata: { prompt: 'Generated using gemini' },
} as never)
expect(assetService.createVersion).toHaveBeenCalledWith(
expect.objectContaining({ metadata: { prompt: 'Generated using gemini' } }),
)
})
it('does not upload when the user lacks Edit permission', async () => {
vi.mocked(authzService.hasPermission).mockRejectedValueOnce(
new Error('User is not a member of the team'),
)
const filePath = tempFile('# Not allowed', 'agent-create-version-denied.md')
await expect(
tool('create_version').execute('call-1', { parent: 'file-1', path: filePath } as never),
).rejects.toThrow('User is not a member of the team')
expect(s3Service.putObject).not.toHaveBeenCalled()
expect(assetService.createVersion).not.toHaveBeenCalled()
})
it('fails when the local file does not exist', async () => {
await expect(
tool('create_version').execute('call-1', {
parent: 'file-1',
path: '/nonexistent/file.md',
} as never),
).rejects.toThrow('Local file not found at path: /nonexistent/file.md')
expect(s3Service.putObject).not.toHaveBeenCalled()
})
it('shows the agent its own parameters', () => {
const properties = Object.keys(
(tool('create_version').parameters as unknown as { properties: object }).properties,
)
expect(properties.sort()).toEqual(['parent', 'path'])
})
})
describe('Creation Context metadata parameter', () => {
const creationMetadataSchema = fieldsToTypeBoxSchema([
{ id: 'prompt', config: { name: 'Prompt', type: 'text' } },
{
id: 'source',
config: {
name: 'Source',
type: 'select',
select: { options: [{ id: 'gemini', displayName: 'Gemini', color: '#ffffff' }] },
},
},
])
it.each(['create_file', 'create_version'] as const)(
'%s exposes the project schema as a strict, nullable metadata parameter',
(name) => {
const parameters = tool(name, { creationMetadataSchema }).parameters as unknown as {
properties: { metadata: { anyOf: [{ required: string[] }, { type: string }] } }
}
const meta = parameters.properties.metadata
expect(meta.anyOf[0].required).toEqual(['prompt', 'source'])
expect(meta.anyOf[1].type).toBe('null')
expect(Value.Check(meta, { prompt: 'hello', source: 'gemini' })).toBe(true)
expect(Value.Check(meta, { prompt: null, source: null })).toBe(true)
expect(Value.Check(meta, null)).toBe(true)
expect(Value.Check(meta, { prompt: 'hello' })).toBe(false)
expect(Value.Check(meta, { prompt: 'x', source: 'gemini', other: 1 })).toBe(false)
expect(Value.Check(meta, { prompt: 'x', source: 'not-an-option' })).toBe(false)
},
)
it('keeps null values inside metadata through harness validation', () => {
const t = tool('create_file', {
creationMetadataSchema: fieldsToTypeBoxSchema([
{ id: 'prompt', config: { name: 'Prompt', type: 'text' } },
]),
})
const validated = validateToolArguments(
{ name: t.name, description: '', parameters: t.parameters } as Parameters<
typeof validateToolArguments
>[0],
{
type: 'toolCall',
id: 'call-1',
name: t.name,
arguments: { parent: 'folder-1', name: 'a.md', content: 'x', metadata: { prompt: null } },
} as Parameters<typeof validateToolArguments>[1],
) as { metadata?: unknown }
expect(validated.metadata).toEqual({ prompt: null })
})
})
})
@@ -0,0 +1,158 @@
import * as fs from 'fs'
import * as path from 'path'
import { z } from 'zod'
import { Type } from 'typebox'
import type { AgentToolResult } from '@earendil-works/pi-agent-core'
import { createFile, type StartedUploadOutput } from '@shumai/operations'
import { storageBucket } from '@shumai/core/src/asset-read'
import { completeUploadOp, runOperation } from '@shumai/core/src/operations'
import { s3Service } from '@shumai/core/src/s3/s3'
import { getFileMimeType, readFileMimeType } from '@shumai/core/src/utils/file-mime'
import {
registerAgentToolExtension,
type AgentOperationContext,
type AgentToolExtension,
type AgentToolOptions,
type ToolParametersSchema,
} from '../operation-tools'
const METADATA_HINT =
'The optional "metadata" parameter accepts only the CREATION_CONTEXT fields declared in its schema; never invent field keys, and use null for fields you do not know.'
/**
* The agent gets the conversation project's Creation Context fields as a strict schema
* (so it knows exactly what to fill in) instead of the open record MCP clients see. Without
* such fields the parameter is left out.
*/
function setCreationMetadata(schema: ToolParametersSchema, options: AgentToolOptions): void {
if (options.creationMetadataSchema) {
schema.properties.metadata = Type.Union([options.creationMetadataSchema, Type.Null()])
} else {
delete schema.properties.metadata
}
}
function resolveLocalFile(localPath: string): string {
const absolutePath = path.resolve(process.cwd(), localPath)
if (!fs.existsSync(absolutePath) || !fs.statSync(absolutePath).isFile()) {
throw new Error(`Local file not found at path: ${localPath}`)
}
return absolutePath
}
/**
* Writes the file straight to the upload's storage key (the agent runs next to storage, so
* it doesn't need the upload URL), then completes the upload as the agent.
*/
async function uploadAndComplete(
raw: unknown,
extra: Record<string, unknown>,
ctx: AgentOperationContext,
): Promise<AgentToolResult<unknown>> {
const started = raw as StartedUploadOutput
if (!started.key) throw new Error('The upload did not return a storage key')
if (typeof extra.path === 'string') {
const absolutePath = resolveLocalFile(extra.path)
await s3Service.putObject(
storageBucket(),
started.key,
fs.createReadStream(absolutePath),
fs.statSync(absolutePath).size,
readFileMimeType(absolutePath),
)
} else {
const content = Buffer.from(typeof extra.content === 'string' ? extra.content : '', 'utf-8')
// The key ends with the file name, which gives the same type as the upload's.
const contentType = getFileMimeType(null, started.key, 'text/plain')
await s3Service.putObject(
storageBucket(),
started.key,
content,
content.byteLength,
contentType,
)
}
const asset = await runOperation(
completeUploadOp,
{ ...ctx, via: 'agent' },
{ uploadId: started.uploadId },
)
return { content: [{ type: 'text', text: JSON.stringify(asset, null, 2) }], details: {} }
}
const createFileExtension: AgentToolExtension = {
description:
'Create a new file in a folder. Choose exactly ONE source: ' +
'(1) "path" to upload a local file (e.g. one you made in .pi), OR ' +
'(2) "name" and "content" to create a text file with that content. ' +
METADATA_HINT,
parameterOverrides: z.object({
name: createFile.input.shape.name
.optional()
.describe(
'File name including its extension (e.g. "notes.md"). Required with "content"; defaults to the local file\'s name with "path".',
),
}),
extraParameters: z.object({
path: z
.string()
.min(1)
.optional()
.describe('Absolute or relative path of a local file to upload. Omit when using "content".'),
content: z
.string()
.optional()
.describe('Full text content of a new text file. Requires "name"; omit when using "path".'),
}),
hiddenParameters: ['contentType'],
adjustParameters: setCreationMetadata,
toInput(input, extra) {
const hasPath = typeof extra.path === 'string'
const hasContent = typeof extra.content === 'string'
if (hasPath === hasContent) {
throw new Error('Provide exactly one of "path" (a local file) or "content" (with "name").')
}
if (hasPath) {
const absolutePath = resolveLocalFile(extra.path as string)
return {
...input,
name: input.name ?? path.basename(absolutePath),
contentType: readFileMimeType(absolutePath),
}
}
if (typeof input.name !== 'string' || !input.name.trim()) {
throw new Error('"name" is required when creating a file from "content".')
}
return { ...input, contentType: getFileMimeType(null, input.name, 'text/plain') }
},
present: uploadAndComplete,
}
const createVersionExtension: AgentToolExtension = {
description:
'Create a new version of an existing file (or version stack) from a local file path. ' +
'The new version becomes the current one. ' +
METADATA_HINT,
extraParameters: z.object({
path: z
.string()
.min(1)
.describe('Absolute or relative path of the local file to upload as the new version.'),
}),
hiddenParameters: ['name', 'contentType'],
adjustParameters: setCreationMetadata,
toInput(input, extra) {
const absolutePath = resolveLocalFile(extra.path as string)
return {
...input,
name: path.basename(absolutePath),
contentType: readFileMimeType(absolutePath),
}
},
present: uploadAndComplete,
}
registerAgentToolExtension('create_file', createFileExtension)
registerAgentToolExtension('create_version', createVersionExtension)
+429
View File
@@ -0,0 +1,429 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { Value } from 'typebox/value'
import { validateToolArguments } from '@earendil-works/pi-ai'
import { type AgentTool } from '@earendil-works/pi-agent-core'
import { AuditAction, type AssetInfo, type ProjectInfo } from '@shumai/dtos'
import { assetService } from '@shumai/core/src/asset/asset'
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
import { projectService } from '@shumai/core/src/project/project'
import { buildOperationTools } from './operation-tools'
const ctx = { userId: 'user-1', agentId: 'agent-1', teamId: 'team-1', projectId: 'proj-1' }
function assetInfo(overrides: Partial<AssetInfo>): AssetInfo {
return {
id: 'asset-1',
name: 'Asset',
sizeByte: 0,
fileCount: 0,
type: 'file',
status: 'uploaded',
createdAt: '2026-01-01T00:00:00.000Z',
updatedAt: '2026-01-01T00:00:00.000Z',
projectId: 'proj-1',
...overrides,
}
}
function getTool(name: string): AgentTool {
const tool = buildOperationTools(ctx).find((t) => t.name === name)
if (!tool) throw new Error(`tool ${name} not built`)
return tool
}
async function run(name: string, params: Record<string, unknown>) {
const result = await getTool(name).execute('call-1', params as never)
return { result, output: JSON.parse((result.content[0] as { text: string }).text) as unknown }
}
function editCheck(id: string) {
return {
user: { id: 'user-1' },
permission: Permission.Edit,
type: ResourceType.Asset,
id,
}
}
describe('operation-backed agent tools', () => {
beforeEach(() => {
vi.spyOn(authzService, 'hasPermission').mockResolvedValue(undefined)
vi.spyOn(auditLogService, 'logAction').mockResolvedValue(null)
vi.spyOn(assetService, 'getAssetContext').mockResolvedValue({
teamId: 'team-1',
projectId: 'proj-1',
})
})
afterEach(() => {
vi.restoreAllMocks()
})
describe('tool definitions', () => {
it('keeps the existing tool names and adds the newer Operations', () => {
expect(
buildOperationTools(ctx)
.map((t) => t.name)
.sort(),
).toEqual([
'copy_assets',
'create_comment',
'create_file',
'create_folder',
'create_version',
'create_version_stack',
'delete_asset',
'download_asset',
'get_asset_render',
'get_folder_instructions',
'list_assets',
'list_comments',
'list_metadata_fields',
'list_projects',
'list_versions',
'move_assets',
'read_asset',
'remove_version',
'rename_asset',
'resolve_comment',
'search_assets',
'update_asset_metadata',
])
})
it('does not give the agent complete_upload: its create tools finish uploads themselves', () => {
expect(buildOperationTools(ctx).map((t) => t.name)).not.toContain('complete_upload')
})
it('keeps the existing parameter names', () => {
const params = (name: string) =>
Object.keys((getTool(name).parameters as unknown as { properties: object }).properties)
expect(params('create_folder')).toEqual(['parent', 'name'])
expect(params('rename_asset')).toEqual(['assetId', 'name'])
expect(params('move_assets')).toEqual(['assetIds', 'newParentId'])
expect(params('delete_asset')).toEqual(['assetId'])
expect(params('list_assets')).toEqual(['parent', 'type', 'first', 'after'])
})
it('exposes JSON Schema parameters the harness can validate', () => {
const tool = getTool('move_assets')
expect(tool.parameters).not.toHaveProperty('$schema')
expect(Value.Check(tool.parameters, { assetIds: ['a'], newParentId: 'b' })).toBe(true)
expect(Value.Check(tool.parameters, { assetIds: 'a', newParentId: 'b' })).toBe(false)
const description = (
tool.parameters as unknown as { properties: { assetIds: { description: string } } }
).properties.assetIds.description
expect(description).toContain('same parent folder')
})
it('passes harness validation with null optional parameters', async () => {
vi.spyOn(assetService, 'listChildren').mockResolvedValue({
data: [],
pageInfo: { total: 0 },
})
const tool = getTool('list_assets')
const validated = validateToolArguments(
{ name: tool.name, description: '', parameters: tool.parameters } as Parameters<
typeof validateToolArguments
>[0],
{
type: 'toolCall',
id: 'call-1',
name: tool.name,
arguments: { parent: 'folder-1' },
} as Parameters<typeof validateToolArguments>[1],
)
await expect(tool.execute('call-1', validated as never)).resolves.toBeDefined()
})
})
describe('list_assets', () => {
beforeEach(() => {
vi.spyOn(assetService, 'listChildren').mockResolvedValue({
data: [
assetInfo({ id: '01M2FILE2', name: 'file2.txt', sizeByte: 200 }),
assetInfo({ id: '01M1FILE1', name: 'file1.txt', sizeByte: 100 }),
],
pageInfo: { cursor: 'next-cursor', total: 5 },
})
})
it('checks read permission and lists all types with the default page size', async () => {
const { result, output } = await run('list_assets', { parent: 'folder-1' })
expect(authzService.hasPermission).toHaveBeenCalledWith({
user: { id: 'user-1' },
permission: Permission.Read,
type: ResourceType.Asset,
id: 'folder-1',
})
expect(assetService.listChildren).toHaveBeenCalledWith({
assetId: 'folder-1',
assetType: 'all',
first: 20,
after: undefined,
})
expect(result.details).toEqual({})
expect(output).toEqual({
data: [
{ id: '01M2FILE2', name: 'file2.txt', type: 'file', size: 200, projectId: 'proj-1' },
{ id: '01M1FILE1', name: 'file1.txt', type: 'file', size: 100, projectId: 'proj-1' },
],
pageInfo: { hasNextPage: true, endCursor: 'next-cursor' },
total: 5,
})
})
it('passes cursor pagination and the type filter through', async () => {
await run('list_assets', { parent: 'folder-1', first: 10, after: 'cur', type: 'folder' })
expect(assetService.listChildren).toHaveBeenCalledWith({
assetId: 'folder-1',
assetType: 'folder',
first: 10,
after: 'cur',
})
})
it('treats null optional parameters as omitted', async () => {
await run('list_assets', { parent: 'folder-1', type: null, first: null, after: null })
expect(assetService.listChildren).toHaveBeenCalledWith({
assetId: 'folder-1',
assetType: 'all',
first: 20,
after: undefined,
})
})
it('rejects a null required parameter', async () => {
await expect(run('list_assets', { parent: null })).rejects.toMatchObject({ status: 400 })
expect(assetService.listChildren).not.toHaveBeenCalled()
})
})
describe('create_folder', () => {
beforeEach(() => {
vi.spyOn(assetService, 'createAsset').mockResolvedValue(
assetInfo({ id: 'folder-1', name: 'New Folder', type: 'folder' }),
)
})
it('checks edit permission and creates a folder attributed to the user and agent', async () => {
const { result, output } = await run('create_folder', {
parent: 'root-folder',
name: 'New Folder',
})
expect(authzService.hasPermission).toHaveBeenCalledWith(editCheck('root-folder'))
expect(assetService.createAsset).toHaveBeenCalledWith({
name: 'New Folder',
parentId: 'root-folder',
type: 'folder',
creatorId: 'user-1',
agentId: 'agent-1',
})
expect(result.details).toEqual({})
expect(output).toEqual({
id: 'folder-1',
name: 'New Folder',
type: 'folder',
size: 0,
projectId: 'proj-1',
})
})
it('logs folder_create with the agent and via agent', async () => {
await run('create_folder', { parent: 'root-folder', name: 'New Folder' })
expect(auditLogService.logAction).toHaveBeenCalledWith({
action: AuditAction.folder_create,
teamId: 'team-1',
userId: 'user-1',
agentId: 'agent-1',
projectId: 'proj-1',
itemId: 'folder-1',
via: 'agent',
})
})
})
describe('rename_asset', () => {
it('checks edit permission and renames', async () => {
vi.spyOn(assetService, 'updateAssetName').mockResolvedValue(
assetInfo({ id: 'asset-1', name: 'Renamed Asset', sizeByte: 1024 }),
)
const { output } = await run('rename_asset', { assetId: 'asset-1', name: 'Renamed Asset' })
expect(authzService.hasPermission).toHaveBeenCalledWith(editCheck('asset-1'))
expect(assetService.updateAssetName).toHaveBeenCalledWith({
id: 'asset-1',
name: 'Renamed Asset',
})
expect(output).toEqual({
id: 'asset-1',
name: 'Renamed Asset',
type: 'file',
size: 1024,
projectId: 'proj-1',
})
expect(auditLogService.logAction).toHaveBeenCalledWith(
expect.objectContaining({ action: AuditAction.file_update, itemId: 'asset-1' }),
)
})
it('logs folder_update when renaming a folder', async () => {
vi.spyOn(assetService, 'updateAssetName').mockResolvedValue(
assetInfo({ id: 'folder-1', name: 'Renamed Folder', type: 'folder' }),
)
await run('rename_asset', { assetId: 'folder-1', name: 'Renamed Folder' })
expect(auditLogService.logAction).toHaveBeenCalledWith({
action: AuditAction.folder_update,
teamId: 'team-1',
userId: 'user-1',
agentId: 'agent-1',
projectId: 'proj-1',
itemId: 'folder-1',
via: 'agent',
})
})
it('fails without renaming when the permission check rejects', async () => {
vi.mocked(authzService.hasPermission).mockRejectedValueOnce(new Error('Permission denied'))
const update = vi.spyOn(assetService, 'updateAssetName')
await expect(run('rename_asset', { assetId: 'asset-1', name: 'New' })).rejects.toThrow(
'Permission denied',
)
expect(update).not.toHaveBeenCalled()
})
})
describe('move_assets', () => {
beforeEach(() => {
vi.spyOn(assetService, 'reparentAssets').mockResolvedValue(undefined)
})
it('checks permissions on the destination and every asset, then reparents', async () => {
const { output } = await run('move_assets', {
assetIds: ['asset-1', 'asset-2'],
newParentId: 'folder-dest',
})
expect(vi.mocked(authzService.hasPermission).mock.calls.map(([req]) => req)).toEqual([
editCheck('folder-dest'),
editCheck('asset-1'),
editCheck('asset-2'),
])
expect(assetService.reparentAssets).toHaveBeenCalledWith({
assetIds: ['asset-1', 'asset-2'],
newParentId: 'folder-dest',
creatorId: 'user-1',
})
expect(output).toEqual({ movedAssetIds: ['asset-1', 'asset-2'], newParentId: 'folder-dest' })
})
it('logs asset_reparent for each asset', async () => {
await run('move_assets', { assetIds: ['asset-1', 'asset-2'], newParentId: 'folder-dest' })
expect(assetService.getAssetContext).toHaveBeenCalledWith('folder-dest')
expect(auditLogService.logAction).toHaveBeenCalledTimes(2)
for (const itemId of ['asset-1', 'asset-2']) {
expect(auditLogService.logAction).toHaveBeenCalledWith({
action: AuditAction.asset_reparent,
teamId: 'team-1',
userId: 'user-1',
agentId: 'agent-1',
projectId: 'proj-1',
itemId,
via: 'agent',
})
}
})
it('fails without moving when the destination permission check rejects', async () => {
vi.mocked(authzService.hasPermission).mockRejectedValueOnce(
new Error('Access denied to destination'),
)
await expect(
run('move_assets', { assetIds: ['asset-1'], newParentId: 'folder-dest' }),
).rejects.toThrow('Access denied to destination')
expect(assetService.reparentAssets).not.toHaveBeenCalled()
})
})
describe('delete_asset', () => {
beforeEach(() => {
vi.spyOn(assetService, 'deleteAssets').mockResolvedValue(undefined)
})
it.each([
['file', AuditAction.file_delete],
['folder', AuditAction.folder_delete],
] as const)('deletes a %s and logs %s', async (type, action) => {
vi.spyOn(assetService, 'getAssetMeta').mockResolvedValue({
id: 'asset-1',
name: 'x',
type,
parentId: null,
teamId: 'team-1',
projectId: 'proj-1',
})
const { output } = await run('delete_asset', { assetId: 'asset-1' })
expect(authzService.hasPermission).toHaveBeenCalledWith(editCheck('asset-1'))
expect(assetService.deleteAssets).toHaveBeenCalledWith(['asset-1'])
expect(output).toEqual({ deletedAssetId: 'asset-1' })
expect(auditLogService.logAction).toHaveBeenCalledWith({
action,
teamId: 'team-1',
userId: 'user-1',
agentId: 'agent-1',
projectId: 'proj-1',
itemId: 'asset-1',
via: 'agent',
})
})
it('fails without deleting when the asset is not found', async () => {
vi.spyOn(assetService, 'getAssetMeta').mockRejectedValue(new Error('Asset not found'))
await expect(run('delete_asset', { assetId: 'missing' })).rejects.toThrow('Asset not found')
expect(assetService.deleteAssets).not.toHaveBeenCalled()
})
it('fails without deleting when the permission check rejects', async () => {
vi.mocked(authzService.hasPermission).mockRejectedValueOnce(new Error('Permission denied'))
await expect(run('delete_asset', { assetId: 'asset-1' })).rejects.toThrow('Permission denied')
expect(assetService.deleteAssets).not.toHaveBeenCalled()
})
})
describe('list_projects', () => {
it("lists the user's projects", async () => {
const project: ProjectInfo = {
id: 'proj-1',
name: 'Project',
teamId: 'team-1',
rootFolder: 'root-1',
enableNotification: true,
updatedAt: '2026-01-01T00:00:00.000Z',
}
vi.spyOn(projectService, 'getUserProjects').mockResolvedValue([project])
const { output } = await run('list_projects', {})
expect(projectService.getUserProjects).toHaveBeenCalledWith('user-1', 200)
expect(output).toEqual({
data: [{ id: 'proj-1', name: 'Project', teamId: 'team-1', rootFolderId: 'root-1' }],
})
})
})
})
+165
View File
@@ -0,0 +1,165 @@
import { z } from 'zod'
import type { TSchema } from 'typebox'
import { Compile } from 'typebox/compile'
import { type AgentTool, type AgentToolResult } from '@earendil-works/pi-agent-core'
import { dropNullOptionals } from '@shumai/operations'
import {
getOperationsForSurface,
runOperation,
type Operation,
type OperationContext,
} from '@shumai/core/src/operations'
/** Context for agent-invoked Operations; `via` is always `agent`. */
export type AgentOperationContext = Omit<OperationContext, 'via'>
/** Per-session settings for building tools, e.g. schemas that depend on the project. */
export interface AgentToolOptions {
/**
* Schema of the conversation project's Creation Context fields, for the `metadata`
* parameter of tools that create files. Undefined when the project has none.
*/
creationMetadataSchema?: TSchema
}
/** The JSON Schema of a tool's parameters (an object schema). */
export interface ToolParametersSchema {
type?: string
properties: Record<string, unknown>
required?: string[]
[key: string]: unknown
}
/**
* Agent-specific presentation for an Operation. By default a tool returns the Operation output
* as JSON text; an extension can add agent-only parameters, map them into the Operation input,
* and render the output (e.g. as image blocks).
*/
export interface AgentToolExtension {
/** Replaces the Operation description for the agent (e.g. where files end up). */
description?: string
/** Extra parameters only the agent sees; they are removed before the Operation runs. */
extraParameters?: z.ZodObject
/**
* Agent-facing versions of Operation input fields, e.g. a required field made optional
* because an extra parameter can be used instead. The Operation still validates its own
* input when it runs.
*/
parameterOverrides?: z.ZodObject
/** Operation input fields the agent doesn't see because `toInput` fills them in. */
hiddenParameters?: readonly string[]
/** Adjust the parameters' JSON Schema for this session (e.g. a project-specific field). */
adjustParameters?(schema: ToolParametersSchema, options: AgentToolOptions): void
/** Adjust the Operation input using the extra parameters. */
toInput?(input: Record<string, unknown>, extra: Record<string, unknown>): Record<string, unknown>
/**
* Handle an agent-only mode without running the Operation (e.g. a storage key instead of
* an asset). Return undefined to run the Operation.
*/
intercept?(
input: Record<string, unknown>,
extra: Record<string, unknown>,
ctx: AgentOperationContext,
): Promise<AgentToolResult<unknown> | undefined>
present(
output: unknown,
extra: Record<string, unknown>,
ctx: AgentOperationContext,
): Promise<AgentToolResult<unknown>>
}
const extensions = new Map<string, AgentToolExtension>()
/** Register agent presentation for an Operation (see `./operation-extensions`). */
export function registerAgentToolExtension(name: string, extension: AgentToolExtension): void {
extensions.set(name, extension)
}
function toolInputSchema(op: Operation, extension?: AgentToolExtension): z.ZodObject {
let schema = op.definition.input
if (extension?.parameterOverrides) schema = schema.extend(extension.parameterOverrides.shape)
if (extension?.extraParameters) schema = schema.extend(extension.extraParameters.shape)
return schema
}
/**
* Convert an Operation's Zod input schema into the JSON Schema the agent harness expects.
* TypeBox schemas are plain JSON Schema at runtime, so the converted schema is used as-is.
* Throws when the schema cannot be compiled, so a bad definition fails loudly in tests.
*/
export function toToolParameters(
op: Operation,
extension?: AgentToolExtension,
options: AgentToolOptions = {},
): TSchema {
const schema = z.toJSONSchema(toolInputSchema(op, extension), {
io: 'input',
}) as unknown as ToolParametersSchema
// `$schema` is not understood by the harness validator or every model provider.
delete schema.$schema
for (const name of extension?.hiddenParameters ?? []) {
delete schema.properties[name]
schema.required = schema.required?.filter((field) => field !== name)
}
extension?.adjustParameters?.(schema, options)
Compile(schema)
return schema as unknown as TSchema
}
/** Split agent-only parameters from the Operation input. */
export function splitAgentParams(
op: Operation,
extension: AgentToolExtension | undefined,
params: unknown,
): { input: unknown; extra: Record<string, unknown> } {
const cleaned = dropNullOptionals(toolInputSchema(op, extension), params)
if (!extension?.extraParameters || !cleaned || typeof cleaned !== 'object') {
return { input: cleaned, extra: {} }
}
const extraKeys = new Set(Object.keys(extension.extraParameters.shape))
const input: Record<string, unknown> = {}
const extra: Record<string, unknown> = {}
for (const [key, value] of Object.entries(cleaned)) {
;(extraKeys.has(key) ? extra : input)[key] = value
}
return { input: extension.toInput ? extension.toInput(input, extra) : input, extra }
}
/** Expose an Operation as a native agent tool that runs through `runOperation`. */
export function toAgentTool(
op: Operation,
ctx: AgentOperationContext,
options: AgentToolOptions = {},
): AgentTool {
const { definition } = op
const extension = extensions.get(definition.name)
return {
name: definition.name,
label: definition.title,
description: extension?.description ?? definition.description,
parameters: toToolParameters(op, extension, options),
execute: async (_toolCallId, params) => {
const { input, extra } = splitAgentParams(op, extension, params)
if (extension?.intercept) {
const handled = await extension.intercept(input as Record<string, unknown>, extra, ctx)
if (handled) return handled
}
const output = await runOperation(op, { ...ctx, via: 'agent' }, input)
if (extension) {
return extension.present(output, extra, ctx)
}
return {
content: [{ type: 'text', text: JSON.stringify(output, null, 2) }],
details: {},
}
},
}
}
/** Agent tools for every Operation with the `agent` surface. */
export function buildOperationTools(
ctx: AgentOperationContext,
options: AgentToolOptions = {},
): AgentTool[] {
return getOperationsForSurface('agent').map((op) => toAgentTool(op, ctx, options))
}
@@ -1,117 +0,0 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
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 { assetService } from '@shumai/core/src/asset/asset'
import { authzService } from '@shumai/core/src/authz/authz'
vi.mock('@shumai/core/src/s3/s3', () => ({
s3Service: {
uploadFileToKey: vi.fn(),
putObject: vi.fn(),
},
}))
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 }),
},
}))
/**
* Reproduce: pi-ai <= 0.82.1 runs its lenient coercion on typebox v1 schemas and
* converts `null` in a `[string, null]` union into `""` (see
* coerceWithUnionSchema in @earendil-works/pi-ai/dist/utils/validation.js).
*
* When the agent calls create_file with `path: null, data: {...}`, the harness
* validates first: the `null` path becomes `""`, so the tool's
* assertExactlyOneSource believes BOTH path and data were provided and throws
* "Provide exactly one of ..." even though the call is valid.
*
* Fixed upstream in pi-ai 0.84.0 (#7328): values that already match a union arm
* are preserved before coercion. This test should pass once @earendil-works/pi-ai
* is upgraded to >= 0.84.0.
*/
describe('reproduce null coercion in harness tool validation', () => {
beforeEach(() => {
vi.clearAllMocks()
})
it('keeps path: null when data is provided (no false "exactly one" error)', async () => {
const tool = createCreateFileTool('user-1')
const validated = validateToolArguments(
{
name: 'create_file',
description: '',
parameters: tool.parameters,
} as Parameters<typeof validateToolArguments>[0],
{
type: 'toolCall',
id: 'call-1',
name: 'create_file',
arguments: {
parent: '01KYKNP52YERGJ6Q4GTPF5FRQF',
path: null,
data: { name: 'random_text.txt', content: 'hello' },
},
} as Parameters<typeof validateToolArguments>[1],
) as { path?: unknown; data?: unknown }
// The `null` path must survive validation untouched; coercion to "" makes
// the tool think both path and data were provided.
expect(validated.path).toBeNull()
expect(validated.data).toEqual({ name: 'random_text.txt', content: 'hello' })
// execute must accept the valid call (data-only) without throwing
const result = await tool.execute('call-1', validated as never)
expect(result.details).toEqual({})
expect(JSON.parse((result.content[0] as { text: string }).text)).toEqual({
id: 'file-1',
name: 'test',
type: 'file',
size: 100,
})
expect(s3Service.putObject).toHaveBeenCalledTimes(1)
expect(authzService.hasPermission).toHaveBeenCalledTimes(1)
expect(assetService.createFile).toHaveBeenCalledTimes(1)
})
it('keeps null metadata values (the "unknown" sentinel) through validation', () => {
const tool = createCreateFileTool(
'user-1',
fieldsToTypeBoxSchema([{ id: 'prompt', config: { name: 'Prompt', type: 'text' } }]),
)
const validated = validateToolArguments(
{
name: 'create_file',
description: '',
parameters: tool.parameters,
} as Parameters<typeof validateToolArguments>[0],
{
type: 'toolCall',
id: 'call-1',
name: 'create_file',
arguments: {
parent: 'folder-1',
path: null,
data: { name: 'a.md', content: 'x' },
metadata: { prompt: null },
},
} as Parameters<typeof validateToolArguments>[1],
) as { metadata?: Record<string, unknown> }
expect(validated.metadata).toEqual({ prompt: null })
})
})
@@ -1,372 +0,0 @@
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 { assetService } from '@shumai/core/src/asset/asset'
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
import { authzService } from '@shumai/core/src/authz/authz'
import { AuditAction } from '@shumai/dtos'
import { Value } from 'typebox/value'
import * as fs from 'fs'
import * as os from 'os'
import * as path from 'path'
vi.mock('@shumai/core/src/s3/s3', () => ({
s3Service: {
uploadFileToKey: vi.fn(),
putObject: vi.fn(),
},
}))
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 }),
},
}))
vi.mock('@shumai/core/src/auditLog/auditLog', () => ({
auditLogService: {
logAction: vi.fn().mockResolvedValue(undefined),
},
}))
describe('createCreateFileTool', () => {
const createdFiles: string[] = []
beforeEach(() => {
vi.clearAllMocks()
})
afterEach(() => {
for (const f of createdFiles) {
if (fs.existsSync(f)) {
fs.unlinkSync(f)
}
}
createdFiles.length = 0
})
const createTempFile = (content: string | Buffer, filename: string): string => {
const filePath = path.join(os.tmpdir(), filename)
fs.writeFileSync(filePath, content)
createdFiles.push(filePath)
return filePath
}
it('should upload a local file when "path" is provided', async () => {
const filePath = createTempFile('# Hello from disk', 'create-file-test.md')
const tool = createCreateFileTool('user-1')
const result = await tool.execute('call-1', { parent: 'folder-1', path: filePath, data: null })
expect(s3Service.uploadFileToKey).toHaveBeenCalledTimes(1)
expect(s3Service.putObject).not.toHaveBeenCalled()
const uploadArgs = vi.mocked(s3Service.uploadFileToKey).mock.calls[0]
const s3Key = uploadArgs[1]
expect(s3Key).toMatch(/^files\/.+\.md$/)
expect(uploadArgs[2]).toBe('text/markdown')
expect(authzService.hasPermission).toHaveBeenCalledWith({
user: { id: 'user-1' },
permission: 'edit',
type: 'asset',
id: 'folder-1',
})
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({})
expect(JSON.parse((result.content[0] as { text: string }).text)).toEqual({
id: 'file-1',
name: 'test',
type: 'file',
size: 100,
})
})
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' } },
])
const tool = createCreateFileTool('user-1', metadataSchema)
await tool.execute('call-1', {
parent: 'folder-1',
path: filePath,
data: null,
metadata: { prompt: 'Generated using gemini' },
})
expect(assetService.createFile).toHaveBeenCalledWith(
expect.objectContaining({
metadata: { prompt: 'Generated using gemini' },
}),
)
})
it('should forward select and selectMulti newOption metadata', async () => {
const filePath = createTempFile('# Hello from disk', 'create-file-new-option.md')
const metadataSchema = fieldsToTypeBoxSchema([
{
id: 'provider',
config: {
name: 'Provider',
type: 'select',
select: { options: [{ id: 'openai', displayName: 'OpenAI', color: '#f43f5e' }] },
},
},
{
id: 'tags',
config: {
name: 'Tags',
type: 'selectMulti',
selectMulti: { options: [{ id: 'tag1', displayName: 'Tag 1', color: '#3b82f6' }] },
},
},
])
const tool = createCreateFileTool('user-1', metadataSchema)
await tool.execute('call-1', {
parent: 'folder-1',
path: filePath,
data: null,
metadata: {
provider: { newOption: { value: 'Kling' } },
tags: ['tag1', { newOption: { value: 'Tag 2' } }],
},
})
expect(assetService.createFile).toHaveBeenCalledWith(
expect.objectContaining({
metadata: {
provider: { newOption: { value: 'Kling' } },
tags: ['tag1', { newOption: { value: 'Tag 2' } }],
},
}),
)
})
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' } },
])
const tool = createCreateFileTool('user-1', metadataSchema)
await tool.execute('call-1', {
parent: 'folder-1',
path: filePath,
data: null,
metadata: null,
})
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 () => {
const tool = createCreateFileTool('user-1')
await expect(
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(assetService.createFile).not.toHaveBeenCalled()
})
it('should create a file directly from name and content', async () => {
const tool = createCreateFileTool('user-1')
const result = await tool.execute('call-1', {
parent: 'folder-1',
path: null,
data: { name: 'notes.md', content: '# Notes\n\nHello' },
})
expect(s3Service.putObject).toHaveBeenCalledTimes(1)
expect(s3Service.uploadFileToKey).not.toHaveBeenCalled()
const [bucket, s3Key, body, size, contentType] = vi.mocked(s3Service.putObject).mock
.calls[0] as unknown as [string, string, Buffer, number, string]
expect(bucket).toBe(process.env.S3_BUCKET || 'shumai')
expect(s3Key).toMatch(/^files\/.+notes\.md$/)
expect(body.toString('utf-8')).toBe('# Notes\n\nHello')
expect(size).toBe(Buffer.byteLength('# Notes\n\nHello', 'utf-8'))
expect(contentType).toBe('text/markdown')
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({})
expect(JSON.parse((result.content[0] as { text: string }).text)).toEqual({
id: 'file-1',
name: 'test',
type: 'file',
size: 100,
})
})
it('should default unknown extensions to text/plain when creating from content', async () => {
const tool = createCreateFileTool('user-1')
await tool.execute('call-1', {
parent: 'folder-1',
path: null,
data: { name: 'script.ts', content: 'const x = 1' },
})
const [, , , , contentType] = vi.mocked(s3Service.putObject).mock.calls[0] as unknown as [
string,
string,
Buffer,
number,
string,
]
expect(contentType).toBe('text/plain')
})
it('should sanitize the name when creating from content', async () => {
const tool = createCreateFileTool('user-1')
await tool.execute('call-1', {
parent: 'folder-1',
path: null,
data: { name: 'my/notes.md', content: 'hello' },
})
const [, s3Key] = vi.mocked(s3Service.putObject).mock.calls[0] as unknown as [
string,
string,
Buffer,
number,
string,
]
expect(s3Key).toContain('my_notes.md')
expect(assetService.createFile).toHaveBeenCalledWith(
expect.objectContaining({ name: 'my_notes.md' }),
)
})
it('should throw when neither "path" nor "data" is provided', async () => {
const tool = createCreateFileTool('user-1')
await expect(
tool.execute('call-1', { parent: 'folder-1', path: null, data: null }),
).rejects.toThrow('Provide exactly one of "path" (a local file) or "data" (name and content).')
})
it('should throw when both "path" and "data" are provided', async () => {
const tool = createCreateFileTool('user-1')
await expect(
tool.execute('call-1', {
parent: 'folder-1',
path: '/some/file.md',
data: { name: 'notes.md', content: 'hello' },
}),
).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(assetService.createFile).not.toHaveBeenCalled()
})
it('should expose a strict, all-required (nullable) metadata schema when fields are provided', () => {
const metadataSchema = fieldsToTypeBoxSchema([
{ id: 'prompt', config: { name: 'Prompt', type: 'text' } },
{
id: 'source',
config: {
name: 'Source',
type: 'select',
select: { options: [{ id: 'gemini', displayName: 'Gemini', color: '#ffffff' }] },
},
},
{ id: 'rating', config: { name: 'Rating', type: 'rating' } },
])
const tool = createCreateFileTool('user-1', metadataSchema)
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- inspecting the runtime schema shape of the dynamically-built tool
const meta = (tool.parameters as any).properties.metadata
// `metadata` is a nullable union: [strict object, null]
const metaObject = meta.anyOf[0]
expect(meta).toBeDefined()
expect(metaObject.required).toEqual(['prompt', 'source', 'rating'])
expect(metaObject.additionalProperties).toBe(false)
expect(metaObject.properties.prompt.anyOf[0].type).toBe('string')
expect(metaObject.properties.prompt.anyOf[1].type).toBe('null')
expect(metaObject.properties.source.anyOf[0].anyOf[0].enum).toEqual(['gemini'])
expect(metaObject.properties.rating.anyOf[0].type).toBe('number')
// Every field must be present (use null when unknown); unknown keys and bad enums are rejected
expect(Value.Check(meta, { prompt: 'hello', source: 'gemini', rating: 5 })).toBe(true)
expect(
Value.Check(meta, {
prompt: 'hello',
source: { newOption: { value: 'kling' } },
rating: 5,
}),
).toBe(true)
expect(Value.Check(meta, { prompt: null, source: null, rating: null })).toBe(true)
expect(Value.Check(meta, { prompt: 'hello', source: null, rating: null })).toBe(true)
expect(Value.Check(meta, { prompt: 'hello' })).toBe(false)
expect(
Value.Check(meta, { prompt: 'hello', source: 'gemini', rating: 5, unknownKey: 'x' }),
).toBe(false)
expect(Value.Check(meta, { prompt: 'hello', source: 'not-an-option', rating: null })).toBe(
false,
)
})
it('should omit the metadata parameter when no schema is provided', () => {
const tool = createCreateFileTool('user-1')
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- inspecting the runtime schema shape of the dynamically-built tool
expect((tool.parameters as any).properties.metadata).toBeUndefined()
})
it('should pass agentId and record audit log when agentContext is provided', async () => {
const filePath = createTempFile('# Agent file', 'agent-file.md')
const tool = createCreateFileTool('user-1', undefined, { teamId: 'team-1', agentId: 'agent-1' })
await tool.execute('call-1', { parent: 'folder-1', path: filePath, data: null })
expect(assetService.createFile).toHaveBeenCalledWith(
expect.objectContaining({
creatorId: 'user-1',
agentId: 'agent-1',
}),
)
expect(auditLogService.logAction).toHaveBeenCalledWith({
action: AuditAction.file_create,
teamId: 'team-1',
userId: 'user-1',
agentId: 'agent-1',
projectId: undefined,
itemId: 'file-1',
})
})
})

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