Files
deepseek-harness/scripts/fixtures/python-sdk-office.mjs
T
yudshj 50ba635949 feat(office): Office 操作改为常驻的原生 office 工具
- 新包 @deepseek-ai/dsh-tool-office 提供常驻的 office 工具(render / convert / recalculate),由 office-kit 在 Host 中直接调用 Kit 的 JS API;标准模式与 PTC 通过同一个工具调用
- render 的页面图片直接进入工具结果(有数量、像素与字节上限);convert / recalculate 的结果写入 office-kit 按 Session 划分的私有输出目录,由模型用 shell 复制到工作区,fs 与 Host 代码不写用户工作区
- 删除为 shell 执行 Kit CLI 而存在的代码:skill-office 的 node / cli / kitRoot、resolveKitCli、DSH_BUNDLED_OFFICE_CLI / DSH_BUNDLED_OFFICE_NODE / DSH_BUNDLED_RUNTIME_ROOT 与 Electron 下的独立 Node 检查;打包 smoke 改为经 office-kit 真实渲染、转换与重算
- office 由 web-app 的 standard / ptc 预设与 sdk-app 挂载,minimal 不挂载;操作技能正文与目录描述指向 office 工具
- 新增 Agent Note,部分取代 progressive-office-skills 的 shell 执行决定;同步 README、子系统页、catalog 与升级指南(含已保存预设的迁移步骤)

本 PR 的 snapshot 统一在这个提交里重新生成,前 4 个提交中的 snapshot 不一定和那一步的代码对应。
2026-11-04 18:17:58 +08:00

26 lines
1.4 KiB
JavaScript

/** Exercise the downloaded sidecar's Kit through the Host Office kit and directly from a shipped profile. */
import { copyFile, readFile, writeFile } from 'node:fs/promises'
import { createConverter } from '@deepseek-ai/libreoffice-kit'
export const name = 'python-sdk-office-smoke'
export async function apply(ctx, config) {
const bytes = await readFile(config.input)
const converted = await ctx.officeKit.convertTo({
extension: 'docx', format: 'pdf', priority: 'foreground',
source: { key: 'python-sdk-office-smoke', version: 'fixture', bytes: bytes.length, async read() { return { bytes, version: 'fixture' } } },
output: { owner: 'python-sdk-office-smoke', name: 'service.pdf' },
})
await copyFile(converted.path, config.output + '.service.pdf')
const pdf = await readFile(config.output + '.service.pdf')
if (pdf.subarray(0, 5).toString() !== '%PDF-') throw new Error('Office kit service did not create a PDF')
const converter = await createConverter({ timeoutMs: 120_000 })
try {
const result = await converter.render({ inputPath: config.input, outputPath: config.output })
const images = await converter.renderImages({ inputPath: config.imageInput, outputDir: config.imageOutput, pages: [1], dpi: 72 })
await writeFile(config.result, JSON.stringify({ ...result, images, moduleUrl: import.meta.resolve('@deepseek-ai/libreoffice-kit') }))
} finally {
await converter.dispose()
}
}