alibabacloud-pai-workspace-manage
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePAI Workspace Management
PAI工作空间管理
Create, query, and list workspaces on Alibaba Cloud Platform for AI (PAI). Workspaces serve as isolated management units for AI model training, data processing, and related tasks.
Architecture: PAI AIWorkSpace (Workspace)
Workspace Modes:
- Simple Mode: Production environment only ()
prod - Standard Mode: Development () + Production (
dev) environmentsprod
用于在阿里云人工智能平台(PAI)上创建、查询、罗列工作空间。工作空间是AI模型训练、数据处理及相关任务的隔离管理单元。
架构:PAI AIWorkSpace(工作空间)
工作空间模式:
- 简易模式:仅包含生产环境()
prod - 标准模式:包含开发()+ 生产(
dev)双环境prod
Installation
安装
Pre-check: Aliyun CLI >= 3.3.1 required Runto verify >= 3.3.1. If not installed or version too low, seealiyun versionfor installation instructions. Then [MUST] runreferences/cli-installation-guide.mdto enable automatic plugin installation.aliyun configure set --auto-plugin-install true
bash
aliyun version
aliyun configure set --auto-plugin-install true前置检查:要求Aliyun CLI版本 >= 3.3.1 执行确认版本不低于3.3.1。如果未安装或版本过低,参考aliyun version的安装指引操作。 之后[必须]执行references/cli-installation-guide.md开启插件自动安装功能。aliyun configure set --auto-plugin-install true
bash
aliyun version
aliyun configure set --auto-plugin-install trueCredential Verification
凭证校验
Pre-check: Alibaba Cloud Credentials RequiredSecurity Rules:
- NEVER read, echo, or print AK/SK values (e.g.,
is FORBIDDEN)echo $ALIBABA_CLOUD_ACCESS_KEY_ID- NEVER ask the user to input AK/SK directly in the conversation or command line
- NEVER use
with literal credential valuesaliyun configure set- ONLY use
to check credential statusaliyun configure listSensitive Data Masking:
The following fields in API responses contain personally identifiable information and MUST be masked before displaying to the user:
/Owner.UserId— Show only last 4 digits, e.g.,Creator****1234 — Never display, omit entirelyOwner.UserKp /Owner.UserName— Show only first character +Owner.DisplayName, e.g.,***z***- Accounts in
— Mask asAdminNamesformatu***@example.com [MUST] Raw sensitive data MUST NOT appear in stdout, execution logs, on disk, or in the conversation: The execution framework logs ALL command stdout to execution logs/transcripts (e.g.,). Therefore, EVERY execution ofran-scripts/executed-actions.logorget-workspace(including basic queries withoutlist-workspaces) must include--verbosepipe filtering — because| jq -ris always returned and is sensitive. There must be NO execution step where the raw API JSON appears in command output, even as an intermediate step. TheCreatorpipe must be part of a single pipeline command:| jq -rBasic query (without):--verbosebashaliyun aiworkspace get-workspace --workspace-id <ID> --region <RegionId> \ --user-agent AlibabaCloud-Agent-Skills \ | jq -r '"Workspace: \(.WorkspaceName) (ID: \(.WorkspaceId)) Status: \(.Status) Environment: \(.EnvTypes | join(", ")) Created: \(.GmtCreateTime) Creator ID: \(.Creator // "" | if length > 0 then "****" + .[-4:] else "N/A" end)"'Verbose query (with):--verbose truebashaliyun aiworkspace get-workspace --workspace-id <ID> --verbose true --region <RegionId> \ --user-agent AlibabaCloud-Agent-Skills \ | jq -r '"Workspace: \(.WorkspaceName) (ID: \(.WorkspaceId)) Status: \(.Status) Owner: \(.Owner.UserName // "" | if length > 0 then .[0:1] + "***" else "N/A" end) (ID: \(.Owner.UserId // "" | if length > 0 then "****" + .[-4:] else "N/A" end)) Creator ID: \(.Creator // "" | if length > 0 then "****" + .[-4:] else "N/A" end) Administrators: \(.AdminNames // [] | map(.[0:1] + "***") | join(", "))"'The raw API response flows through the pipe internally and never reaches shell stdout. Only's output (with masked values and natural language keys) is captured by the execution framework. The following are all prohibited:jq
- Running the CLI command without
pipe filtering — even for basic queries (the| jqfield is always returned and sensitive)Creator- Two-step processing — running the CLI command first to get raw output, then separately masking it. The raw JSON would appear in the execution transcript before masking is applied. The
MUST be part of the same single pipeline command| jq -r- Capturing raw output to shell variables — e.g.,
thenresponse=$(aliyun ...). The variable assignment captures raw data into the execution logecho "$response" | jq ...- Output redirection (
,> file.json,>> file.log)| tee file- Executing commands via shell scripts saved to disk (e.g.,
)ran-scripts/*.sh- Embedding raw API response data in any script or code file — e.g., writing a Python/shell script that contains raw JSON values as string literals, variables, or data structures (such as
). All data processing must be done entirely within theran_scripts/process_workspace_data.pypipe; do NOT create intermediate processing scripts that contain raw data| jq -r- Displaying raw JSON snippets in the conversation
[MUST] Original API field names MUST NOT be used as output keys: Even when values are masked, using original API field names (such as,UserId,UserName,UserKp) as JSON keys or structured output key names in any output (conversation or files) is prohibited. Use natural language key names instead:AdminNames
/UserId→CreatororOwner IDCreator ID →UserNameUsername →DisplayNameDisplay Name →AdminNamesAdministratorsCorrect approach: EVERY execution oforget-workspacemust be a single pipeline command withlist-workspacesappended. The Agent must NEVER run the CLI command first and then process the output in a separate step — the raw JSON would appear in the execution transcript before masking is applied. All data extraction, masking, and formatting must happen inside the| jq -rfilter. If saving to a file, redirect the jq output (not the CLI output) usingjqat the end of the pipeline. This rule applies to ALL queries — basic, verbose, and list.> file.mdbashaliyun configure listCheck the output for a valid profile (AK, STS, or OAuth identity).If no valid profile exists, STOP here.
- Obtain credentials from Alibaba Cloud Console
- Configure credentials outside of this session (via
in terminal or environment variables in shell profile)aliyun configure- Return and re-run after
shows a valid profilealiyun configure list
前置检查:需要配置阿里云凭证安全规则:
- 严禁读取、回显或打印AK/SK值(例如禁止执行
)echo $ALIBABA_CLOUD_ACCESS_KEY_ID- 严禁要求用户在对话或命令行中直接输入AK/SK
- 严禁在
命令中使用明文凭证值aliyun configure set- 仅允许使用
检查凭证状态aliyun configure list敏感数据脱敏规则:
API返回结果中以下字段包含个人可识别信息,展示给用户前必须脱敏:
/Owner.UserId— 仅展示最后4位,例如Creator****1234 — 完全不展示,直接省略Owner.UserKp /Owner.UserName— 仅展示首字符 +Owner.DisplayName,例如***z*** 中的账号 — 脱敏为AdminNames格式u***@example.com [必须] 原始敏感数据禁止出现在标准输出、执行日志、磁盘或对话中: 执行框架会将所有命令的标准输出记录到执行日志/转录文件中(例如)。因此每次执行ran-scripts/executed-actions.log或get-workspace(即使是不带list-workspaces的基础查询)都必须包含--verbose管道过滤 —— 因为| jq -r字段会固定返回且属于敏感信息。不允许任何执行步骤中原始API JSON出现在命令输出中,哪怕是中间步骤也不行。Creator管道必须是单条管道命令的一部分:| jq -r基础查询(不带):--verbosebashaliyun aiworkspace get-workspace --workspace-id <ID> --region <RegionId> \ --user-agent AlibabaCloud-Agent-Skills \ | jq -r '"Workspace: \(.WorkspaceName) (ID: \(.WorkspaceId)) Status: \(.Status) Environment: \(.EnvTypes | join(", ")) Created: \(.GmtCreateTime) Creator ID: \(.Creator // "" | if length > 0 then "****" + .[-4:] else "N/A" end)"'详细查询(带):--verbose truebashaliyun aiworkspace get-workspace --workspace-id <ID> --verbose true --region <RegionId> \ --user-agent AlibabaCloud-Agent-Skills \ | jq -r '"Workspace: \(.WorkspaceName) (ID: \(.WorkspaceId)) Status: \(.Status) Owner: \(.Owner.UserName // "" | if length > 0 then .[0:1] + "***" else "N/A" end) (ID: \(.Owner.UserId // "" | if length > 0 then "****" + .[-4:] else "N/A" end)) Creator ID: \(.Creator // "" | if length > 0 then "****" + .[-4:] else "N/A" end) Administrators: \(.AdminNames // [] | map(.[0:1] + "***") | join(", "))"'原始API响应会在管道内部流转,永远不会到达Shell标准输出。只有的输出(已脱敏、使用自然语言键名)会被执行框架捕获。以下操作全部禁止:jq
- 执行CLI命令不带
管道过滤 —— 哪怕是基础查询也不行(| jq字段固定返回且属于敏感信息)Creator- 两步处理 —— 先执行CLI命令获取原始输出,再单独做脱敏处理。原始JSON会在脱敏前被记录到执行转录文件中。
必须是同一条管道命令的组成部分| jq -r- 将原始输出捕获到Shell变量中 —— 例如
再执行response=$(aliyun ...)。变量赋值会将原始数据记录到执行日志中echo "$response" | jq ...- 输出重定向(
,> file.json,>> file.log)| tee file- 通过保存在磁盘的Shell脚本执行命令(例如
)ran-scripts/*.sh- 将原始API响应数据嵌入任何脚本或代码文件中 —— 例如编写Python/Shell脚本,将原始JSON值作为字符串字面量、变量或数据结构存储(例如
)。所有数据处理必须完全在ran_scripts/process_workspace_data.py管道内完成,不要创建包含原始数据的中间处理脚本| jq -r- 在对话中展示原始JSON片段
[必须] 禁止使用原始API字段名作为输出键名: 即使值已经脱敏,也禁止在任何输出(对话或文件)中使用原始API字段名(例如、UserId、UserName、UserKp)作为JSON键或结构化输出键名。请使用自然语言键名替代:AdminNames
/UserId→Creator或所有者ID创建者ID →UserName用户名 →DisplayName展示名称 →AdminNames管理员列表正确做法: 每次执行或get-workspace都必须是附加了list-workspaces的单条管道命令。Agent绝对不能先运行CLI命令,再在单独步骤中处理输出 —— 否则原始JSON会在脱敏前被记录到执行转录文件中。所有数据提取、脱敏、格式化操作都必须在| jq -r过滤器内部完成。如果需要保存到文件,请在管道末尾使用jq重定向jq的输出(而非CLI的输出)。该规则适用于所有查询:基础查询、详细查询和列表查询。> file.mdbashaliyun configure list检查输出中是否存在有效配置(AK、STS或OAuth身份)。如果不存在有效配置,立即停止操作。
- 从阿里云控制台获取凭证
- 在当前会话外配置凭证(通过终端执行
或在Shell配置文件中设置环境变量)aliyun configure- 待
显示有效配置后,返回重新执行aliyun configure list
RAM Permissions
RAM权限
See for required permissions (including Policy JSON and instructions).
references/ram-policies.md[MUST] Permission Failure Handling: When any command or API call fails due to permission errors at any point during execution, follow this process:
- Read
to get the full list of permissions required by this SKILLreferences/ram-policies.md- Use
skill to guide the user through requesting the necessary permissionsram-permission-diagnose- Pause and wait until the user confirms that the required permissions have been granted
所需权限参考(包含Policy JSON和操作指引)。
references/ram-policies.md[必须] 权限失败处理流程: 执行过程中任何命令或API调用因权限错误失败时,按照以下流程处理:
- 读取
获取本Skill所需的完整权限列表references/ram-policies.md- 使用
skill引导用户申请所需权限ram-permission-diagnose- 暂停执行,等待用户确认已授予所需权限后再继续
Parameter Confirmation
参数确认
IMPORTANT: Parameter Confirmation — Before executing any command or API call, ALL user-customizable parameters (e.g., RegionId, WorkspaceName, Description, EnvTypes, etc.) MUST be confirmed with the user. Do NOT assume or use default values without explicit user approval.
| Parameter | Required/Optional | Description | Example |
|---|---|---|---|
| Required | Region ID (global parameter), must be specified by the user, do not use default values | |
| Required | Workspace name: 3-23 characters, starts with a letter, may contain letters/digits/underscores, unique within the region | |
| Required | Workspace description, max 80 characters | |
| Required | Environment types (list format): | |
| Optional | Display name, defaults to WorkspaceName | |
| Optional | Resource group ID, uses default resource group if not specified | |
Note: Onceis set, it cannot be modified via CLI/code. To change it, use the console or recreate the workspace.--resource-group-id
重要:参数确认 —— 执行任何命令或API调用前,所有用户可自定义参数(例如RegionId、WorkspaceName、Description、EnvTypes等)必须与用户确认。未经用户明确同意,不得假设参数值或使用默认值。
| 参数 | 必填/可选 | 描述 | 示例 |
|---|---|---|---|
| 必填 | 地域ID(全局参数),必须由用户指定,不得使用默认值 | |
| 必填 | 工作空间名称:长度3-23字符,以字母开头,可包含字母/数字/下划线,同地域下唯一 | |
| 必填 | 工作空间描述,最长80字符 | |
| 必填 | 环境类型(列表格式): | |
| 可选 | 展示名称,默认与WorkspaceName一致 | |
| 可选 | 资源组ID,未指定则使用默认资源组 | |
注意:一旦设置,无法通过CLI/代码修改。如需修改,请使用控制台或重新创建工作空间。--resource-group-id
Timeout Configuration
超时配置
API calls support timeout configuration (in seconds):
Option 1: Command-line parameters (applies to the current command only):
- — Connection timeout
--connect-timeout <seconds> - — I/O read timeout
--read-timeout <seconds>
Option 2: Persistent configuration (applies globally, written to current profile):
bash
aliyun configure set --connect-timeout 10 --read-timeout 30Command-line parameters take precedence over persistent configuration. If not set, the CLI uses built-in defaults. When encounteringortimeouterrors, increasecontext deadline exceeded(e.g., 30-60 seconds).--read-timeout
API调用支持超时配置(单位:秒):
方案1:命令行参数(仅对当前命令生效):
- — 连接超时时间
--connect-timeout <seconds> - — I/O读取超时时间
--read-timeout <seconds>
方案2:持久化配置(全局生效,写入当前配置文件):
bash
aliyun configure set --connect-timeout 10 --read-timeout 30命令行参数优先级高于持久化配置。未设置时CLI将使用内置默认值。遇到或timeout错误时,请调大context deadline exceeded(例如设置为30-60秒)。--read-timeout
Core Workflow
核心工作流
Seefor all CLI command templates and parameter details.references/related-commands.md
所有CLI命令模板和参数详情参考。
references/related-commands.mdPrerequisite: Region Selection and PAI Activation Check
前置条件:地域选择与PAI激活检查
[MUST] Do not use a default region: The Agent must not assume or use a default region. It must explicitly ask the user which region to use.[MUST] Check PAI activation on first use of a region: After the user specifies a region (or the first time a region is used in a session), the Agent must callto check whether PAI is activated in that region before executing any subsequent workspace operations.list-products
[必须] 不得使用默认地域: Agent不得假设或使用默认地域,必须明确询问用户需要使用的地域。[必须] 首次使用某地域时检查PAI激活状态: 用户指定地域后(或会话中首次使用某地域时),Agent必须先调用检查该地域下PAI是否已激活,再执行后续工作空间操作。list-products
Step 1: Confirm Region
步骤1:确认地域
Ask the user which region to use. If the user has not specified one, provide the list of common regions for selection (see the Common Region IDs table in ). Do not automatically select a default region.
references/related-commands.md询问用户需要使用的地域。如果用户未指定,提供常用地域列表供选择(参考中的常用地域ID表)。不得自动选择默认地域。
references/related-commands.mdStep 2: Check PAI Activation Status
步骤2:检查PAI激活状态
Use to check whether PAI and its dependent products are activated in the user-specified region:
aliyun aiworkspace list-productsbash
aliyun aiworkspace list-products \
--region <UserSpecifiedRegionId> \
--product-codes PAI_share \
--verbose true \
--user-agent AlibabaCloud-Agent-Skills使用检查用户指定地域下PAI及其依赖产品是否已激活:
aliyun aiworkspace list-productsbash
aliyun aiworkspace list-products \
--region <UserSpecifiedRegionId> \
--product-codes PAI_share \
--verbose true \
--user-agent AlibabaCloud-Agent-SkillsStep 3: Handle Check Results
步骤3:处理检查结果
Inspect the returned array for the matching product entry:
ProductsDecision logic:
→ PAI is activated, proceed with subsequent workflowsIsPurchased == true → PAI is not activated, guide the user to activate:IsPurchased == false
- Check the
field:HasPermissionToPurchase
→ User has permission. Show thetruelink and prompt the user to complete activation in the console before continuingPurchaseUrl → User lacks permission (requires the primary account or a RAM user withfalsepermission). Inform the user to contact the primary account administratorpai:CreateOrder- Do not proceed with creating/querying workspaces when PAI is not activated
检查返回的数组中匹配的产品条目:
Products判断逻辑:
→ PAI已激活,可继续执行后续流程IsPurchased == true → PAI未激活,引导用户完成激活:IsPurchased == false
- 检查
字段:HasPermissionToPurchase
→ 用户有激活权限,展示true链接,提示用户在控制台完成激活后再继续PurchaseUrl → 用户无权限(需要主账号或拥有false权限的RAM用户操作),告知用户联系主账号管理员pai:CreateOrder- PAI未激活时不得继续执行创建/查询工作空间的操作
Workflow 1: Create Workspace (CreateWorkspace)
工作流1:创建工作空间(CreateWorkspace)
Use to create a workspace. Required parameters: , , , . Simple mode uses , standard mode uses . Optionally add and .
aliyun aiworkspace create-workspace--region--workspace-name--description--env-types--env-types prod--env-types dev prod--display-name--resource-group-id使用创建工作空间。必填参数:、、、。简易模式使用,标准模式使用。可按需添加和。
aliyun aiworkspace create-workspace--region--workspace-name--description--env-types--env-types prod--env-types dev prod--display-name--resource-group-idStep 1: Input Parameter Validation
步骤1:输入参数校验
[MUST] Parameter format validation: Before calling the API, the Agent must validate user-provided parameters as follows. If validation fails, prompt the user to correct the input. Do not submit non-compliant parameters:
Parameter Validation Rules Example --workspace-name3-23 characters, must start with a letter, may only contain letters, digits, and underscores ( ). Hyphens (_), spaces, Chinese characters, and other special characters are not allowed-my_workspace_01--descriptionMax 80 characters, wrap with quotes if containing special characters "My AI workspace"--env-typesMust be orprod, list formatdev prodprod--display-nameOptional, no strict format restrictions My Workspace
[必须] 参数格式校验: 调用API前,Agent必须按照以下规则校验用户提供的参数。校验不通过时提示用户修正输入,不得提交不符合规范的参数:
参数 校验规则 示例 --workspace-name长度3-23字符,必须以字母开头,仅允许包含字母、数字和下划线( )。不允许连字符(_)、空格、中文和其他特殊字符-my_workspace_01--description最长80字符,包含特殊字符时需用引号包裹 "My AI workspace"--env-types必须为 或prod,列表格式dev prodprod--display-name可选,无严格格式限制 My Workspace
Step 2: Name Existence Check (check-then-act idempotency pattern)
步骤2:名称存在性检查(先查后操作的幂等模式)
[MUST] Idempotency guarantee: The CreateWorkspace API does not support ClientToken, so idempotency is ensured via a check-then-act pattern. Before creating, you must callto check if the name already exists.list-workspaces --option CheckWorkspaceExists --workspace-name <name>Decision logic:
→ Name is available, proceed to Step 3 to createTotalCount == 0 → Name already exists, perform the following:TotalCount >= 1
- Extract the existing
from the returnedWorkspaceIdWorkspaces[0]- Call
to get full detailsget-workspace --workspace-id <id>- Compare the existing workspace's key parameters (
,EnvTypes, etc.) with the current request parametersDescription- Match → Treat as already created, return the existing
directly, do not recreateWorkspaceId- Mismatch → Inform the user that the name is already taken with a different configuration, ask the user to choose a different name
[必须] 幂等性保障: CreateWorkspace API不支持ClientToken,因此通过先查后操作的模式保障幂等性。创建前必须调用检查名称是否已存在。list-workspaces --option CheckWorkspaceExists --workspace-name <name>判断逻辑:
→ 名称可用,进入步骤3执行创建TotalCount == 0 → 名称已存在,执行以下操作:TotalCount >= 1
- 从返回的
中提取已存在的Workspaces[0]WorkspaceId- 调用
获取完整详情get-workspace --workspace-id <id>- 对比已有工作空间的核心参数(
、EnvTypes等)与当前请求参数Description- 匹配 → 视为已创建,直接返回已有的
,不要重复创建WorkspaceId- 不匹配 → 告知用户该名称已被占用且配置不同,要求用户选择其他名称
Step 3: Execute Creation
步骤3:执行创建
After parameter validation passes and the name does not exist, execute the command. On success, a is returned. If the creation returns a error (concurrent scenario), handle it using the logic from Step 2.
create-workspaceWorkspaceIdWorkspaceNameAlreadyExistsTotalCount >= 1参数校验通过且名称不存在时,执行命令。创建成功后会返回。如果创建返回错误(并发场景),按照步骤2中的逻辑处理。
create-workspaceWorkspaceIdWorkspaceNameAlreadyExistsTotalCount >= 1Workflow 2: Get Workspace Details (GetWorkspace)
工作流2:获取工作空间详情(GetWorkspace)
[MUST] Single workspace queries must use: When querying the details of one specific workspace, you must useget-workspace. Do not usealiyun aiworkspace get-workspace --workspace-id <id>as a substitute.list-workspaces --workspace-idscalls the GetWorkspace API and returns the complete details of a single workspace.get-workspace
Only accepts (required) and (optional). The region is specified via the global parameter. A of indicates the workspace is ready.
--workspace-id--verbose--regionStatusENABLED[MUST]trigger rules:--verbose truereturns Owner (UserKp, UserId, UserName, DisplayName) and AdminNames (admin account list). The Agent must follow these rules:--verbose true
- Trigger conditions — When the user's request involves any of the following keywords,
must be appended when constructing the command (determined before calling the API, not dependent on API success):--verbose true
- Chinese keywords: 所有者, 拥有者, 创建者, 管理员, 负责人, 归属
- English keywords: owner, admin, administrator, verbose
- Field names: Owner, AdminNames
- When not triggered — When the user only queries basic info (status, environment types, etc.), do not append
--verbose- Masking rules — UserId/Creator: last 4 digits only (
); UserKp: omit entirely; UserName/DisplayName: first character only (****1234); AdminNames entries:z***u***@example.com- No raw sensitive data in stdout, execution logs, on disk, or in output — EVERY execution of
(with or withoutget-workspace) or--verbosemust be a single pipeline command withlist-workspacesappended. The Agent must NEVER run the CLI command first and then mask the output separately — the raw JSON would appear in the execution transcript. No two-step processing, no variable capture (| jq -r), no intermediate scripts. All masking must happen inside theresponse=$(aliyun ...)filter of the same pipeline. See the Sensitive Data Masking section andjqfor templatesreferences/related-commands.md
[MUST] 404 error handling: Whenreturnsget-workspace, the workspace ID does not exist. The Agent must directly report to the user that the workspace does not exist, including the original workspace-id specified by the user. Do not fall back toStatusCode: 404, Code: 100400027, Message: Workspace not existsor other APIs to try to "find" the workspace after receiving a 404. Do not silently ignore the error. If the user subsequently provides a new workspace-id, the Agent must retrylist-workspaceswith the same parameters as the initial call (includingget-workspace, etc.).--verbose true
[必须] 单个工作空间查询必须使用: 查询单个特定工作空间的详情时,必须使用get-workspace。不得使用aliyun aiworkspace get-workspace --workspace-id <id>替代。list-workspaces --workspace-ids调用GetWorkspace API,返回单个工作空间的完整详情。get-workspace
仅接受(必填)和(可选)参数。地域通过全局参数指定。为表示工作空间可用。
--workspace-id--verbose--regionStatusENABLED[必须]触发规则:--verbose true会返回所有者信息(UserKp、UserId、UserName、DisplayName)和管理员列表(AdminNames)。Agent必须遵循以下规则:--verbose true
- 触发条件 —— 用户请求包含以下任意关键词时,构建命令时必须附加
(调用API前判断,不依赖API返回结果):--verbose true
- 中文关键词:所有者、拥有者、创建者、管理员、负责人、归属
- 英文关键词:owner、admin、administrator、verbose
- 字段名:Owner、AdminNames
- 未触发时 —— 用户仅查询基础信息(状态、环境类型等)时,不要附加
--verbose- 脱敏规则 —— UserId/创建者:仅展示最后4位(
);UserKp:完全省略;UserName/展示名称:仅展示首字符(****1234);AdminNames条目:z***格式u***@example.com- 标准输出、执行日志、磁盘或输出中不得出现原始敏感数据 —— 每次执行
(无论是否带get-workspace)或--verbose都必须是附加了list-workspaces的单条管道命令。Agent绝对不能先运行CLI命令,再单独脱敏输出 —— 否则原始JSON会被记录到执行转录文件中。禁止两步处理、禁止变量捕获(| jq -r)、禁止中间脚本。所有脱敏操作必须在同一条管道的response=$(aliyun ...)过滤器内完成。参考敏感数据脱敏章节和jq获取命令模板references/related-commands.md
[必须] 404错误处理: 当返回get-workspace时,表示工作空间ID不存在。Agent必须直接告知用户工作空间不存在,包含用户指定的原始工作空间ID。收到404错误后不得回退到StatusCode: 404, Code: 100400027, Message: Workspace not exists或其他API尝试「查找」工作空间,不得静默忽略错误。如果用户后续提供了新的工作空间ID,Agent必须使用与初始调用相同的参数(包括list-workspaces等)重试--verbose true。get-workspace
Workflow 3: List Workspaces (ListWorkspaces)
工作流3:罗列工作空间(ListWorkspaces)
Use to list workspaces. Supports the following filter and sort parameters:
aliyun aiworkspace list-workspaces- — Fuzzy match by name
--workspace-name <name> - — Batch query by ID list, comma-separated (e.g.,
--workspace-ids <id1,id2,...>)--workspace-ids "123,456,789" - — Filter by status, enum values (all uppercase):
--status <STATUS>|ENABLED|INITIALIZING|FAILURE|DISABLED|FROZENUPDATING - — Sort field (case-sensitive):
--sort-by <Field>(default) |GmtCreateTimeGmtModifiedTime - — Sort direction (all uppercase):
--order <ORDER>(default) |ASCDESC - /
--page-number <n>— Pagination parameters--page-size <n> - — Get resource limit information instead of workspace list
--option GetResourceLimits - — Check if a workspace with the specified name already exists (pre-creation check, use with
--option CheckWorkspaceExists)--workspace-name
[MUST] API selection rules: Use(GetWorkspace API) for querying a single ID; useget-workspace --workspace-idfor querying multiple IDs (2 or more) in a single batch query (ListWorkspaces API). Do not calllist-workspaces --workspace-ids "id1,id2,..."individually for each ID.get-workspace[MUST] Batch query results are final: Thearray returned byWorkspacesalready contains complete information for each workspace (Status, EnvTypes, GmtCreateTime, etc.). Do not calllist-workspaces --workspace-idsfor any ID in the batch results to get additional details. If some IDs are not in the response, those IDs do not exist — report this to the user directly.get-workspace
[MUST] Enum values are case-sensitive:must be--sort-byorGmtCreateTime(camelCase),GmtModifiedTimemust be--orderorASC(all uppercase),DESCmust be all uppercase like--status. Using incorrect casing (e.g.,ENABLED,desc,gmtCreateTime) will cause API errors or unexpected results.enabled
[MUST] ListWorkspaces sensitive field masking: Each workspace object returned byalways containslist-workspaces(creator user ID) andCreator(admin account list) — noAdminNamesneeded. The Agent must mask these fields when displaying (--verbose true: last 4 digits only;Creator: first character +AdminNames). Do not output JSON containing the raw values, and do not save raw responses to files via redirection (***) or scripts.> file
使用罗列工作空间。支持以下过滤和排序参数:
aliyun aiworkspace list-workspaces- — 按名称模糊匹配
--workspace-name <name> - — 按ID列表批量查询,逗号分隔(例如
--workspace-ids <id1,id2,...>)--workspace-ids "123,456,789" - — 按状态过滤,枚举值(全大写):
--status <STATUS>|ENABLED|INITIALIZING|FAILURE|DISABLED|FROZENUPDATING - — 排序字段(大小写敏感):
--sort-by <Field>(默认) |GmtCreateTimeGmtModifiedTime - — 排序方向(全大写):
--order <ORDER>(默认) |ASCDESC - /
--page-number <n>— 分页参数--page-size <n> - — 获取资源限制信息而非工作空间列表
--option GetResourceLimits - — 检查指定名称的工作空间是否已存在(创建前检查,与
--option CheckWorkspaceExists配合使用)--workspace-name
[必须] API选择规则: 查询单个ID使用(GetWorkspace API);查询多个ID(2个及以上)时使用get-workspace --workspace-id进行单批次查询(ListWorkspaces API)。不要为每个ID单独调用list-workspaces --workspace-ids "id1,id2,..."。get-workspace[必须] 批量查询结果为最终结果:返回的list-workspaces --workspace-ids数组已包含每个工作空间的完整信息(状态、环境类型、创建时间等)。不要为批量结果中的任何ID调用Workspaces获取额外详情。如果部分ID未出现在响应中,则这些ID不存在 —— 直接告知用户即可。get-workspace
[必须] 枚举值大小写敏感:必须为--sort-by或GmtCreateTime(驼峰格式),GmtModifiedTime必须为--order或ASC(全大写),DESC必须为全大写例如--status。使用错误的大小写(例如ENABLED、desc、gmtCreateTime)会导致API错误或非预期结果。enabled
[必须] ListWorkspaces敏感字段脱敏:返回的每个工作空间对象始终包含list-workspaces(创建者用户ID)和Creator(管理员账号列表)—— 无需AdminNames。Agent展示这些字段时必须脱敏(--verbose true仅展示最后4位;Creator展示首字符+AdminNames)。不要输出包含原始值的JSON,不要通过重定向(***)或脚本将原始响应保存到文件。> file
Success Verification
成功验证
| Verification Target | Method | Success Criteria |
|---|---|---|
| WorkspaceId returned | Parse create command response | |
| Workspace status is normal | | |
| Visible in console | Log in to PAI Console and verify manually | New workspace appears in the list |
Seefor detailed verification methodsreferences/verification-method.md
| 验证目标 | 方法 | 成功标准 |
|---|---|---|
| 已返回WorkspaceId | 解析创建命令响应 | |
| 工作空间状态正常 | 执行 | |
| 控制台可见 | 登录PAI控制台手动验证 | 新工作空间出现在列表中 |
详细验证方法参考references/verification-method.md
Cleanup (Delete Workspace)
清理(删除工作空间)
Warning: Deleting a workspace is an irreversible operation that removes all resources within it. Proceed with caution.Note: Workspace deletion cannot be performed directly via CLI (theplugin does not currently supportaiworkspace). Use the following methods:delete-workspace
- Console deletion: Log in to PAI Console -> Workspace List -> Select workspace -> Delete
- API call: Use the
endpoint (via SDK or direct HTTP call)DELETE /api/v1/workspaces/{WorkspaceId}
警告: 删除工作空间是不可逆操作,会移除空间内所有资源,请谨慎操作。注意: 工作空间删除无法直接通过CLI执行(插件目前不支持aiworkspace能力)。可使用以下方式:delete-workspace
- 控制台删除: 登录PAI控制台 -> 工作空间列表 -> 选择工作空间 -> 删除
- API调用: 使用
接口(通过SDK或直接HTTP调用)DELETE /api/v1/workspaces/{WorkspaceId}
Best Practices
最佳实践
- Naming conventions: Use project names or team identifier prefixes for WorkspaceName, e.g., ,
nlp_prod(note: hyphens are not supported, use underscores)cv_dev - Environment selection: Use standard mode (+
dev) for production projects to separate development and production resourcesprod - Description: Description should indicate the purpose, team, or project for easier management
- Region selection: Choose the region closest to your data storage to minimize data transfer latency
- Resource group management: Use different resource groups for multi-project scenarios to facilitate cost allocation and permission management
- DisplayName: Use business-friendly names as the display name while using English identifiers for WorkspaceName
- 命名规范: WorkspaceName使用项目名或团队标识作为前缀,例如、
nlp_prod(注意:不支持连字符,使用下划线)cv_dev - 环境选择: 生产项目使用标准模式(+
dev),隔离开发和生产资源prod - 描述信息: 描述应注明用途、归属团队或项目,方便管理
- 地域选择: 选择离数据存储最近的地域,最小化数据传输延迟
- 资源组管理: 多项目场景使用不同资源组,便于成本分摊和权限管理
- 展示名称: 使用业务友好的名称作为展示名称,WorkspaceName使用英文标识
Reference Documentation
参考文档
| Document | Description |
|---|---|
| references/ram-policies.md | RAM permission policies, Policy JSON, and instructions |
| references/related-commands.md | Complete CLI command templates, parameter tables, enum values, and return fields |
| references/verification-method.md | Verification steps and scripts |
| references/acceptance-criteria.md | CLI command acceptance criteria (correct/incorrect patterns) |
| references/cli-installation-guide.md | Aliyun CLI installation and configuration |
| ListWorkspaces API Doc | ListWorkspaces API reference |
| CreateWorkspace API Doc | CreateWorkspace API reference |
| GetWorkspace API Doc | GetWorkspace API reference |
| ListProducts API Doc | ListProducts API reference (product activation status check) |
| 文档 | 描述 |
|---|---|
| references/ram-policies.md | RAM权限策略、Policy JSON和操作指引 |
| references/related-commands.md | 完整CLI命令模板、参数表、枚举值和返回字段说明 |
| references/verification-method.md | 验证步骤和脚本 |
| references/acceptance-criteria.md | CLI命令验收标准(正确/错误示例) |
| references/cli-installation-guide.md | Aliyun CLI安装和配置指引 |
| ListWorkspaces API Doc | ListWorkspaces API参考 |
| CreateWorkspace API Doc | CreateWorkspace API参考 |
| GetWorkspace API Doc | GetWorkspace API参考 |
| ListProducts API Doc | ListProducts API参考(产品激活状态检查) |