Script execution and member grants
Workspace admins can enable script execution for members: in chat the agent runs Python scripts in a skill to generate or edit downloadable Excel / Word / PPT. Permissions are plat
Source help/en/admin-ops/script-execution.md
Workspace admins can enable script execution for members: in chat the agent runs Python scripts in a skill to generate or edit downloadable Excel / Word / PPT. Permissions are platform, workspace, and member — similar to network requests.
What you can do
- The agent runs scripts under the skill
scripts/directory (e.g.main.py) - Typical results: export
.xlsx, generate.docx, make.pptx - To edit an existing Office attachment, also enable Office document read, and pass the source file in the script
Script logic is written in Skills Center; this page is who may run, not how to write Python.
Who can configure
| Role | What they can do |
|---|---|
| Platform ops | Turn on the platform master switch in mindlink.json (see Server configuration) |
| Workspace owner / admin | Enable in Workspace collaboration → Assistant capability packs → Script execution, and grant each member separately |
| Ordinary member | See whether they are granted; if not enabled they can submit a capability request |
How to see whether it is allowed
Script execution needs platform, workspace, and member all satisfied before chat can run skill scripts. Check by role below.
Platform ops
In backend/mindlink.json (do not commit to Git):
"agent_script_tool": {
"enabled": true,
// ...
}
enabledistrueand the backend was restarted after the change → platform layer allows- Env
AGENT_SCRIPT_TOOL_ENABLED=1also works (overrides JSON) - If the platform is off, no agent site-wide can run scripts, regardless of whether the workspace card says “enabled”
Details: Server configuration §3.11.
Workspace admin
- Open
Workspace collaboration→ Assistant capability packs - See Script execution card status: Not enabled / Expired / Enabled
- Click the card to open settings (same layout as Network requests):
- Top Enable switch → whether the workspace allows - Left Workspace settings → validity, prerequisite notes - Left Member script grants → each member follows the workspace, is forbidden, or has a per-member grant
If a member “workspace is on but still cannot use it”, open that member under Member script grants and see whether they are Forbidden, or whether the matching skill is ticked under Per-member grant.
Ordinary member
- Same Assistant capability packs → Script execution card
- Click the card for details. Common prompts:
- Workspace not enabled or expired → you can submit a capability request - “This workspace has script execution enabled, but you are not yet authorized” → workspace on, person not granted - “You have a separate script-execution policy” → an admin configured you separately, possibly different from workspace default
- If the assistant in chat says it cannot run scripts, contact an admin per the table above, or see Common questions
Three-layer check (troubleshooting)
| Layer | Who configures | How to check |
|---|---|---|
| Platform | Ops | mindlink.json → agent_script_tool.enabled |
| Workspace | Admin | Assistant capability packs → Script execution → Enable + validity; Basic document tools must already be on |
| Member | Admin | Script execution dialog → Member script grants → that member’s grant mode |
Enable steps (admin)
1. Platform master switch
Ops in backend/mindlink.json (do not commit to Git):
"agent_script_tool": {
"enabled": true,
"timeout_sec": 60,
"max_output_bytes": 10485760,
},
Then restart the backend. Env AGENT_SCRIPT_TOOL_ENABLED=1 also works (overrides JSON).
If the platform is off, no agent site-wide can run scripts, regardless of the workspace.
2. Workspace capability pack
- Open
Workspace collaboration - Open Assistant capability packs → card Script execution
- Turn Enable on, set validity as needed
Prerequisites:
- Basic document tools must already be on (script products need to register as downloadable attachments)
- To read or edit existing Word/Excel/PPT attachments, also enable Office document read
3. Member script grants
In the Script execution settings dialog, left Member script grants (same layout as Network requests member pairing: member list left, detail right):
- Pick a member on the left, set grant mode on the right
| Grant mode | Meaning |
|---|---|
| Follow workspace | Usable once the workspace is enabled (default) |
| Forbidden | This member cannot run scripts even if the workspace is on |
| Per-member grant | Tick skills they may run (the skill must declare scripts and contain scripts/*.py); tick all means no skill limit; you can also control whether ad-hoc scripts are allowed |
Suggestions:
- Most members: Follow workspace
- HR, finance, and similar export-report roles: Per-member grant, tick only related skills (e.g. export Excel)
- Allow ad-hoc scripts is off by default; turn on only in high-trust scenes
Relation to skills
The agent does not run arbitrary code; all of these must be true:
- The member is granted script execution
- Chat hit a workspace skill that has scripts
- The skill body has ## Script execution, or the skill notes declare executable scripts
When creating a skill in Skills Center, tap Describe to create and pick script-first; after generate, edit scripts/ in the left file tree.
Writing requirements: How to write workspace skills §8.4.
What members see
- Granted: in chat they can ask the agent “export Excel per such-and-such skill”; on success they get a downloadable attachment
- Workspace on but not granted: the capability-pack dialog or the assistant in chat says contact an admin to configure Script execution → Member script grants
- Workspace not enabled: they can submit a request on the capability-pack page, or ask an admin to enable
Safety notes
- Scripts run in a restricted environment on the server (timeout, output-size cap, no network-class statements, etc.)
- Do not put secrets in scripts; talking to external systems still uses Network requests + Connection credentials
- Allow ad-hoc scripts is higher risk; off by default
Backend Python and dependencies (ops)
Scripts run on the machine hosting the Cadau backend process (not the user’s browser).
- Install Python 3.10+ and make sure
pythonorpy -3works on the command line. - Optional: set
MINDLINK_PYTHONto the interpreter absolute path (e.g.C:\Python312\python.exe). - A skill may declare dependencies in
scripts/requirements.txt; Cadau auto pip-installs allow-listed packages such as reportlab, pypdf, matplotlib, pillow into each run’s temp directory (.packages) — not the user’s local Python. .xlsx/.docx/.pptx/.pdf must not be produced by scripts; use office-document tools (office_document; PDF via build_pdf). - Change scripts in chat: the agent can use skill_script_read / skill_script_write to update
scripts/*.py(skill_update only changes the Markdown body); after change, run_script to verify; non-emptyoutput_filescounts as success. - One-tap seed default skills (workspace admin):
POST /api/v1/workspaces/{workspace-id}/seed-office-script-skillsidempotently creates presentation (ppt-deck-builder, via OfficeCLI) and simple PDF script skills; locally alsogo run ./cmd/seed-office-skills -workspace <id>. - Mainland networks: if auto-install reports
ConnectionResetError/No matching distribution found, set a pip mirror inmindlink.json, e.g.:
``json "agent_script_tool": { "pip_index_url": "https://pypi.tuna.tsinghua.edu.cn/simple" } ` or env MINDLINK_PIP_INDEX_URL (system PIP_INDEX_URL` also works). Then restart the backend.
- Installing system software, changing PATH/registry still needs ops by hand; if the agent sees
error_code=python_not_foundit should tell the user, not pretend a file was generated.
Common questions
| What you see | Check first |
|---|---|
| Assistant says it cannot run scripts / has no related capability | Platform agent_script_tool.enabled; workspace Script execution enabled |
| Workspace on, one member still cannot | Is that member Forbidden; or is the skill ticked under Per-member grant |
| Assistant says the skill did not declare scripts | Does the skill have scripts/*.py and body ## Script execution |
| Script error module not found (exit 9009 / ModuleNotFoundError) | Backend Python 3.10+ installed (Windows: python/py on PATH, or MINDLINK_PYTHON); Cadau auto pip installs allow-listed libs |
| pip install failed / ConnectionResetError / cannot reach PyPI from the mainland | Set agent_script_tool.pip_index_url or MINDLINK_PIP_INDEX_URL to a mainland mirror, restart backend |
| Cannot read a Word/Excel to edit | Has the workspace enabled Office document read |
| Can only export CSV, not xlsx/docx/pptx/pdf | Has the workspace enabled Office document tools; is the assistant using office_document (PDF via build_pdf, not run_script) |
| Cannot export PDF | Office document tools on; server has a Chinese .ttf (or MINDLINK_CHAT_EXPORT_FONT) |
Related docs
- Platform config: mindlink.json notes (
agent_script_toolsection) - Skills and scripts: How to write workspace skills
- Network and secrets (complements scripts): Member connection credentials
- Implementation (interop): repo docs/core-mechanisms/工作区能力包.md