diff --git a/README.md b/README.md index 0aff36f5..26d3ba85 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ But Shumai goes beyond being a Frame.io alternative. With modern models like GPT * **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: diff --git a/README_CN.md b/README_CN.md index 63f9d400..bc0aa90c 100644 --- a/README_CN.md +++ b/README_CN.md @@ -38,6 +38,7 @@ Shumai 是一个开源的 Frame.io 替代方案,专为创意团队打造,让 * **沙箱隔离执行**:Agent 生成的脚本会在隔离环境里运行,更安全。 * **AI 自动补全元数据**:新素材上传后,系统可以自动帮你补一些元数据。 * **语义搜索**:支持按画面内容或语义找素材,底层用的是向量 embedding(Gemini Embedding 2)。 +* **资源配额**:支持按成员、角色或全团队对 AI Token、成本和工具调用设置使用上限与实时用量监控。 下面是一个简短的 demo 视频,展示了 Shumai Agent 能做什么: diff --git a/docs/docs.json b/docs/docs.json index 5bbb88a2..faa35e87 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -51,8 +51,8 @@ ] }, { - "group": "Media Transcoding Settings", - "pages": ["using-shumai/transcode-settings"] + "group": "Team Settings", + "pages": ["using-shumai/transcode-settings", "using-shumai/quotas-settings"] }, { "group": "Configuration", diff --git a/docs/using-shumai/quotas-settings.mdx b/docs/using-shumai/quotas-settings.mdx new file mode 100644 index 00000000..032d978a --- /dev/null +++ b/docs/using-shumai/quotas-settings.mdx @@ -0,0 +1,95 @@ +--- +title: Resource Quotas +description: Control and monitor AI token usage, costs, shell executions, and tool call quotas for your team. +--- + +AI workflows and media processing tools can consume significant compute and API credits. Shumai provides a **Resource Quotas** system that allows Team Owners to set granular rate limits, govern budgets, and monitor real-time usage across team members and roles. + +--- + +## Overview + +Resource Quotas allow you to define maximum usage limits across specific time windows (e.g., hourly, daily, or weekly). When a member or team reaches their assigned quota, further actions for that resource are safely blocked until the quota period resets. + +To manage quotas, open **Team Settings** from your team dashboard and navigate to the **Quotas** tab. + +--- + +## Scope Modes + +When creating or editing a quota rule, you can define how the limit is applied: + +### 1. Each Member + +- **Behavior**: Every member in the scope receives their own independent limit. Usage by one member does not affect the remaining quota of others. +- **Optional Role Filter**: You can restrict the quota to members with a specific role (e.g. only **Editors** or **Reviewers**), or apply it to the entire team. +- **Use Case**: Give each editor a daily budget of 100,000 tokens. + +### 2. All Members (Shared Pool) + +- **Behavior**: The quota limit is shared as a collective pool across all matching members. Every member's consumption draws from the same total. +- **Optional Role Filter**: Apply the shared pool to all team members or restrict it to a specific role. +- **Use Case**: Cap the total team spending on AI models to $50 per day. + +### 3. Selected Members + +- **Behavior**: Assign individual limits to specific chosen team members. +- **Use Case**: Grant higher limits to senior artists or technical directors while keeping standard limits for others. + +--- + +## Supported Resource Types + +Shumai supports quota enforcement across multiple layers of the AI and agent architecture: + +| Resource Type | Description | Target Specification | +| :-------------------------- | :-------------------------------------------------------------------------------------- | :----------------------------------- | +| **Total Tokens** | Total LLM input and output tokens consumed in chat, comments, and autofill. | Team, Role, or Members | +| **AI Cost ($)** | Dollar expenditure accrued from AI model providers. | Team, Role, or Members | +| **MCP Server Calls** | Number of tool invocations directed to a connected Model Context Protocol (MCP) server. | Target MCP Server ID | +| **Sandboxed Bash Commands** | Shell commands executed by the agent inside the isolated sandbox. | Wildcard pattern (e.g. `npm *`, `*`) | +| **Agent Tool Calls** | Calls to specific native tools (e.g. `analyze_image`, `screenshot`, `create_file`). | Tool name | + +### Bash Command Wildcard Matching + +For sandboxed bash execution, you can restrict specific command patterns using wildcards (`*` and `?`): + +- `*`: Matches any bash command execution. +- `npm *`: Matches any npm command (e.g., `npm install`, `npm test`). +- `git commit*`: Matches git commit invocations. + +--- + +## Time Periods & Rollover + +Quotas can be configured with the following reset periods: + +- **1 Hour** (`1hour`) +- **5 Hours** (`5hour`) +- **1 Day** (`1day`) +- **7 Days** (`7day`) + +### Lazy Reset Mechanism + +Shumai tracks usage windows automatically. When a period window expires, the system resets the quota upon the member's next request, seamlessly starting a fresh window without requiring background maintenance tasks. + +--- + +## Monitoring Live Usage + +Team Owners can inspect live consumption at any time: + +1. In the **Quotas** settings tab, click **View Usage** on any quota rule card. +2. The **Usage Records** modal displays: + - **Consumption Status**: Progress bar showing consumed units vs. total limit. + - **Remaining Allowance**: Percentage and numerical amount remaining. + - **Refresh Countdown**: Exact remaining time until the active window resets (e.g., _"Refreshes in 45m"_). + - **Member Search**: Quickly filter through members to view individual usage. + +--- + +## Managing Quota Rules + +- **Enable / Disable**: Toggle the switch on any quota card to temporarily pause or resume enforcement without deleting the rule. +- **Edit Rules**: Click any quota card to update limits, change reset periods, or adjust member selections. +- **Delete Rules**: Open the card action menu (`⋮`) and select **Delete** to remove the quota rule. diff --git a/packages/webui/messages/en.json b/packages/webui/messages/en.json index 2a45afdd..28dbf607 100644 --- a/packages/webui/messages/en.json +++ b/packages/webui/messages/en.json @@ -505,7 +505,7 @@ "pending_domains_description": "These domains were blocked during agent execution. You can approve them to allow future network requests, or delete them from this list.", "no_pending_domains": "No pending domains requiring approval", "filesystem_restriction": "Filesystem Restriction", - "filesystem_restriction_description": "The agent is restricted to reading and writing only within the .pi and /tmp folders. These settings are currently hardcoded for security.", + "filesystem_restriction_description": "Sandboxed shell commands can read workspace files except sensitive environment, certificate, and key files. They can write to the project's .pi folder and the system temporary directory, plus a few runtime-managed system paths. These filesystem rules are currently hardcoded for security.", "position_and_resize": "Position and resize", "avatar_source": "Avatar Source", diff --git a/packages/webui/messages/zh.json b/packages/webui/messages/zh.json index 72baa03a..ec55b3e5 100644 --- a/packages/webui/messages/zh.json +++ b/packages/webui/messages/zh.json @@ -505,7 +505,7 @@ "pending_domains_description": "这些域名在智能体执行期间被阻止。您可以批准它们以允许将来的网络请求,或从此列表中删除它们。", "no_pending_domains": "没有待审核的域名", "filesystem_restriction": "文件系统限制", - "filesystem_restriction_description": "智能体仅限于在 .pi 和 /tmp 文件夹内读写。这些设置目前出于安全考虑已硬编码。", + "filesystem_restriction_description": "沙箱 Shell 命令可以读取工作区文件,但环境变量、证书和密钥等敏感文件除外;可以写入项目的 .pi 文件夹和系统临时目录,以及少量由运行时管理的系统路径。这些文件系统规则目前出于安全考虑已硬编码。", "position_and_resize": "定位和调整大小", "avatar_source": "头像来源", diff --git a/packages/webui/paraglide/messages/filesystem_restriction_description.d.ts b/packages/webui/paraglide/messages/filesystem_restriction_description.d.ts index b2d5690f..c19f7bc8 100644 --- a/packages/webui/paraglide/messages/filesystem_restriction_description.d.ts +++ b/packages/webui/paraglide/messages/filesystem_restriction_description.d.ts @@ -1,7 +1,7 @@ /** * | output | * | --- | -* | "The agent is restricted to reading and writing only within the .pi and /tmp folders. These settings are currently hardcoded for security." | +* | "Sandboxed shell commands can read workspace files except sensitive environment, certificate, and key files. They can write to the project's .pi folder and th..." | * * @param {Filesystem_Restriction_DescriptionInputs} inputs * @param {{ locale?: "en" | "zh" }} options diff --git a/packages/webui/paraglide/messages/filesystem_restriction_description.js b/packages/webui/paraglide/messages/filesystem_restriction_description.js index 2391089c..e1f7784a 100644 --- a/packages/webui/paraglide/messages/filesystem_restriction_description.js +++ b/packages/webui/paraglide/messages/filesystem_restriction_description.js @@ -6,17 +6,17 @@ import { getLocale, experimentalStaticLocale } from '../runtime.js'; /** @typedef {{}} Filesystem_Restriction_DescriptionInputs */ const en_filesystem_restriction_description = /** @type {(inputs: Filesystem_Restriction_DescriptionInputs) => LocalizedString} */ () => { - return /** @type {LocalizedString} */ (`The agent is restricted to reading and writing only within the .pi and /tmp folders. These settings are currently hardcoded for security.`) + return /** @type {LocalizedString} */ (`Sandboxed shell commands can read workspace files except sensitive environment, certificate, and key files. They can write to the project's .pi folder and the system temporary directory, plus a few runtime-managed system paths. These filesystem rules are currently hardcoded for security.`) }; const zh_filesystem_restriction_description = /** @type {(inputs: Filesystem_Restriction_DescriptionInputs) => LocalizedString} */ () => { - return /** @type {LocalizedString} */ (`智能体仅限于在 .pi 和 /tmp 文件夹内读写。这些设置目前出于安全考虑已硬编码。`) + return /** @type {LocalizedString} */ (`沙箱 Shell 命令可以读取工作区文件,但环境变量、证书和密钥等敏感文件除外;可以写入项目的 .pi 文件夹和系统临时目录,以及少量由运行时管理的系统路径。这些文件系统规则目前出于安全考虑已硬编码。`) }; /** * | output | * | --- | -* | "The agent is restricted to reading and writing only within the .pi and /tmp folders. These settings are currently hardcoded for security." | +* | "Sandboxed shell commands can read workspace files except sensitive environment, certificate, and key files. They can write to the project's .pi folder and th..." | * * @param {Filesystem_Restriction_DescriptionInputs} inputs * @param {{ locale?: "en" | "zh" }} options