fix: guide agent to a real public link instead of dead-ending on apps__create_app

Diagnosed via production session logs (RDS + shared goose PG) that some
users' page-generation attempts drifted: the agent used apps__create_app
(no public URL) then fabricated a placeholder domain when asked for a
link, and separately burned many turns scraping unreachable/anti-bot
search engines. Steer both flows toward the already-working path instead
of banning tools outright:

- apps__create_app is fine for designing/previewing a page, but the
  agent must still write_file the result into public/*.html per the
  static-page-publish skill and return a link built from the real
  public URL template (no invented domains)
- for real-world lookups, load_skill('web') first and prefer
  Bing/360 over retrying google.com or hammering anti-bot sites

Also folds in generate_docx guidance for Word-download attachments
(sandbox-fs tool) that landed in the same files during this pass.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
john
2026-07-01 14:11:09 +08:00
parent b273bb7aa2
commit 862824202f
4 changed files with 27 additions and 6 deletions
+11 -5
View File
@@ -141,7 +141,7 @@ description: 在专属 MindSpace 目录生成可公开访问的静态 HTML 报
1. **唯一可写目录**\`${publishDir}\`
2. **禁止**使用绝对路径(如 \`/Users/...\`\`../\` 跳出目录)
3. **允许**在本目录内使用 \`write_file\`\`edit_file\`\`read_file\`\`list_dir\`**禁止**访问此目录外的路径(含 \`../\`、其它用户目录、项目根目录;系统会在 OS 层拦截越界访问)
3. **允许**在本目录内使用 \`write_file\`\`edit_file\`\`read_file\`\`list_dir\`\`generate_docx\`**禁止**访问此目录外的路径(含 \`../\`、其它用户目录、项目根目录;系统会在 OS 层拦截越界访问)
4. **禁止**子 Agent、扩展管理、修改工作区外文件
5. 页面默认写入 \`public/\` 分区,使用相对路径如 \`public/report.html\`\`public/assets/chart.png\`
6. 生成 HTML 后,向用户提供可访问链接,格式:
@@ -155,12 +155,13 @@ description: 在专属 MindSpace 目录生成可公开访问的静态 HTML 报
3. 在 \`<head>\` 写入 **mindspace-cover** 元数据(见下文,必须与页面主题一致)
4. 页面内资源使用**相对路径**\`assets/foo.png\`),不要用磁盘绝对路径
5. 保存 HTML 后,服务端会**立即**生成同名预览图 \`<文件名>.thumbnail.svg\`(Agent 交互阶段即生效,无需等用户保存到「我的空间」)
6. 下载按钮的相对链接目标(如 \`public/report.docx\`)必须落盘且 basename 与 HTML 一致
6. 下载按钮的相对链接目标(如 \`public/report.docx\`)必须通过 \`generate_docx\` 落盘且 basename 与 HTML 一致
7. 完成后按「回复格式」返回可点击链接
## 伴生下载文件(必须)
- 相对路径下载链接(\`.docx\` / \`.pdf\` 等)必须在 HTML 同目录或子目录真实存在
- Word 文档必须用 sandbox-fs 的 \`generate_docx\` 生成;禁止用 \`computercontroller\` / shell 生成生产下载文件作为交付依据
- 改 HTML 文件名时同步 rename/copy 伴生文件;从 \`oa/\` 复制到 \`public/\` 再链接
- 可跑 \`node scripts/check-mindspace-public-links.mjs\` 自检
@@ -322,9 +323,10 @@ export function buildSandboxSessionConstraints({ baseConstraints, developerTools
'- 开始前执行 load_skill → `static-page-publish`,按技能说明写入 mindspace-cover 元数据',
'- 如果用户要求 Word / docx 下载:先 `load_skill` → `docx-generate`,生成并确认 `public/*.docx` 已存在,再写 HTML 用相对路径链接',
'- **禁止**用 shell / cat / heredoc / echo / cp 写入 HTMLshell 在容器内执行,文件不会出现在公网 MindSpace 路径',
'- 用 `apps__create_app` 设计页面时,最后仍要按 `static-page-publish` skill 把内容 write_file 落到 `public/`,才有公网链接',
'- **禁止**让用户手动保存到 public 或说无法生成页面(除非 write_file 调用失败)',
'- 完成后回复 `[页面标题](公网URL)` 可点击链接;写入 `public/` 时 URL 必须含 `/public/` 路径段',
'- 下载附件:相对链接文件必须已在 `public/` 落盘,basename 与 HTML 一致',
'- 完成后回复 `[页面标题](公网URL)` 可点击链接;写入 `public/` 时 URL 必须含 `/public/` 路径段;按本会话给出的公网前缀模板拼接真实地址',
'- 下载附件:Word 用 `generate_docx` 写入 `public/*.docx`相对链接文件必须已在 `public/` 落盘,basename 与 HTML 一致',
);
return lines.join('\n');
}
@@ -347,7 +349,11 @@ export function buildPublishConstraints({ slug, username, publicBaseUrl, publish
'- **用户可见回复**:不要向用户复述 load_skill、技能更新、页脚标记、mindspace-cover 等内部实现;完成后直接给出页面链接或结果',
'- **禁止**用 shell 写入 HTML**禁止**让用户「手动保存到 public 目录」或说「我无法生成页面」——除非 write_file 已失败并报告错误',
'- 完成后给出 Markdown 可点击公网链接 `[标题](URL)`;写入 `public/页面.html` 时 URL 为 `.../MindSpace/<用户ID>/public/页面.html`',
'- 下载链接(如 `report.docx`)必须与 HTML 同目录且文件名一致',
'- 若先用 `apps__create_app` 设计/预览,最后仍要把内容 write_file 落到 `public/页面.html` 才有公网链接',
'- **需要查实时/真实世界信息时**:先 `load_skill` → `web`,优先 `web_search`/`fetch_url`;国内 google.com 不可达,多次无果时改走 Bing/360 等可达搜索源',
'- **禁止**让用户「手动保存到 public 目录」或说「我无法生成页面」——除非 write_file 已失败并报告错误',
'- 完成后给出 Markdown 可点击公网链接 `[标题](URL)`;写入 `public/页面.html` 时 URL 为 `.../MindSpace/<用户ID>/public/页面.html`,按模板拼真实地址',
'- 下载链接(如 `report.docx`)必须与 HTML 同目录且文件名一致;Word 必须用 sandbox-fs `generate_docx` 生成,不要用 `computercontroller` / shell 作为交付依据',
`- 发布技能:\`${PUBLISH_SKILL_NAME}\`(生成页面前应 load_skill`,
].join('\n');
}