Browse Source

fix: Codex 网关工具显示参数摘要;技能补充 reportlab 中文字体用法

- Codex 时间线中网关工具(MCP)的标题显示网址或"输入文件 → 格式"
- report-conventions:reportlab 生成中文 PDF 使用内置 CID 字体 STSong-Light,
  避免加载系统 Noto CJK(PostScript 轮廓,reportlab 不支持)反复失败

验收:生产环境 Codex 经网关完成 kb_list_roots、web_fetch、recalc_workbook、
convert_document,全程无额外审批;内网地址被拦截;读取并按官方 pdf 技能生成
中文 PDF

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Jerry Liang 1 tuần trước cách đây
mục cha
commit
542a6363be

+ 7 - 2
apps/server/src/providers/codex/adapter.ts

@@ -502,8 +502,13 @@ function describeTool(item: ThreadItem, cwd: string): { name: string; title: str
       return { name: 'Bash', title: commandTitle(item.command), input: { command: item.command, cwd: item.cwd } }
     case 'fileChange':
       return { name: 'Edit', title: item.changes.map(c => rel(c.path)).join('、').slice(0, 200), input: { changes: item.changes.map(c => ({ path: c.path, kind: c.kind, diff: c.diff })) } }
-    case 'mcpToolCall':
-      return { name: `mcp__${item.server}__${item.tool}`, title: '', input: item.arguments }
+    case 'mcpToolCall': {
+      // 标题取最有代表性的参数:网址 / 输入文件(及目标格式)
+      const a = (item.arguments ?? {}) as Record<string, unknown>
+      const title = typeof a.url === 'string' ? a.url
+        : typeof a.input === 'string' ? `${rel(a.input)}${typeof a.format === 'string' ? ` → ${a.format}` : ''}` : ''
+      return { name: `mcp__${item.server}__${item.tool}`, title, input: item.arguments }
+    }
     case 'webSearch':
       return { name: 'WebSearch', title: (item as { query?: string }).query ?? '', input: { query: (item as { query?: string }).query } }
     case 'imageView':

+ 6 - 0
skills/skills/report-conventions/SKILL.md

@@ -31,6 +31,12 @@ description: 生成数据分析报告、图表、Word/Excel/PDF 文档时的规
 - 表头加粗、冻结首行、调整列宽。
 
 ## PDF 与格式转换
+- 用 reportlab 直接生成中文 PDF 时,使用内置的 CID 字体,不要加载系统里的 Noto CJK(.ttc 为 PostScript 轮廓,reportlab 不支持):
+  ```python
+  from reportlab.pdfbase import pdfmetrics
+  from reportlab.pdfbase.cidfonts import UnicodeCIDFont
+  pdfmetrics.registerFont(UnicodeCIDFont('STSong-Light'))  # 之后在样式中使用 fontName='STSong-Light'
+  ```
 - 格式转换(docx/xlsx/pptx → pdf、doc → docx 等)**必须使用 `convert_document` 工具**。不要在 Bash 里调用 soffice/libreoffice(包括其他技能自带的 recalc.py、转换脚本),沙箱禁止它需要的进程通信,一定会失败。
 - 示例:`convert_document(input="outputs/Q3销售分析.docx", format="pdf")` 会生成 `outputs/Q3销售分析.pdf`。
 - 自检:用 `pdftoppm -png -r 60 <pdf> .agent/preview` 渲染预览图,再用 Read 工具查看版式。