Extract memind_adm admin server, add local dev tooling, and remove image-generation.
Split platform admin and ops APIs into standalone admin-server.mjs with network guards; simplify billing to RMB token pricing, refactor user auth, and add rsync deploy plus local-test scripts and docs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+26
-17
@@ -124,7 +124,7 @@ description: 在专属 MindSpace 目录生成可公开访问的静态 HTML 报
|
||||
|
||||
1. **唯一可写目录**:\`${publishDir}\`
|
||||
2. **禁止**使用绝对路径(如 \`/Users/...\`、\`../\` 跳出目录)
|
||||
3. **允许**在本目录内使用 \`write\`、\`edit\`、\`shell\`、\`tree\`;**禁止**访问此目录外的路径(含 \`../\`、其它用户目录、项目根目录)
|
||||
3. **允许**在本目录内使用 \`write_file\`、\`edit_file\`、\`read_file\`、\`list_dir\`;**禁止**访问此目录外的路径(含 \`../\`、其它用户目录、项目根目录;系统会在 OS 层拦截越界访问)
|
||||
4. **禁止**子 Agent、扩展管理、修改工作区外文件
|
||||
5. 页面默认写入 \`public/\` 分区,使用相对路径如 \`public/report.html\`、\`public/assets/chart.png\`
|
||||
6. 生成 HTML 后,向用户提供可访问链接,格式:
|
||||
@@ -134,7 +134,7 @@ description: 在专属 MindSpace 目录生成可公开访问的静态 HTML 报
|
||||
## 推荐工作流
|
||||
|
||||
1. 确认需求(标题、章节、是否要图表/样式)
|
||||
2. 使用 \`write\` 创建 \`public/页面.html\`(可含内联 CSS;需要时在 \`public/assets/\` 或工作区 \`assets/\` 放资源)
|
||||
2. 使用 \`write_file\` 创建 \`public/页面.html\`(可含内联 CSS;需要时在 \`public/assets/\` 或工作区 \`assets/\` 放资源)
|
||||
3. 在 \`<head>\` 写入 **mindspace-cover** 元数据(见下文,必须与页面主题一致)
|
||||
4. 页面内资源使用**相对路径**(\`assets/foo.png\`),不要用磁盘绝对路径
|
||||
5. 保存 HTML 后,服务端会**立即**生成同名预览图 \`<文件名>.thumbnail.svg\`(Agent 交互阶段即生效,无需等用户保存到「我的空间」)
|
||||
@@ -190,7 +190,7 @@ description: 在专属 MindSpace 目录生成可公开访问的静态 HTML 报
|
||||
|
||||
## 查找文件(CSV、文档等)
|
||||
|
||||
- 只在**当前工作区**内从 \`.\` 搜索(如 \`find . -name '*.csv'\`、\`tree .\`、\`rg\`)
|
||||
- 只在**当前工作区**内从 \`.\` 搜索(如 \`list_dir\`、\`list_dir oa\`,或 shell 可用时 \`find . -name '*.csv'\`)
|
||||
- 用户说的「OA 区」等视为工作区**子目录**(如 \`oa/\`),用相对路径查找
|
||||
- **禁止**搜索上级目录、其它用户目录、\`${PUBLISH_ROOT_DIR}\` 根目录、\`/Users\`、项目根目录
|
||||
- 找不到时告知用户上传或提供相对路径,**不要**扩大到工作区外
|
||||
@@ -205,7 +205,7 @@ description: 在专属 MindSpace 目录生成可公开访问的静态 HTML 报
|
||||
用户:「写一份越南旅游指南网页」
|
||||
|
||||
正确做法:
|
||||
- \`write\` → \`public/vietnam-guide.html\`(内容完整)
|
||||
- \`write_file\` → \`public/vietnam-guide.html\`(内容完整)
|
||||
- 回复链接:\`${buildPublicZonePageUrl(publicBaseUrl, slug, 'vietnam-guide.html')}\`
|
||||
`;
|
||||
}
|
||||
@@ -220,7 +220,7 @@ export function renderWorkspaceHints({ slug, username, publishDir, displayName }
|
||||
${renderBrandingBlock(addressName)}
|
||||
## 查找 / 读取文件(CSV、文档、OA 区等)
|
||||
|
||||
1. **只能**在本工作区内、从 \`.\` 开始搜索,例如 \`tree .\`、\`find . -name '*.csv'\`、\`rg keyword .\`
|
||||
1. **只能**在本工作区内搜索,例如 \`list_dir\`、\`list_dir oa\`,或 shell 可用时 \`find . -name '*.csv'\`、\`rg keyword .\`
|
||||
2. 用户说的「OA 区」「文档区」等,**先当作工作区内的子目录**(如 \`oa/\`、\`docs/\`),只用相对路径查找
|
||||
3. **绝对禁止**:
|
||||
- 去上级目录、\`${PUBLISH_ROOT_DIR}\` 根目录、其它用户名目录、项目根目录搜索
|
||||
@@ -238,14 +238,22 @@ ${renderBrandingBlock(addressName)}
|
||||
}
|
||||
|
||||
export function buildSandboxSessionConstraints({ baseConstraints, developerTools = [] }) {
|
||||
const tools = developerTools.length > 0 ? developerTools : ['write', 'edit'];
|
||||
const tools = developerTools.length > 0 ? developerTools : ['write_file', 'edit_file'];
|
||||
const hasSandboxMcp = tools.includes('write_file') || tools.includes('read_file');
|
||||
const hasShell = tools.includes('shell');
|
||||
const hasListDir = tools.includes('list_dir') || tools.includes('tree');
|
||||
|
||||
const lines = [
|
||||
baseConstraints,
|
||||
'',
|
||||
'## 当前会话可用 developer 工具',
|
||||
'## 当前会话可用文件工具',
|
||||
`- ${tools.join(', ')}`,
|
||||
];
|
||||
if (tools.includes('shell')) {
|
||||
hasSandboxMcp
|
||||
? '- 文件工具由**沙箱 MCP** 提供:所有路径在 OS 层强制限制在工作区内,越界访问会立即报错'
|
||||
: '',
|
||||
].filter((l) => l !== '');
|
||||
|
||||
if (hasShell) {
|
||||
lines.push(
|
||||
'- **shell 已开启**:只能在本工作区内执行(如 `ls oa/`、`find . -name "*.csv"`、`cat oa/文件.csv`)',
|
||||
'- **禁止** curl/wget 或访问公网 URL 来读取工作区文件',
|
||||
@@ -253,18 +261,19 @@ export function buildSandboxSessionConstraints({ baseConstraints, developerTools
|
||||
} else {
|
||||
lines.push(
|
||||
'- **shell 未开启**:不能执行 shell;也不要用公网 URL 代替本地读文件',
|
||||
'- 需要列目录或读 CSV 时,请用户开启 shell 能力或上传文件内容',
|
||||
);
|
||||
}
|
||||
if (tools.includes('tree')) {
|
||||
lines.push('- **tree 已开启**:`tree .` 或 `tree oa/` 查看目录结构');
|
||||
if (hasListDir) {
|
||||
lines.push('- **list_dir 可用**:`list_dir` 或 `list_dir oa` 查看目录结构');
|
||||
} else {
|
||||
lines.push('- 需要列目录或读 CSV 时,请用户上传文件内容或开启 list_dir 能力');
|
||||
}
|
||||
lines.push(
|
||||
'',
|
||||
'## 生成 / 发布 HTML 页面',
|
||||
'- 你有 write/edit 工具:**必须由你**写入 `public/xxx.html`(或工作区根目录 `.html`)',
|
||||
'- 你有 write_file/edit_file 工具:**必须由你**写入 `public/xxx.html`(或工作区根目录 `.html`)',
|
||||
'- 开始前执行 load_skill → `static-page-publish`,按技能说明写入 mindspace-cover 元数据',
|
||||
'- **禁止**让用户手动保存到 public 或说无法生成页面(除非 write 调用失败)',
|
||||
'- **禁止**让用户手动保存到 public 或说无法生成页面(除非 write_file 调用失败)',
|
||||
'- 完成后回复 `[页面标题](公网URL)` 可点击链接;写入 `public/` 时 URL 必须含 `/public/` 路径段',
|
||||
);
|
||||
return lines.join('\n');
|
||||
@@ -282,9 +291,9 @@ export function buildPublishConstraints({ slug, username, publicBaseUrl, publish
|
||||
`- 公网 HTML 前缀(公开区页面):\`${buildPublicUrl(publicBaseUrl, slug, `${PUBLIC_ZONE_DIR}/`)}\``,
|
||||
'- **查找文件**:在工作区内对应分区搜索(如 `oa/2025-12-06T13-34_export.csv`),不要搜其它用户目录或公网 URL',
|
||||
'- **禁止**:访问 `assets/` 内部路径、其它用户目录、主机绝对路径;禁止用公网 URL 列目录或读 CSV',
|
||||
'- **路径规则**:只用相对路径;禁止 `../`;越界 shell/tree/write/edit 会被拒绝',
|
||||
'- **生成页面(必须亲自完成)**:先 `load_skill` → `static-page-publish`,再用 `write`/`edit` 写入 `public/页面.html`',
|
||||
'- **禁止**让用户「手动保存到 public 目录」或说「我无法生成页面」——除非 write 已失败并报告错误',
|
||||
'- **路径规则**:只用相对路径;禁止 `../`;工作区外的路径会被系统拒绝(OS 层强制,非软约束)',
|
||||
'- **生成页面(必须亲自完成)**:先 `load_skill` → `static-page-publish`,再用 `write_file`/`edit_file` 写入 `public/页面.html`',
|
||||
'- **禁止**让用户「手动保存到 public 目录」或说「我无法生成页面」——除非 write_file 已失败并报告错误',
|
||||
'- 完成后给出 Markdown 可点击公网链接 `[标题](URL)`;写入 `public/页面.html` 时 URL 为 `.../MindSpace/<用户ID>/public/页面.html`',
|
||||
`- 发布技能:\`${PUBLISH_SKILL_NAME}\`(生成页面前应 load_skill)`,
|
||||
].join('\n');
|
||||
|
||||
Reference in New Issue
Block a user