refactor(office): office 工具拆成 office_render/office_convert/office_recalculate,加载 Office 技能后按需声明

- tool-office 注册三个工具,参数规则由各自 schema 表达,运行时拒绝其他工具的参数
- 三个工具共用 when:本 agent 成功加载过 activationSkills 中的技能(内存标记),或上一次请求头已声明 office_*;加载后下一步声明,之后不移除
- Office 技能改用新工具名,加入工具不可用时重新加载 office 的说明和旧格式先转换的说明
- Client 卡片按工具名分派,图片子槽改为 tool.call.office_render.images
- 删除未发布 office 工具的两份升级指南,新增 office-operation-tools 指南,只记录已发布版本的变化
- 刷新 catalog、snapshot、SDK expected 与 Agent Note
This commit is contained in:
yudshj committed 2026-11-04 18:17:59 +08:00
1 parent dce403d575
commit edd38f1d66
153 files changed
+3675 -1801

No files matched your search

@@ -9,8 +9,8 @@
en: a9984a594cdac98d
zh: 38768e7699bc8d39
/agent-note-progressive-office-skills-with-ordinary-shell-execution/decision:
en: ca266170f3fe00c0
zh: d1e6ce70971b7cfc
en: 391c5d75994ab7e7
zh: f820f407eb2d8769
/agent-note-progressive-office-skills-with-ordinary-shell-execution/alternatives-considered:
en: 0689e709dc1ff48d
zh: 5d2108ccdd13f093
@@ -11,7 +11,7 @@ Combined authoring and rendering instructions spend context on operations unrela
## Decision
The [Office provider](../../../../packages/skill/skill-office/README.md) lists a compact router and three format-specific authoring skills; the operation skills this decision introduced are replaced by the [resident office tool](2026-10-31-native-office-tool.md). The model loads full instructions by name and selects rendering for appearance-focused changes unless the user explicitly skips it. Rendering uses a private, randomly named temporary directory inside the task workspace and removes it after inspection. Skills invoke the shared Python checker and configured LibreOffice Kit CLI through ordinary Bash or PowerShell. SDK and Desktop own their Office composition separately; ordinary Web and the shared base do not mount these plugins. [Office skills in every deployment](2026-10-26-cross-deployment-office-kit.md) supersedes this mounting decision, and the [resident office tool](2026-10-31-native-office-tool.md) supersedes the shell execution and renderer-tool rejection.
The [Office provider](../../../../packages/skill/skill-office/README.md) lists a compact router and three format-specific authoring skills; the operation skills this decision introduced are replaced by the [on-demand Office tools](2026-10-31-native-office-tool.md). The model loads full instructions by name and selects rendering for appearance-focused changes unless the user explicitly skips it. Rendering uses a private, randomly named temporary directory inside the task workspace and removes it after inspection. Skills invoke the shared Python checker and configured LibreOffice Kit CLI through ordinary Bash or PowerShell. SDK and Desktop own their Office composition separately; ordinary Web and the shared base do not mount these plugins. [Office skills in every deployment](2026-10-26-cross-deployment-office-kit.md) supersedes this mounting decision, and the [on-demand Office tools](2026-10-31-native-office-tool.md) supersede the shell execution and renderer-tool rejection.
Carriers own interpreter and resource locations. Operation skills append the configured Node and CLI paths only when their bodies are loaded; authoring skills use the selected Python and shared checker resource. Loading instructions does not prepare engines or authoring payloads. Ordinary shell execution retains its existing permissions and process management.
@@ -11,7 +11,7 @@ Status: implemented
## 决策
[Office 提供者](../../../../packages/skill/skill-office/README.zh.md) 列出精简路由和三个各格式创作技能;本决策引入的操作技能已由[常驻 office 工具](2026-10-31-native-office-tool.zh.md)取代。模型按名称加载完整说明;以外观为目标的修改会选择渲染,除非用户明确要求跳过。渲染使用任务工作区内随机命名的私有临时目录,并在检查后删除。技能通过普通 Bash 或 PowerShell 调用共享 Python 检查器和配置的 LibreOffice Kit CLI。SDK 和 Desktop 分别拥有 Office 组合;普通 Web 和共享 base 不挂载这些插件。[Office 技能在所有部署中可用](2026-10-26-cross-deployment-office-kit.zh.md)取代此挂载决策,[常驻 office 工具](2026-10-31-native-office-tool.zh.md)取代其 shell 执行方式和对渲染工具的否决。
[Office 提供者](../../../../packages/skill/skill-office/README.zh.md) 列出精简路由和三个各格式创作技能;本决策引入的操作技能已由[按需激活的 Office 工具](2026-10-31-native-office-tool.zh.md)取代。模型按名称加载完整说明;以外观为目标的修改会选择渲染,除非用户明确要求跳过。渲染使用任务工作区内随机命名的私有临时目录,并在检查后删除。技能通过普通 Bash 或 PowerShell 调用共享 Python 检查器和配置的 LibreOffice Kit CLI。SDK 和 Desktop 分别拥有 Office 组合;普通 Web 和共享 base 不挂载这些插件。[Office 技能在所有部署中可用](2026-10-26-cross-deployment-office-kit.zh.md)取代此挂载决策,[按需激活的 Office 工具](2026-10-31-native-office-tool.zh.md)取代其 shell 执行方式和对渲染工具的否决。
载体负责解释器和资源位置。操作技能仅在加载正文时附加配置的 Node 与 CLI 路径;创作技能使用选定的 Python 和共享检查器资源。加载说明不准备引擎或创作 payload。普通 shell 执行保留现有权限和进程管理。
@@ -9,11 +9,11 @@
en: 129d30508926bbc5
zh: 15feff44556fc9b7
/agent-note-office-skills-in-every-deployment-with-one-office-kit-package/decision:
en: 40a77b9f1ace9a76
zh: e062b495b9ca174c
en: 1f3d54764b002e44
zh: a9180e274648898c
/agent-note-office-skills-in-every-deployment-with-one-office-kit-package/alternatives-considered:
en: dbf6832a4ba0107d
zh: b707f4c3bef6a7bc
/agent-note-office-skills-in-every-deployment-with-one-office-kit-package/consequences:
en: a702df43df882786
zh: 48e35d930672b174
en: bd68079f92d2d06f
zh: 547b29beee76fc52
@@ -10,15 +10,15 @@ Office skills were mounted only by Desktop and the Python SDK, so ordinary `dsh
## Decision
The [Web bundle](../../../../packages/bundle/web-app/cordis.patch.yml) and the [SDK bundle](../../../../packages/bundle/sdk-app/cordis.patch.yml) mount [`skill-office`](../../../../packages/skill/skill-office/README.md) in Desktop, ordinary `dsh web`, and the SDK. This supersedes the mounting decision of [progressive Office skills](2026-09-27-progressive-office-skills.md); its skill structure remains current, and the [resident office tool](2026-10-31-native-office-tool.md) replaces its shell execution.
The [Web bundle](../../../../packages/bundle/web-app/cordis.patch.yml) and the [SDK bundle](../../../../packages/bundle/sdk-app/cordis.patch.yml) mount [`skill-office`](../../../../packages/skill/skill-office/README.md) in Desktop, ordinary `dsh web`, and the SDK. This supersedes the mounting decision of [progressive Office skills](2026-09-27-progressive-office-skills.md); its skill structure remains current, and the [on-demand Office tools](2026-10-31-native-office-tool.md) replace its shell execution.
The bundled Python environment ([`tool-workspace-dependencies`](../../../../packages/skill/tool-workspace-dependencies/README.md)) mounts only in Desktop and in the SDK when a primary runtime is available. `skill-office` declares `pythonEnvironment: 'workspace-dependencies' | 'user'` explicitly; each bundle row selects the value for its deployment. The default is `'workspace-dependencies'` because older SDK patches replace the complete `config` of the `skill-office` row; such a patch omits the new key and keeps the bundled-environment instructions it was written for.
[`@deepseek-ai/dsh-office-kit`](../../../../packages/document/office-kit/README.md) owns Kit location and the shared conversion service. Its `/locate` entry accepts only explicit arguments: the consumer's own `import.meta.resolve` lookup. Native engine paths use ASAR-unpacked mapping. It reads no environment variables, and the entry imports only Node built-in modules as values, so a consumer can depend on it without loading Cordis services, Schemastery, or Kit. The [resident office tool](2026-10-31-native-office-tool.md) runs Kit operations inside the Host, so no deployment publishes Kit CLI paths or Office executable variables.
[`@deepseek-ai/dsh-office-kit`](../../../../packages/document/office-kit/README.md) owns Kit location and the shared conversion service. Its `/locate` entry accepts only explicit arguments: the consumer's own `import.meta.resolve` lookup. Native engine paths use ASAR-unpacked mapping. It reads no environment variables, and the entry imports only Node built-in modules as values, so a consumer can depend on it without loading Cordis services, Schemastery, or Kit. The [on-demand Office tools](2026-10-31-native-office-tool.md) run Kit operations inside the Host, so no deployment publishes Kit CLI paths or Office executable variables.
An absent Kit degrades instead of failing a load. The conversion service registers and rejects conversions with code `unavailable`, retaining only a successful Kit import and reporting each distinct failure once; the `office` tool stays registered and returns that message.
An absent Kit degrades instead of failing a load. The conversion service registers and rejects conversions with code `unavailable`, retaining only a successful Kit import and reporting each distinct failure once; the `office_render`, `office_convert`, and `office_recalculate` tools stay registered and return that message when called.
`office-to-pdf` became `office-kit` so that later Kit consumers, such as native rendering (PR #5374) and the `office` tool, take Kit from one package. LibreOffice Kit dependencies declare one exact version in every manifest, so the converter and packaged engine come from the same Kit release.
`office-to-pdf` became `office-kit` so that later Kit consumers, such as native rendering (PR #5374) and the `tool-office` package, take Kit from one package. LibreOffice Kit dependencies declare one exact version in every manifest, so the converter and packaged engine come from the same Kit release.
## Alternatives considered
@@ -34,8 +34,8 @@ An absent Kit degrades instead of failing a load. The conversion service registe
## Consequences
Ordinary Web and SDK sessions without a bundled environment list the four Office skills, which adds their summaries to the first context. Deployments without Kit see `unavailable` previews and an `office` tool that reports the missing Kit instead of failing at startup; skill loading does not check for Kit; a later Kit installation takes effect for conversion without reloading the provider. External compositions migrate from the `office-to-pdf` row, `ctx.officeToPdf`, and the `officeToPdf/*` Remote methods to the `office-kit` package through the [upgrade guide](../../../../docs/upgrade-guide/v0.2.2-alpha.2/office-kit-package/guide.md).
Ordinary Web and SDK sessions without a bundled environment list the four Office skills, which adds their summaries to the first context. Deployments without Kit see `unavailable` previews and `office_*` tools that report the missing Kit instead of failing at startup; skill loading does not check for Kit; a later Kit installation takes effect for conversion without reloading the provider. External compositions migrate from the `office-to-pdf` row, `ctx.officeToPdf`, and the `officeToPdf/*` Remote methods to the `office-kit` package through the [upgrade guide](../../../../docs/upgrade-guide/v0.2.2-alpha.2/office-kit-package/guide.md).
Processes launched from the Desktop built-in terminal inherit `DSH_PRIMARY_RUNTIME`, so the SDK uses its bundled environment. The shell publishes no Kit location; child applications resolve their own Kit.
Verification covers the `/locate` import restriction, Kit lookup and engine resolution, conversion retry after a missing or unloadable Kit, deduplicated warnings, the `office` tool's `unavailable` result with an absent Kit, recorded Web and SDK sessions that list the Office skills, and Office profile end-to-end tests.
Verification covers the `/locate` import restriction, Kit lookup and engine resolution, conversion retry after a missing or unloadable Kit, deduplicated warnings, the `office_*` tools' `unavailable` results with an absent Kit, recorded Web and SDK sessions that list the Office skills, and Office profile end-to-end tests.
@@ -10,15 +10,15 @@ Status: implemented
## 决策
[Web bundle](../../../../packages/bundle/web-app/cordis.patch.yml) 和 [SDK bundle](../../../../packages/bundle/sdk-app/cordis.patch.yml) 在 Desktop、普通 `dsh web` 和 SDK 中都挂载 [`skill-office`](../../../../packages/skill/skill-office/README.zh.md)。这取代了[渐进式 Office 技能](2026-09-27-progressive-office-skills.zh.md)中的挂载决策;其技能结构仍然有效,[常驻 office 工具](2026-10-31-native-office-tool.zh.md)取代了其 shell 执行方式。
[Web bundle](../../../../packages/bundle/web-app/cordis.patch.yml) 和 [SDK bundle](../../../../packages/bundle/sdk-app/cordis.patch.yml) 在 Desktop、普通 `dsh web` 和 SDK 中都挂载 [`skill-office`](../../../../packages/skill/skill-office/README.zh.md)。这取代了[渐进式 Office 技能](2026-09-27-progressive-office-skills.zh.md)中的挂载决策;其技能结构仍然有效,[按需激活的 Office 工具](2026-10-31-native-office-tool.zh.md)取代了其 shell 执行方式。
内置 Python 环境([`tool-workspace-dependencies`](../../../../packages/skill/tool-workspace-dependencies/README.zh.md))只在 Desktop 以及有主运行时的 SDK 中挂载。`skill-office` 显式声明 `pythonEnvironment: 'workspace-dependencies' | 'user'`,由各 bundle 的配置行按部署选择取值。默认值为 `'workspace-dependencies'`,因为旧 SDK patch 会整体替换 `skill-office` 行的 `config`;这样的 patch 不含新键,仍保留它所针对的内置环境说明。
[`@deepseek-ai/dsh-office-kit`](../../../../packages/document/office-kit/README.zh.md) 负责 Kit 定位和共享转换服务。其 `/locate` 入口只接收显式参数:消费方自己的 `import.meta.resolve` 查找函数。原生引擎路径使用 ASAR 解包映射。它不读取环境变量,且入口只以值的形式导入 Node 内置模块,因此消费方可以依赖它而不加载 Cordis 服务、Schemastery 或 Kit。[常驻 office 工具](2026-10-31-native-office-tool.zh.md)在 Host 内执行 Kit 操作,因此任何部署都不发布 Kit CLI 路径或 Office 可执行文件变量。
[`@deepseek-ai/dsh-office-kit`](../../../../packages/document/office-kit/README.zh.md) 负责 Kit 定位和共享转换服务。其 `/locate` 入口只接收显式参数:消费方自己的 `import.meta.resolve` 查找函数。原生引擎路径使用 ASAR 解包映射。它不读取环境变量,且入口只以值的形式导入 Node 内置模块,因此消费方可以依赖它而不加载 Cordis 服务、Schemastery 或 Kit。[按需激活的 Office 工具](2026-10-31-native-office-tool.zh.md)在 Host 内执行 Kit 操作,因此任何部署都不发布 Kit CLI 路径或 Office 可执行文件变量。
Kit 缺失时降级,而不是加载失败。转换服务照常注册,以代码 `unavailable` 拒绝转换,只保留成功的 Kit 导入,并对每种不同的失败只报告一次;`office` 工具保持注册并返回该消息。
Kit 缺失时降级,而不是加载失败。转换服务照常注册,以代码 `unavailable` 拒绝转换,只保留成功的 Kit 导入,并对每种不同的失败只报告一次;`office_render`、`office_convert` 和 `office_recalculate` 工具保持注册并在调用时返回该消息。
`office-to-pdf` 改为 `office-kit`,使后续的 Kit 消费方(例如原生渲染(PR #5374)和 `office` 工具)从同一个包获取 Kit。LibreOffice Kit 依赖在每个清单中声明同一个精确版本,因此转换器和打包的引擎来自同一个 Kit 发行版。
`office-to-pdf` 改为 `office-kit`,使后续的 Kit 消费方(例如原生渲染(PR #5374)和 `tool-office` 包)从同一个包获取 Kit。LibreOffice Kit 依赖在每个清单中声明同一个精确版本,因此转换器和打包的引擎来自同一个 Kit 发行版。
## 考虑过的替代方案
@@ -34,8 +34,8 @@ Kit 缺失时降级,而不是加载失败。转换服务照常注册,以代
## 影响
没有内置环境的普通 Web 和 SDK 会话会列出四个 Office 技能,首个上下文因此增加它们的摘要。没有 Kit 的部署看到的是 `unavailable` 预览和报告 Kit 缺失的 `office` 工具,而不是启动失败;加载技能时不检查 Kit;之后安装的 Kit 无需重新加载提供方即可用于转换。外部组合按[升级指南](../../../../docs/upgrade-guide/v0.2.2-alpha.2/office-kit-package/guide.zh.md)从 `office-to-pdf` 配置行、`ctx.officeToPdf` 和 `officeToPdf/*` Remote 方法迁移到 `office-kit` 包。
没有内置环境的普通 Web 和 SDK 会话会列出四个 Office 技能,首个上下文因此增加它们的摘要。没有 Kit 的部署看到的是 `unavailable` 预览和报告 Kit 缺失的 `office_*` 工具,而不是启动失败;加载技能时不检查 Kit;之后安装的 Kit 无需重新加载提供方即可用于转换。外部组合按[升级指南](../../../../docs/upgrade-guide/v0.2.2-alpha.2/office-kit-package/guide.zh.md)从 `office-to-pdf` 配置行、`ctx.officeToPdf` 和 `officeToPdf/*` Remote 方法迁移到 `office-kit` 包。
从 Desktop 内置终端启动的进程会继承 `DSH_PRIMARY_RUNTIME`,因此 SDK 使用其内置环境。Desktop 壳不发布 Kit 位置;子应用自行解析自己的 Kit。
验证覆盖 `/locate` 的导入限制、Kit 查找与引擎解析、Kit 缺失或无法加载后的转换重试、去重后的警告、Kit 缺失时 `office` 工具的 `unavailable` 结果、列出 Office 技能的录制 Web 与 SDK 会话,以及 Office profile 端到端测试。
验证覆盖 `/locate` 的导入限制、Kit 查找与引擎解析、Kit 缺失或无法加载后的转换重试、去重后的警告、Kit 缺失时 `office_*` 工具的 `unavailable` 结果、列出 Office 技能的录制 Web 与 SDK 会话,以及 Office profile 端到端测试。
@@ -2,18 +2,18 @@
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write .agents/notes/implemented/architecture/2026-10-31-native-office-tool.md
/agent-note-resident-office-tool-for-office-operations:
en: d18369e036d521f8
zh: 2e9c79f1fe787279
/agent-note-resident-office-tool-for-office-operations/problem:
/agent-note-on-demand-office-tools-for-rendering-conversion-and-recalculation:
en: ac1af3d918f27b6f
zh: 5822ce52c384fca3
/agent-note-on-demand-office-tools-for-rendering-conversion-and-recalculation/problem:
en: 5b23962ecc835664
zh: c96ea8720ebc9419
/agent-note-resident-office-tool-for-office-operations/decision:
en: 08f0097bec154750
zh: bcb8cddac23970b5
/agent-note-resident-office-tool-for-office-operations/alternatives-considered:
en: e8ec6e98b9e3c60a
zh: 4b104c91af5b9ae9
/agent-note-resident-office-tool-for-office-operations/consequences:
en: 210b60b1e11344b5
zh: 81d4a125798599d6
/agent-note-on-demand-office-tools-for-rendering-conversion-and-recalculation/decision:
en: fe1ab9e63c616118
zh: 9a31307d1f8359cb
/agent-note-on-demand-office-tools-for-rendering-conversion-and-recalculation/alternatives-considered:
en: f36e8534958e5a46
zh: 96a3876a26a9d9ac
/agent-note-on-demand-office-tools-for-rendering-conversion-and-recalculation/consequences:
en: 8ea5f5c493dfae3d
zh: 29d7160bd3f98512
@@ -1,4 +1,4 @@
# Agent Note: Resident office tool for Office operations
# Agent Note: On-demand Office tools for rendering, conversion, and recalculation
Status: implemented
@@ -10,13 +10,13 @@ Office operation skills ran the LibreOffice Kit CLI through ordinary shell comma
## Decision
The [`office` tool](../../../../packages/document/tool-office/README.md) exposes `render`, `convert`, and `recalculate` as one resident Host tool. It calls the [Office kit](../../../../packages/document/office-kit/README.md) service, which loads Kit in the Host process through `/locate` and runs every operation through the queue, concurrency limits, byte reservations, and cache that Office previews use. Tool requests use `foreground` priority, the class of an open preview, so background prewarming cannot starve them. The SDK composition mounts the tool beside `office-kit`, and the Web bundle's standard and PTC agent presets mount it while its minimal preset keeps its fixed roster; when Kit is missing the tool stays registered and every call returns the service's `unavailable` message. The tool reads the service at each call instead of injecting it, so a composition that omits or disables `office-kit` still creates Sessions with the tool and each call fails as `unavailable`; a service loaded later serves the next call. Standard and PTC modes reach the same registration; nested PTC calls re-enter the ordinary execution pipeline.
The [`tool-office` package](../../../../packages/document/tool-office/README.md) exposes `office_render`, `office_convert`, and `office_recalculate` as three on-demand Host tools. Each tool states its parameter rules in its own JSON Schema: `office_render` accepts document paths, page or slide `pages`, worksheet `sheet` and `range` selection, and `dpi`; `office_convert` accepts all nine output formats (`pdf`, `docx`, `odt`, and `txt` for Word; `pdf`, `xlsx`, `ods`, and `csv` for Excel; `pdf`, `pptx`, and `odp` for PowerPoint) plus `sheet` for CSV output (required when the workbook has several sheets); and `office_recalculate` accepts `xlsx` and `ods`. Together the three declarations total ~1,813 characters, paid only in Sessions that load an Office skill. They call the [Office kit](../../../../packages/document/office-kit/README.md) service, which loads Kit in the Host process through `/locate` and runs every operation through the queue, concurrency limits, byte reservations, and cache that Office previews use. Tool requests use `foreground` priority, the class of an open preview, so background prewarming cannot starve them. The SDK composition mounts `tool-office` beside `office-kit`, and the Web bundle's standard and PTC agent presets mount it while its minimal preset keeps its fixed roster; when Kit is missing the tools still register and every call returns the service's `unavailable` message. Each tool reads the service at each call instead of injecting it, so a composition that omits or disables `office-kit` still creates Sessions with the tools and each call fails as `unavailable`; a service loaded later serves the next call. Standard and PTC modes reach the same registrations; nested PTC calls re-enter the ordinary execution pipeline.
`render` returns PNG images in the tool result. The tool commits them through the attachment store before the result is logged, so the model-visible images are reconstructable from the Session log, resume and fork restore them, and image offload applies to them. The complete result is bounded by image count, per-image pixels and dimensions, and total PNG bytes, each the lower of the tool configuration and the attachment store's limits; an over-limit selection fails instead of being truncated. A route without image input is refused before rendering.
`office_render` returns PNG images in the tool result and presents them in the Client through the `tool.call.office_render.images` child slot. The tool commits the images through the attachment store before the result is logged, so the model-visible images are reconstructable from the Session log, resume and fork restore them, and image offload applies to them. The complete result is bounded by image count, per-image pixels and dimensions, and total PNG bytes, each the lower of the tool configuration and the attachment store's limits; an over-limit selection fails instead of being truncated. A route without image input is refused before rendering.
`convert` and `recalculate` do not write into the workspace. The filesystem service intentionally provides only binary reads, and binary files in the workspace come only from the shell, whose sandbox and approvals already govern writes. The Office kit saves each output in an owner-only directory under its configurable `outputDirectory` (`$DSH_HOME/office-kit/outputs` by default), grouped by the root Session of the caller's subagent tree, and deletes it after `outputRetentionMs`, when `maxOutputStoreBytes` needs room for newer outputs, when that root Session is disposed, or when the provider unloads. A subagent's output therefore outlives the subagent, so the delegating agent can still copy it. The tool returns the absolute temporary path, format, size, and PDF page count with the instruction to copy the file with the shell now, because it is deleted when the conversation ends. A filesystem backend that cannot read Host paths, such as an SSH workspace, refuses these two operations before converting, because a remote shell cannot read the Host output store. Shell sandboxes allow reads of the Harness home on macOS Seatbelt, Linux bubblewrap, and Linux Landlock, so a confined shell can copy the file into the workspace.
`office_convert` and `office_recalculate` do not write into the workspace. The filesystem service intentionally provides only binary reads, and binary files in the workspace come only from the shell, whose sandbox and approvals already govern writes. The Office kit saves each output in an owner-only directory under its configurable `outputDirectory` (`$DSH_HOME/office-kit/outputs` by default), grouped by the root Session of the caller's subagent tree, and deletes it after `outputRetentionMs`, when `maxOutputStoreBytes` needs room for newer outputs, when that root Session is disposed, or when the provider unloads. A subagent's output therefore outlives the subagent, so the delegating agent can still copy it. Each tool returns the absolute temporary path, format, size, and PDF page count with the instruction to copy the file with the shell now, because it is deleted when the conversation ends. A filesystem backend that cannot read Host paths, such as an SSH workspace, refuses these two tools before converting, because a remote shell cannot read the Host output store. Shell sandboxes allow reads of the Harness home on macOS Seatbelt, Linux bubblewrap, and Linux Landlock, so a confined shell can copy the file into the workspace.
The tool is resident rather than activated with an Office skill, and no skill wraps a single operation. Its schema is short and fixed, and the model-facing description names only task concepts. The demand-loaded [Office router and format skills](../../../../packages/skill/skill-office/README.md) name the `operation` to call and keep the when-to-render guidance; a standalone render, recalculation, or PDF export loads only the router. The skills no longer carry executable paths, so `skill-office` has no Node, CLI, or Kit location configuration, `/locate` has no CLI resolver, Desktop and the bundles publish no Office executable variables, and the Python sidecar's standalone Node remains only for the Python `deepseek_harness.office` module.
The three tools share one `when(agent)` predicate instead of staying resident in every request. An `Agent` activates them when `marked.has(agent)` is true or when `agent.session.requestHeader()?.tools` already lists `office_render`, `office_convert`, or `office_recalculate`; `agent/disposed` clears the `WeakSet<Agent>` mark. `tool-office` marks the `Agent` on a non-error `skill` tool result (`tools/result` with `!result.isError`, including a nested `skill` call inside `run_code`) or a direct user skill invocation (`session/event` where `event.type === 'user/message'` and `event.data.source.kind === 'skill-invocation'`) whose skill name is in `activationSkills` (`office`, `office-docx`, `office-xlsx`, and `office-pptx` by default). The declarations appear on the step after the skill loads and stay active for the rest of the Session; calling an `office_*` tool before activation fails as `UNKNOWN_TOOL`. When mid-session activation adds the tools, the agent loop records a `developer/message` (`source: { kind: 'tool-registry' }`) with `tool-addition` items: models that declare `toolUpdate` (`in-history` or `addition-only`) keep their existing request prefix, whereas models without `toolUpdate` start a new request series once. Because standard-mode request headers are already persisted in the Session log, checking `requestHeader()` preserves activation across resume, fork, and compaction without a Session projection. In PTC mode, the recorded request header declares only `run_code`, so a resumed or forked PTC Session (or a process crash between loading a skill and recording the next native request header) does not retain `office_*` bindings until an Office skill loads again; the [Office router and format skills](../../../../packages/skill/skill-office/README.md) instruct the model to load `office` if the tools are unavailable. No skill wraps a single operation, and a standalone render, recalculation, or conversion loads only the `office` router. The skills carry no executable paths, so `skill-office` has no Node, CLI, or Kit location configuration, `/locate` has no CLI resolver, Desktop and the bundles publish no Office executable variables, and the Python sidecar's standalone Node remains only for the Python `deepseek_harness.office` module.
This decision partially supersedes [progressive Office skills](2026-09-27-progressive-office-skills.md): its router and format skills remain current, while its operation skills, ordinary-shell execution, and rejection of a dedicated renderer tool are replaced here.
@@ -24,9 +24,13 @@ This decision partially supersedes [progressive Office skills](2026-09-27-progre
**Keep shell execution of the Kit CLI.** It reuses shell approvals and process management, but the native engine runs restricted under shell sandboxes and PTC permissions, and every deployment must maintain Node and CLI paths, an Electron Node check, and runtime-root containment.
**Keep one skill per operation.** Separate render, recalculation, and PDF export skills add a `skill` call before each standalone operation and repeat what the tool schema and results already state.
**Keep one resident `office` tool.** One resident schema (~1,514 characters) avoids mid-session tool additions, but charges every non-Office Session on every request and forces rendering, conversion, and recalculation parameters into a single flat schema where per-operation parameter combinations must be explained in prose instead of enforced per tool.
**Activate the tool only with the Office skills.** Step-owned `when` activation would remove the schema from ordinary requests, but adding or removing a tool declaration changes the request prefix and forces KV cache recomputation, and recording when it applies would need its own Session projection. A short resident schema costs a fixed amount per request instead.
**Add a Session projection for loaded Office skills.** Folding `tools/result` and `user/message` records in a dedicated projection would reconstruct skill activation across PTC resume and fork, but requires a new projection service, fold rules, and cross-package dependencies for state that standard-mode request headers already record and that PTC mode recovers by reloading `office`.
**Track activation only in `Agent` memory.** Checking only `WeakSet<Agent>` (as `action-cards` does) drops the `office_*` declarations on the first step after a standard-mode resume or fork because the new `Agent` instance starts unmarked; consulting `agent.session.requestHeader()?.tools` preserves the declarations from the persisted header.
**Keep one skill per operation.** Separate render, recalculation, and PDF export skills add a `skill` call before each standalone operation and repeat what the tool schema and results already state.
**Write converted files into the workspace from the Host.** This saves the shell copy, but needs binary creation in the filesystem service or a second write path beside it, both of which would duplicate the shell's sandbox and approval decisions for workspace writes.
@@ -36,8 +40,8 @@ This decision partially supersedes [progressive Office skills](2026-09-27-progre
## Consequences
Visual inspection takes one tool call and no cleanup, and its images follow the Session's attachment, offload, and replay rules. The `office` schema adds a fixed cost to every request that mounts it, independent of whether Office skills load. Office operations behave the same in standard and PTC modes and across deployments, and the deployment-specific Node, CLI, and containment code is gone.
Visual inspection takes one `office_render` call after loading an Office skill and needs no cleanup, and its images follow the Session's attachment, offload, and replay rules. Sessions that do not load an Office skill pay zero Office tool-declaration tokens; Sessions that load one activate ~1,813 characters of operation-specific schemas, keeping the existing request prefix on models with `toolUpdate` and starting one new request series on models without it. Standard-mode resume, fork, and compaction retain the tools through the recorded request header, while PTC resume or fork and crashes before the next recorded header recover by loading `office` again. Office operations behave the same in standard and PTC modes and across deployments once activated, and the deployment-specific Node, CLI, and containment code is gone.
Converted files need a shell copy; compositions without a shell tool can render but cannot deliver converted files, and remote workspaces cannot convert at all. Temporary outputs disappear after retention or root Session disposal, so a resumed Session must convert again. Saving page images as files is not offered.
Verification covers the tool's schema, results, argument rules, limits, failures, cancellation, PTC dispatch, and disposal in its package tests; the output store's retention, eviction, release, and sweeping in Office kit tests; Loader compositions that return the `unavailable` message with Kit absent and with the `office-kit` row absent, then reach the service once the row loads; packaged Desktop smoke checks that render, convert, and recalculate real DOCX, XLSX, and PPTX files through the service; and recorded headless sessions whose tool declarations and loaded Office skills name the `office` tool, including a render that the tool refuses for a route without image input.
Verification covers the three tools' schemas, results, argument rules, limits, failures, cancellation, PTC dispatch, and disposal in `tool-office.spec.ts`, and skill-driven activation, custom `activationSkills`, failed skill calls, direct `/office` invocation, `requestHeader()` persistence across resume and fork, and PTC reactivation in `activation.spec.ts`; the output store's retention, eviction, release, and sweeping in Office kit tests; Loader compositions that return the `unavailable` message with Kit absent and with the `office-kit` row absent, then reach the service once the row loads; packaged Desktop smoke checks that render, convert, and recalculate real DOCX, XLSX, and PPTX files through the service; and recorded headless sessions that omit `office_*` before an Office skill loads and declare `office_render`, `office_convert`, and `office_recalculate` on the step after loading one, including a render that `office_render` refuses for a route without image input.
@@ -1,4 +1,4 @@
# Agent Note: 以常驻 office 工具执行 Office 操作
# Agent Note: 按需激活的 Office 渲染、转换与重算工具
Status: implemented
@@ -10,13 +10,13 @@ Status: implemented
## 决策
[`office` 工具](../../../../packages/document/tool-office/README.zh.md)以一个常驻 Host 工具提供 `render`、`convert` 和 `recalculate`。它调用 [Office 套件](../../../../packages/document/office-kit/README.zh.md)服务;该服务通过 `/locate` 在 Host 进程中加载 Kit,并让每个操作经过 Office 预览所用的队列、并发上限、字节预留和缓存。工具请求使用 `foreground` 优先级,即打开的预览所属的类别,因此后台预热不会饿死它们。SDK 组合在 `office-kit` 旁挂载该工具,Web bundle 的标准和 PTC Agent 预设挂载它,minimal 预设保持其固定工具列表;Kit 缺失时工具仍然注册,每次调用都返回服务的 `unavailable` 消息。工具在每次调用时读取该服务而不是注入它,因此省略或禁用 `office-kit` 的组合仍能带着该工具创建 Session,每次调用以 `unavailable` 失败;之后加载的服务会处理下一次调用。标准模式与 PTC 模式使用同一个注册;PTC 嵌套调用重新进入普通执行管线。
[`tool-office` 包](../../../../packages/document/tool-office/README.zh.md)提供三个按需激活的 Host 工具:`office_render`、`office_convert` 和 `office_recalculate`。每个工具在各自的 JSON Schema 中直接声明参数规则:`office_render` 接受文档路径、页码或幻灯片 `pages`、工作表 `sheet` 与 `range` 选择以及 `dpi`;`office_convert` 保留全部九种输出格式(Word 支持 `pdf`、`docx`、`odt`、`txt`,Excel 支持 `pdf`、`xlsx`、`ods`、`csv`,PowerPoint 支持 `pdf`、`pptx`、`odp`)以及仅用于 CSV 输出的 `sheet`(工作簿含多个工作表时必填);`office_recalculate` 接受 `xlsx` 和 `ods`。三个工具声明共约 1,813 个字符,仅在加载了 Office 技能的 Session 中付出。它们调用 [Office 套件](../../../../packages/document/office-kit/README.zh.md)服务;该服务通过 `/locate` 在 Host 进程中加载 Kit,并让每个操作经过 Office 预览所用的队列、并发上限、字节预留和缓存。工具请求使用 `foreground` 优先级,即打开的预览所属的类别,因此后台预热不会饿死它们。SDK 组合在 `office-kit` 旁挂载 `tool-office`,Web bundle 的标准和 PTC Agent 预设挂载它,minimal 预设保持其固定工具列表;Kit 缺失时三个工具仍然注册,每次调用都返回服务的 `unavailable` 消息。每个工具在每次调用时读取该服务而不是注入它,因此省略或禁用 `office-kit` 的组合仍能带着这些工具创建 Session,每次调用以 `unavailable` 失败;之后加载的服务会处理下一次调用。标准模式与 PTC 模式使用同一组注册;PTC 嵌套调用重新进入普通执行管线。
`render` 在工具结果中返回 PNG 图片。工具在结果写入日志之前通过附件存储提交图片,因此模型可见的图片可以从 Session 日志还原,恢复和分叉会还原它们,图片卸载也适用于它们。完整结果受图片数量、单图像素与尺寸以及 PNG 总字节数约束,每项取工具配置与附件存储上限中的较小值;超出上限的选择直接失败,不会被截断。不支持图片输入的路由在渲染前即被拒绝。
`office_render` 在工具结果中返回 PNG 图片,并在 Client 中通过 `tool.call.office_render.images` 子插槽展示。工具在结果写入日志之前通过附件存储提交图片,因此模型可见的图片可以从 Session 日志还原,恢复和分叉会还原它们,图片卸载也适用于它们。完整结果受图片数量、单图像素与尺寸以及 PNG 总字节数约束,每项取工具配置与附件存储上限中的较小值;超出上限的选择直接失败,不会被截断。不支持图片输入的路由在渲染前即被拒绝。
`convert` 和 `recalculate` 不写入工作区。文件系统服务有意只提供二进制读取,工作区中的二进制文件只由 shell 产生,而 shell 的沙箱和审批已经管理写入。Office 套件把每个输出保存在可配置的 `outputDirectory`(默认 `$DSH_HOME/office-kit/outputs`)下仅属主可访问的目录中,按调用方 subagent 树的根 Session 分组;输出在 `outputRetentionMs` 到期、`maxOutputStoreBytes` 需要为较新的输出腾出空间、该根 Session 卸载或提供方卸载时删除。因此 subagent 的输出在 subagent 结束后仍然保留,委派它的 agent 仍可复制。工具返回临时文件的绝对路径、格式、大小和 PDF 页数,并指示立即用 shell 复制该文件,因为对话结束后文件会被删除。无法读取 Host 路径的文件系统后端(例如 SSH 工作区)会在转换前拒绝这两种操作,因为远程 shell 读不到 Host 的输出存储。macOS Seatbelt、Linux bubblewrap 和 Linux Landlock 的 shell 沙箱都允许读取 Harness 主目录,因此受限的 shell 可以把文件复制进工作区。
`office_convert` 和 `office_recalculate` 不写入工作区。文件系统服务有意只提供二进制读取,工作区中的二进制文件只由 shell 产生,而 shell 的沙箱和审批已经管理写入。Office 套件把每个输出保存在可配置的 `outputDirectory`(默认 `$DSH_HOME/office-kit/outputs`)下仅属主可访问的目录中,按调用方 subagent 树的根 Session 分组;输出在 `outputRetentionMs` 到期、`maxOutputStoreBytes` 需要为较新的输出腾出空间、该根 Session 卸载或提供方卸载时删除。因此 subagent 的输出在 subagent 结束后仍然保留,委派它的 agent 仍可复制。工具返回临时文件的绝对路径、格式、大小和 PDF 页数,并指示立即用 shell 复制该文件,因为对话结束后文件会被删除。无法读取 Host 路径的文件系统后端(例如 SSH 工作区)会在转换前拒绝这两个工具,因为远程 shell 读不到 Host 的输出存储。macOS Seatbelt、Linux bubblewrap 和 Linux Landlock 的 shell 沙箱都允许读取 Harness 主目录,因此受限的 shell 可以把文件复制进工作区。
该工具常驻,而不是随 Office 技能激活,也没有技能只包装单个操作。其 schema 简短且固定,面向模型的描述只包含任务概念。按需加载的 [Office 路由与格式技能](../../../../packages/skill/skill-office/README.zh.md)写明要调用的 `operation`,并保留何时渲染的指导;单独的渲染、重算或 PDF 导出只加载路由。技能不再携带可执行文件路径,因此 `skill-office` 没有 Node、CLI 或 Kit 位置配置,`/locate` 没有 CLI 解析器,Desktop 和各 bundle 不发布 Office 可执行文件变量,Python sidecar 的独立 Node 只保留给 Python `deepseek_harness.office` 模块使用。
三个工具共享同一个 `when(agent)` 谓词,而不是在每次请求中常驻。当 `marked.has(agent)` 为真,或 `agent.session.requestHeader()?.tools` 已包含 `office_render`、`office_convert` 或 `office_recalculate` 时,`Agent` 激活它们;`agent/disposed` 会清除 `WeakSet<Agent>` 标记。当非错误的 `skill` 工具结果(`tools/result` 且 `!result.isError`,包括 `run_code` 内嵌套的 `skill` 调用)或直接的用户技能调用(`session/event` 中 `event.type === 'user/message'` 且 `event.data.source.kind === 'skill-invocation'`)加载了 `activationSkills`(默认为 `office`、`office-docx`、`office-xlsx` 和 `office-pptx`)中的技能时,`tool-office` 标记该 `Agent`。工具声明在加载技能后的下一步出现,并在该 Session 剩余时间内保持激活;激活前调用 `office_*` 工具会以 `UNKNOWN_TOOL` 失败。会话中途激活新增这些工具时,agent loop 会记录一条带 `tool-addition` 项的 `developer/message`(`source: { kind: 'tool-registry' }`):声明了 `toolUpdate`(`in-history` 或 `addition-only`)的模型保留现有请求前缀,未声明 `toolUpdate` 的模型则开启一次新的请求序列。由于标准模式的请求头本就持久化在 Session 日志中,检查 `requestHeader()` 即可在恢复、分叉和压缩后保留激活状态,无需新增 Session projection。PTC 模式下记录的请求头只声明 `run_code`,因此恢复或分叉的 PTC Session(或加载技能后、下一条原生请求头记录前发生进程崩溃)不会保留 `office_*` 绑定,直到再次加载 Office 技能;[Office 路由与格式技能](../../../../packages/skill/skill-office/README.zh.md)指示模型在工具不可用时调用 `skill` 加载 `office`。没有技能只包装单个操作,单独的渲染、重算或转换只需加载 `office` 路由。技能不再携带可执行文件路径,因此 `skill-office` 没有 Node、CLI 或 Kit 位置配置,`/locate` 没有 CLI 解析器,Desktop 和各 bundle 不发布 Office 可执行文件变量,Python sidecar 的独立 Node 只保留给 Python `deepseek_harness.office` 模块使用。
此决定部分取代[渐进式 Office 技能](2026-09-27-progressive-office-skills.zh.md):其路由与格式技能仍然有效,而其操作技能、普通 shell 执行方式以及否决专用渲染工具的决定由本文取代。
@@ -24,9 +24,13 @@ Status: implemented
**保留通过 shell 执行 Kit CLI。** 这样可复用 shell 的审批和进程管理,但原生引擎在 shell 沙箱和 PTC 权限下运行受限,而且每个部署都要维护 Node 与 CLI 路径、Electron 的 Node 检查以及运行时根目录约束。
**为每个操作保留一个技能。** 单独的渲染、重算和 PDF 导出技能会在每次单独操作前多一次 `skill` 调用,并重复工具 schema 与结果中已有的说明。
**保留单一常驻 `office` 工具。** 单一常驻 schema(约 1,514 个字符)虽能避免会话中途新增工具,但会让所有不使用 Office 的 Session 在每次请求中都承担这笔开销,并迫使渲染、转换和重算参数挤在同一个扁平 schema 中,各操作的参数组合只能靠自然语言说明而无法按工具分 schema 约束。
**仅随 Office 技能激活该工具。** 按步骤的 `when` 激活可以把 schema 移出普通请求,但增删工具声明会改变请求前缀并导致 KV cache 重算,记录其何时生效还需要单独的 Session projection。简短的常驻 schema 则让每个请求承担固定开销。
**为已加载的 Office 技能新增 Session projection。** 在专用 projection 中折叠 `tools/result` 和 `user/message` 记录虽可在 PTC 恢复和分叉后还原技能激活状态,但需要新增 projection 服务、折叠规则和跨包依赖,而标准模式已由持久化的请求头记录该状态,PTC 模式只需重新加载 `office` 即可恢复。
**仅在 `Agent` 内存中记录激活状态。** 若像 `action-cards` 那样只检查 `WeakSet<Agent>`,标准模式恢复或分叉后的第一步会丢失 `office_*` 声明,因为新的 `Agent` 实例初始未标记;同时检查 `agent.session.requestHeader()?.tools` 可从已持久化的请求头保留声明。
**为每个操作保留一个技能。** 单独的渲染、重算和 PDF 导出技能会在每次单独操作前多一次 `skill` 调用,并重复工具 schema 与结果中已有的说明。
**由 Host 把转换后的文件写入工作区。** 这样省去 shell 复制,但需要文件系统服务支持创建二进制文件,或在其旁另建一条写入路径,两者都会重复 shell 对工作区写入的沙箱和审批决策。
@@ -36,8 +40,8 @@ Status: implemented
## 影响
视觉检查只需一次工具调用且无需清理,图片遵循 Session 的附件、卸载和回放规则。挂载 `office` 的每个请求都增加固定的 schema 开销,与是否加载 Office 技能无关。Office 操作在标准模式与 PTC 模式之间、在不同部署之间行为一致,各部署专用的 Node、CLI 和约束代码已经删除。
加载 Office 技能后,视觉检查只需一次 `office_render` 调用且无需清理,图片遵循 Session 的附件、卸载和回放规则。未加载 Office 技能的 Session 不消耗任何 Office 工具声明 token;加载了 Office 技能的 Session 激活约 1,813 个字符的专用 schema,支持 `toolUpdate` 的模型保留现有请求前缀,不支持 `toolUpdate` 的模型只开启一次新的请求序列。标准模式的恢复、分叉和压缩通过已记录的请求头保留工具声明,PTC 恢复或分叉以及在记录下一条请求头前崩溃的场景则通过再次加载 `office` 恢复。激活后,Office 操作在标准模式与 PTC 模式之间、在不同部署之间行为一致,各部署专用的 Node、CLI 和约束代码已经删除。
转换后的文件需要 shell 复制;没有 shell 工具的组合可以渲染,但无法交付转换后的文件,远程工作区则完全不能转换。临时输出在保留期满或根 Session 卸载后消失,恢复的 Session 需要重新转换。不提供把页面图片保存为文件。
验证包括:工具包测试覆盖 schema、结果、参数规则、上限、失败、取消、PTC 分发和卸载;Office 套件测试覆盖输出存储的保留、淘汰、释放和清扫;Loader 组合测试在 Kit 缺失时以及 `office-kit` 条目缺失时返回 `unavailable` 消息,并在该条目加载后调用到服务;Desktop 打包 smoke 通过服务对真实 DOCX、XLSX 和 PPTX 文件执行渲染、转换和重算;录制的 headless Session 的工具声明和已加载的 Office 技能都包含 `office` 工具,其中包括一次因路由不接受图片输入而被工具拒绝的渲染。
验证包括:`tool-office.spec.ts` 覆盖三个工具的 schema、结果、参数规则、上限、失败、取消、PTC 分发和卸载,`activation.spec.ts` 覆盖技能触发激活、自定义 `activationSkills`、失败的技能调用、直接 `/office` 调用、跨恢复与分叉的 `requestHeader()` 持久化以及 PTC 重新激活;Office 套件测试覆盖输出存储的保留、淘汰、释放和清扫;Loader 组合测试在 Kit 缺失时以及 `office-kit` 条目缺失时返回 `unavailable` 消息,并在该条目加载后调用到服务;Desktop 打包 smoke 通过服务对真实 DOCX、XLSX 和 PPTX 文件执行渲染、转换和重算;录制的 headless Session 在加载 Office 技能前不声明 `office_*`,在加载后的下一步声明 `office_render`、`office_convert` 和 `office_recalculate`,其中包括一次因路由不接受图片输入而被 `office_render` 拒绝的渲染。
@@ -606,8 +606,11 @@ it.each(['unset', 'empty', 'full', 'python-only', 'python-only-patched', 'missin
const names = (requests[0]!.tools as { name: string }[]).map(value => value.name)
expect(names.includes('load_workspace_dependencies')).toBe(enabled)
expect(JSON.stringify(requests[0]!.messages).includes('`office`')).toBe(mode !== 'missing-assets')
expect(names).toContain('office')
expect(names).not.toContain('office_tools')
const officeTools = ['office_convert', 'office_recalculate', 'office_render']
expect(names.filter(name => name.startsWith('office'))).toEqual([])
const lastNames = (requests.at(-1)!.tools as { name: string }[]).map(value => value.name)
// Loading an Office skill declares the Office tools from the following request.
expect(lastNames.filter(name => name.startsWith('office')).sort()).toEqual(mode === 'missing-assets' ? [] : officeTools)
expect(names).not.toContain('render_document')
for (const name of ['office-docx', 'office-pptx', 'office-xlsx']) {
expect(JSON.stringify(requests[0]!.messages).includes(name)).toBe(mode !== 'missing-assets')
@@ -1,6 +1,6 @@
/**
* PDF export through the shipped SDK profile: the agent converts with the `office` tool and copies the temporary PDF
* into the workspace with the shell, with no Node on PATH.
* PDF export through the shipped SDK profile: the agent loads an Office skill, converts with `office_convert`, and
* copies the temporary PDF into the workspace with the shell, with no Node on PATH.
* Defaults to built Node packages. DSH_OFFICE_TEST_EXECUTABLE/ENTRY select a relocated Node or Electron carrier;
* CARRIER=sdk selects the standalone executable. API=openai-completions selects a development gateway instead of the
* default Messages API.
@@ -31,7 +31,7 @@ function callArguments(call: ToolCall): Record<string, unknown> {
return JSON.parse(call.arguments) as Record<string, unknown>
}
it.skipIf(!process.env.DEEPSEEK_API_KEY || process.platform === 'win32')(`agent exports a PDF with the office tool in the ${carrier} carrier without Node on PATH`, async () => {
it.skipIf(!process.env.DEEPSEEK_API_KEY || process.platform === 'win32')(`agent exports a PDF with office_convert in the ${carrier} carrier without Node on PATH`, async () => {
const root = await mkdtemp(join(tmpdir(), 'dsh office export '))
try {
const source = zipSync({
@@ -104,9 +104,11 @@ it.skipIf(!process.env.DEEPSEEK_API_KEY || process.platform === 'win32')(`agent
const params = record.params as { event?: { type: string; data: ToolCall } } | undefined
return params?.event?.type === 'tool/call' ? [params.event.data] : []
})
const convert = calls.findIndex(call => call.name === 'office' && callArguments(call).operation === 'convert')
const skill = calls.findIndex(call => call.name === 'skill')
const convert = calls.findIndex(call => call.name === 'office_convert' && callArguments(call).format === 'pdf')
const copy = calls.findIndex(call => call.name === 'bash' && /\bcp\b/u.test(String(callArguments(call).command)))
expect(convert, diagnostic).toBeGreaterThanOrEqual(0)
expect(skill, diagnostic).toBeGreaterThanOrEqual(0)
expect(convert, diagnostic).toBeGreaterThan(skill)
expect(copy, diagnostic).toBeGreaterThan(convert)
expect(existsSync(decoyMarker), 'the agent must not invoke system Office').toBe(false)
const pdf = await readFile(join(root, 'result.pdf'))
+1 -1
View File
@@ -301,7 +301,7 @@ describe('the shipped Web composition', () => {
// depend on ripgrep being present on the machine.
expect(toolNames(ctx, handle.agent).filter(name => name !== 'glob' && name !== 'grep')).toEqual([
'ask_user_question', 'bash', 'create_goal', 'edit', 'exit_plan_mode',
'get_goal', 'interrupt_agent', 'job_kill', 'job_list', 'job_output', 'list_agents', 'list_subagent_models', 'office', 'plugin_manager', 'present', 'read', 'read_image',
'get_goal', 'interrupt_agent', 'job_kill', 'job_list', 'job_output', 'list_agents', 'list_subagent_models', 'office_convert', 'office_recalculate', 'office_render', 'plugin_manager', 'present', 'read', 'read_image',
'schedule_create', 'schedule_edit', 'schedule_list', 'schedule_view',
'send_message', 'skill',
'subagent', 'subagent_fork', 'team_task_create', 'team_task_get', 'team_task_list', 'team_task_update', 'todo_write', 'update_goal', 'wait_agent', 'web_fetch', 'web_search',
+2 -2
View File
@@ -27,8 +27,8 @@
en: 3724c53da4f7647b
zh: 76ae549d43c99bb4
/deepseek-harness-desktop/key-technical-decisions/bundled-workspace-dependencies:
en: aee4f96a104359b6
zh: 23a1d46b0cd727de
en: 6ca3d310060d0ec5
zh: 83bab7049d670200
/deepseek-harness-desktop/bundled-command-runtime:
en: 372297005b57a08b
zh: 074a635ac17e4362
+2 -2
View File
@@ -103,9 +103,9 @@ Signed Windows packaging scans the primary runtime and application production de
Desktop carries independent Python, Node.js and pnpm distributions. Python includes numpy, pandas, python-docx, python-pptx, openpyxl, Pillow, lxml and XlsxWriter with their complete dependencies. The `load_workspace_dependencies` tool installs this payload offline on first use under `$DSH_HOME/dsh-runtimes/dsh-primary-runtime` (normally `~/.dsh/dsh-runtimes/dsh-primary-runtime`) and returns absolute interpreter, pnpm script and library paths plus `pythonDistributions`, the bundled distribution names and versions. The version report excludes user-installed additions. Office tasks prefer these libraries unless user or workspace instructions select another environment. Execute the pnpm script with the returned Node executable. The returned Node library directory is reserved for bundled libraries, not pnpm's global installation directory.
Desktop exposes the compact `office` router and named authoring subskills. Authoring uses bundled Python libraries; rendering, conversion, and recalculation call the [`office` tool](../../packages/document/tool-office/README.md), which runs LibreOffice Kit inside the Host through the Office kit service. The skill package itself may remain in ASAR. Skills live in `runtime/office-skills` outside ASAR. A missing or invalid skill file removes only that skill from the catalog, and Office profile rows that cannot load leave Office skills or `load_workspace_dependencies` unavailable; neither failure stops Host startup. See the [Office skill package](../../packages/skill/skill-office/README.md) for progressive loading and limitations.
Desktop exposes the compact `office` router and named authoring subskills. Authoring uses bundled Python libraries; rendering, conversion, and recalculation call the [Office tools](../../packages/document/tool-office/README.md), which run LibreOffice Kit inside the Host through the Office kit service. The skill package itself may remain in ASAR. Skills live in `runtime/office-skills` outside ASAR. A missing or invalid skill file removes only that skill from the catalog, and Office profile rows that cannot load leave Office skills or `load_workspace_dependencies` unavailable; neither failure stops Host startup. See the [Office skill package](../../packages/skill/skill-office/README.md) for progressive loading and limitations.
If Kit cannot be loaded, Office skills and the `office` tool remain registered; each tool call reports that LibreOffice Kit is not installed, and the Office kit logs each distinct failure once through `ctx.logger.warn`. The independent dependency-query row is unaffected. There is no separate diagnostic file or GUI notification. Required Host components must still start successfully, and packaging smoke checks reject an unavailable Kit.
If Kit cannot be loaded, Office skills and the Office tools remain registered; each tool call reports that LibreOffice Kit is not installed, and the Office kit logs each distinct failure once through `ctx.logger.warn`. The independent dependency-query row is unaffected. There is no separate diagnostic file or GUI notification. Required Host components must still start successfully, and packaging smoke checks reject an unavailable Kit.
Processes started from the Desktop built-in terminal inherit `DSH_PRIMARY_RUNTIME`, so `dsh --profile sdk` started there uses Desktop's bundled Python environment. Unset that variable to use the user's Python. Desktop publishes no Kit location to the Host or its children; each application loads its own Kit.
+2 -2
View File
@@ -103,9 +103,9 @@ Windows 签名打包按 PE 文件内容扫描第一方运行时和应用生产
Desktop 携带独立的 Python、Node.js 和 pnpm 分发包。Python 包含 numpy、pandas、python-docx、python-pptx、openpyxl、Pillow、lxml、XlsxWriter 及其完整依赖。`load_workspace_dependencies` 工具首次使用时,将该产物离线安装到 `$DSH_HOME/dsh-runtimes/dsh-primary-runtime`(通常为 `~/.dsh/dsh-runtimes/dsh-primary-runtime`),并返回解释器、pnpm 脚本和库目录的绝对路径,以及记录内置分发包名称与版本的 `pythonDistributions`。版本报告不包含用户自行安装的包。Office 任务默认使用这些库,用户或工作区指令指定其他环境时遵循其要求。pnpm 脚本通过返回的 Node 可执行文件运行。返回的 Node 库目录为随包交付的库预留,不是 pnpm 的全局安装目录。
Desktop 展示精简的 `office` 路由及可具名调用的创作子技能。创作使用内置 Python 库;渲染、转换和重算调用 [`office` 工具](../../packages/document/tool-office/README.zh.md),它通过 Office 套件服务在 Host 内运行 LibreOffice Kit。技能包本身可以留在 ASAR 中。技能位于 ASAR 之外的 `runtime/office-skills`。缺失或无效的技能文件只会把该技能移出目录;无法加载的 Office profile 行会使 Office 技能或 `load_workspace_dependencies` 不可用;这两种失败都不会阻止 Host 启动。渐进加载与限制见 [Office 技能包](../../packages/skill/skill-office/README.zh.md)。
Desktop 展示精简的 `office` 路由及可具名调用的创作子技能。创作使用内置 Python 库;渲染、转换和重算调用 [Office 工具](../../packages/document/tool-office/README.zh.md),它们通过 Office 套件服务在 Host 内运行 LibreOffice Kit。技能包本身可以留在 ASAR 中。技能位于 ASAR 之外的 `runtime/office-skills`。缺失或无效的技能文件只会把该技能移出目录;无法加载的 Office profile 行会使 Office 技能或 `load_workspace_dependencies` 不可用;这两种失败都不会阻止 Host 启动。渐进加载与限制见 [Office 技能包](../../packages/skill/skill-office/README.zh.md)。
无法加载 Kit 时,Office 技能和 `office` 工具仍会注册;每次调用工具都会报告 LibreOffice Kit 未安装,Office 套件通过 `ctx.logger.warn` 对每种不同的失败只记录一次。独立的依赖查询行不受影响。没有单独的诊断文件或 GUI 通知。必需的 Host 组件仍须成功启动,打包冒烟检查会拒绝不可用的 Kit。
无法加载 Kit 时,Office 技能和 Office 工具仍会注册;每次调用工具都会报告 LibreOffice Kit 未安装,Office 套件通过 `ctx.logger.warn` 对每种不同的失败只记录一次。独立的依赖查询行不受影响。没有单独的诊断文件或 GUI 通知。必需的 Host 组件仍须成功启动,打包冒烟检查会拒绝不可用的 Kit。
从 Desktop 内置终端启动的进程会继承 `DSH_PRIMARY_RUNTIME`,因此在其中启动的 `dsh --profile sdk` 使用 Desktop 的内置 Python 环境。要改用用户的 Python,请取消设置该变量。Desktop 不向 Host 或其子进程发布 Kit 位置;每个应用加载自己的 Kit。
+2 -2
View File
@@ -45,8 +45,8 @@
en: b42f103358d0dfd7
zh: a534164ad9eb00da
/desktop-packaging/runtime-file-selection-and-installation-checks:
en: 44044a5c14b75533
zh: 39d91a369c4ec2fa
en: 2a1763aa66d82272
zh: cfd44dc5a0b7f528
/desktop-packaging/desktop-runtime-preparation:
en: 84be38ab3136fff7
zh: bb4ed12ee0e1dfa0
+1 -1
View File
@@ -252,7 +252,7 @@ Desktop packs workspace packages locally and installs external dependencies thro
The [Electron shell file list](../scripts/electron-builder-config.mjs) excludes recognized JavaScript/CSS/TypeScript source maps and TypeScript build caches from the separate `resources/app.asar/node_modules` dependency collection. These exclusions preserve runtime code, native modules, WASM, data files (including ordinary `.map` assets), licenses, and notices; [shell archive tests](../tests/shell-file-selection.spec.ts) check retained bytes and exclusions.
The [Office conversion provider](../../../packages/document/office-kit/README.md) is a Host service mounted by web-app, so every application that loads web-app, including `dsh web` and Desktop, provides it together with the [`office` tool](../../../packages/document/tool-office/README.md). The provider and its [`/locate` entry](../../../packages/document/office-kit/README.md#locate-kit) resolve the Kit's engine, including the mapping of native engine manifests to unpacked physical directories. Desktop packaging only carries and unpacks the engine: it carries the target’s declared native engine, or WASM when the kit declares no matching native target, and preparation rejects a missing target engine before packaging. The complete Office dependencies, including the JavaScript libraries and the selected engine’s executables, data, licenses, and notices, are unpacked under `resources/app.asar.unpacked/dsh/node_modules/`. The Desktop shell passes `DSH_PRIMARY_RUNTIME` in [main.ts](../src/main.ts) and no Kit location. Office skills are available in every application that loads web-app; only Desktop mounts the bundled Python environment (`workspace-dependencies`). On macOS, the native helper receives the JIT entitlement required by [LibreOffice’s UNO bridge](https://github.com/LibreOffice/core/blob/master/sysui/desktop/macosx/hardened_runtime.xcent.in). The Computer Use helper applications under `@deepseek-ai/dsh-experimental-cua-macos/native/bin` are also unpacked whole under `resources/app.asar.unpacked/dsh/node_modules/`, and the provider opens that copy.
The [Office conversion provider](../../../packages/document/office-kit/README.md) is a Host service mounted by web-app, so every application that loads web-app, including `dsh web` and Desktop, provides it together with the [Office tools](../../../packages/document/tool-office/README.md). The provider and its [`/locate` entry](../../../packages/document/office-kit/README.md#locate-kit) resolve the Kit's engine, including the mapping of native engine manifests to unpacked physical directories. Desktop packaging only carries and unpacks the engine: it carries the target’s declared native engine, or WASM when the kit declares no matching native target, and preparation rejects a missing target engine before packaging. The complete Office dependencies, including the JavaScript libraries and the selected engine’s executables, data, licenses, and notices, are unpacked under `resources/app.asar.unpacked/dsh/node_modules/`. The Desktop shell passes `DSH_PRIMARY_RUNTIME` in [main.ts](../src/main.ts) and no Kit location. Office skills are available in every application that loads web-app; only Desktop mounts the bundled Python environment (`workspace-dependencies`). On macOS, the native helper receives the JIT entitlement required by [LibreOffice’s UNO bridge](https://github.com/LibreOffice/core/blob/master/sysui/desktop/macosx/hardened_runtime.xcent.in). The Computer Use helper applications under `@deepseek-ai/dsh-experimental-cua-macos/native/bin` are also unpacked whole under `resources/app.asar.unpacked/dsh/node_modules/`, and the provider opens that copy.
The packaged application runs compiled JavaScript and pre-generated Typert metadata; it does not compile TypeScript plugins. Source-level debugger navigation and editor declarations remain available in development packages. [Copy-policy tests](../tests/runtime-file-policy.spec.ts) cover exclusions and retained assets; The [payload smoke](../tests/fixtures/runtime-payload-smoke.mjs) runs under Electron RunAsNode before the Host smoke and final inventory verification. The payload smoke resolves the search tool’s ripgrep executable and verifies text search and file enumeration. Signed Windows builds run these checks after dependency signing; other builds run them during `prepare:dsh`. The [Host smoke](../scripts/smoke-runtime.ts) creates DOCX, XLSX, and PPTX inputs with bundled Python and runs each through the real Office provider: PDF conversion, PNG rendering, conversion to the matching OpenDocument format, and, for XLSX, recalculation, checking each output's signature. Every assembled application, including directory and unsigned builds, repeats the payload and Host checks against ASAR. Archive integrity checks compare the complete archived descriptor with preparation, file bytes and membership in both archive and unpacked trees, recorded executable flags for archived files, and physical permissions for unpacked files. Conversion failures stop packaging before a release record is written; macOS DMG/ZIP builds run these checks before notarization.
+1 -1
View File
@@ -252,7 +252,7 @@ Desktop 在本地打包工作区包,并通过目标捆绑的 Node 和 pnpm 安
[Electron 外壳文件清单](../scripts/electron-builder-config.mjs)从单独收集的 `resources/app.asar/node_modules` 依赖中排除已识别的 JavaScript/CSS/TypeScript source map 和 TypeScript 构建缓存。这些排除规则保留运行时代码、原生模块、WASM、数据文件(包括普通 `.map` 资源)、许可证和 notices;[外壳归档测试](../tests/shell-file-selection.spec.ts)检查保留文件的字节和排除项。
[Office 转换提供方](../../../packages/document/office-kit/README.zh.md)是 web-app 挂载的 Host 服务,因此所有加载 web-app 的应用(包括 `dsh web` 和 Desktop)都提供它以及 [`office` 工具](../../../packages/document/tool-office/README.zh.md)。该提供方及其 [`/locate` 入口](../../../packages/document/office-kit/README.zh.md#locate-kit)解析 Kit 的引擎,包括把原生引擎清单映射到解包后的实体目录。Desktop 打包只负责携带和解包引擎:携带目标声明的原生引擎;kit 未声明匹配的原生目标时携带 WASM;目标引擎缺失时,准备阶段在打包前拒绝。完整的 Office 依赖(包括 JavaScript 库以及所选引擎的可执行文件、数据、许可证和声明)解包到 `resources/app.asar.unpacked/dsh/node_modules/` 下。Desktop 壳在 [main.ts](../src/main.ts) 中传入 `DSH_PRIMARY_RUNTIME`,不传 Kit 位置。所有加载 web-app 的应用都提供 Office 技能;只有 Desktop 挂载内置 Python 环境(`workspace-dependencies`)。在 macOS 上,原生 helper 获得 [LibreOffice UNO 桥](https://github.com/LibreOffice/core/blob/master/sysui/desktop/macosx/hardened_runtime.xcent.in)所需的 JIT 权限。 `@deepseek-ai/dsh-experimental-cua-macos/native/bin` 下的 Computer Use helper 应用也整体解包到 `resources/app.asar.unpacked/dsh/node_modules/` 下,提供方打开该副本。
[Office 转换提供方](../../../packages/document/office-kit/README.zh.md)是 web-app 挂载的 Host 服务,因此所有加载 web-app 的应用(包括 `dsh web` 和 Desktop)都提供它以及 [Office 工具](../../../packages/document/tool-office/README.zh.md)。该提供方及其 [`/locate` 入口](../../../packages/document/office-kit/README.zh.md#locate-kit)解析 Kit 的引擎,包括把原生引擎清单映射到解包后的实体目录。Desktop 打包只负责携带和解包引擎:携带目标声明的原生引擎;kit 未声明匹配的原生目标时携带 WASM;目标引擎缺失时,准备阶段在打包前拒绝。完整的 Office 依赖(包括 JavaScript 库以及所选引擎的可执行文件、数据、许可证和声明)解包到 `resources/app.asar.unpacked/dsh/node_modules/` 下。Desktop 壳在 [main.ts](../src/main.ts) 中传入 `DSH_PRIMARY_RUNTIME`,不传 Kit 位置。所有加载 web-app 的应用都提供 Office 技能;只有 Desktop 挂载内置 Python 环境(`workspace-dependencies`)。在 macOS 上,原生 helper 获得 [LibreOffice UNO 桥](https://github.com/LibreOffice/core/blob/master/sysui/desktop/macosx/hardened_runtime.xcent.in)所需的 JIT 权限。 `@deepseek-ai/dsh-experimental-cua-macos/native/bin` 下的 Computer Use helper 应用也整体解包到 `resources/app.asar.unpacked/dsh/node_modules/` 下,提供方打开该副本。
打包应用运行编译后的 JavaScript 和预生成的 Typert 元数据,不编译 TypeScript 插件。源码级调试导航和编辑器声明仍可从开发包中获取。[复制规则测试](../tests/runtime-file-policy.spec.ts)覆盖排除项和保留资源;[产物 smoke](../tests/fixtures/runtime-payload-smoke.mjs) 在 Host smoke 和最终清单验证之前,使用 Electron RunAsNode 执行。产物 smoke 解析搜索工具使用的 ripgrep 可执行文件,并验证文本搜索和文件枚举。Windows 签名构建在依赖签名后运行这些检查;其他构建在 `prepare:dsh` 中运行。[Host smoke](../scripts/smoke-runtime.ts) 使用捆绑的 Python 创建 DOCX、XLSX 和 PPTX 输入,并通过真实 Office 提供方逐一执行:PDF 转换、PNG 渲染、转换为对应的 OpenDocument 格式,以及针对 XLSX 的重算,检查每个输出的签名。每个组装后的应用(包括目录包和未签名构建)都会针对 ASAR 重复产物和 Host 检查。归档完整性检查将归档内完整描述符与准备结果比对,并核对归档和解包目录中的文件内容与清单、归档内文件记录的执行标志,以及解包文件的物理权限。转换失败会在写入发布记录前终止打包;macOS DMG/ZIP 构建在公证前执行这些检查。
+4 -4
View File
@@ -27,7 +27,7 @@ export function apply(ctx) {
const names = (await ctx.skills.list()).map(skill => skill.name).filter(name => name.startsWith('office'))
const content = {}
for (const name of ['office', 'office-docx']) content[name] = (await ctx.skills.get(name))?.content ?? null
response.end(JSON.stringify({ names, content, officeKit: ctx.get('officeKit') !== undefined, tools: ctx.tools.schemas().map(tool => tool.name).filter(name => name === 'office') }))
response.end(JSON.stringify({ names, content, officeKit: ctx.get('officeKit') !== undefined, tools: ctx.tools.schemas().map(tool => tool.name).filter(name => name.startsWith('office_')) }))
} catch (error) {
response.statusCode = 500
response.end(String(error?.stack ?? error))
@@ -79,18 +79,18 @@ describe.skipIf(!existsSync(builtHost))('built Desktop Host Office resources', (
expect(probe.status, body).toBe(200)
const skills = JSON.parse(body) as { names: string[]; content: Record<string, string | null>; officeKit: boolean; tools: string[] }
expect(skills.officeKit).toBe(true)
// Agent presets, not the Host root, mount the office tool.
// Agent presets, not the Host root, mount the Office tools.
expect(skills.tools).toEqual([])
switch (mode) {
case 'complete':
expect(skills.names.toSorted()).toEqual(OFFICE_SKILLS)
expect(skills.content['office-docx']).toEqual(expect.any(String))
expect(skills.content.office).toContain('`office` tool')
expect(skills.content.office).toContain('`office_render`')
break
case 'missing-skill':
expect(skills.names.toSorted()).toEqual(OFFICE_SKILLS.filter(name => name !== 'office-docx'))
expect(skills.content['office-docx']).toBeNull()
expect(skills.content.office).toContain('`office` tool')
expect(skills.content.office).toContain('`office_render`')
break
case 'empty-runtime':
case 'relative-source':
@@ -9,9 +9,9 @@
- 'row "CONTEXT, Current runtime context. This snapshot supersedes earlier runtime-context snapshots. Current working directory: \"{{cwd}}/workspace\". Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}/workspace\". Some pl…"':
- cell "CONTEXT"
- 'cell "Current runtime context. This snapshot supersedes earlier runtime-context snapshots. Current working directory: \"{{cwd}}/workspace\". Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}/workspace\". Some pl…"'
- 'row "CONTEXT, <system-reminder> A skill is a reusable set of task-specific instructions. The following skills are available in this session: <available_skills> office: Create, edit, inspect, or convert Office documents, spreadsheets, presentations, and PDFs. Load to choose the relevant workflow. office-docx: Create, read, edit, and validate Word documents (.docx). office-pptx: Create, read, edit, and validate PowerPoint presentations (.pptx). office-xlsx: Read, create, edit, and validate Excel workbooks, data, and formul…"':
- 'row "CONTEXT, <system-reminder> A skill is a reusable set of task-specific instructions. The following skills are available in this session: <available_skills> office: Create or edit Office files; inspect Office files and PDFs. Load before rendering, conversion, or recalculation to enable office_render, office_convert, and office_recalculate next step. office-docx: Create, read, edit, and validate Word documents (.docx). office-pptx: Create, read, edit, and validate PowerPoint presentations (.pptx). office-xlsx: Read, cr…"':
- cell "CONTEXT"
- 'cell "<system-reminder> A skill is a reusable set of task-specific instructions. The following skills are available in this session: <available_skills> office: Create, edit, inspect, or convert Office documents, spreadsheets, presentations, and PDFs. Load to choose the relevant workflow. office-docx: Create, read, edit, and validate Word documents (.docx). office-pptx: Create, read, edit, and validate PowerPoint presentations (.pptx). office-xlsx: Read, create, edit, and validate Excel workbooks, data, and formul…"'
- 'cell "<system-reminder> A skill is a reusable set of task-specific instructions. The following skills are available in this session: <available_skills> office: Create or edit Office files; inspect Office files and PDFs. Load before rendering, conversion, or recalculation to enable office_render, office_convert, and office_recalculate next step. office-docx: Create, read, edit, and validate Word documents (.docx). office-pptx: Create, read, edit, and validate PowerPoint presentations (.pptx). office-xlsx: Read, cr…"'
- 'row "CONTEXT, Time sampled while preparing turn 1, step 1: 2026-01-15T{{clock}}+{{clock}}[Asia/Shanghai] Browser time zone for this request: Asia/Shanghai. Interpret otherwise-unqualified dates and times in this zone. Elapsed since the preceding model-visible message: unavailable."':
- cell "CONTEXT"
- 'cell "Time sampled while preparing turn 1, step 1: 2026-01-15T{{clock}}+{{clock}}[Asia/Shanghai] Browser time zone for this request: Asia/Shanghai. Interpret otherwise-unqualified dates and times in this zone. Elapsed since the preceding model-visible message: unavailable."'
+3 -1
View File
@@ -485,7 +485,9 @@ const EXPECTED_TOOLS = [
'job_output',
'list_agents',
'list_subagent_models',
'office',
'office_convert',
'office_recalculate',
'office_render',
'plugin_manager',
'present',
'read',
+5 -3
View File
@@ -4258,12 +4258,14 @@ export interface Config {
## `@deepseek-ai/dsh-tool-office`
- `inject`: `tools` · `fs` · `workingDirectory`
- `source`: [`packages/document/tool-office/src/index.ts:34`](../packages/document/tool-office/src/index.ts)
- `inject`: `tools` · `fs` · `workingDirectory` · `agents`
- `source`: [`packages/document/tool-office/src/index.ts:37`](../packages/document/tool-office/src/index.ts)
```ts config-catalog
/** Bounds on one render result; deployment attachment limits apply when they are lower. */
/** Activation skills and render bounds; lower deployment attachment limits take precedence. */
export interface Config {
/** Skill names whose successful loading admits all three tools from the following step. */
activationSkills: string[]
/** Maximum images one render returns, including worksheet fragments. */
maxImages: number
/** Maximum pixels of each image. */
+5 -3
View File
@@ -4260,12 +4260,14 @@ export interface Config {
## `@deepseek-ai/dsh-tool-office`
- `inject`: `tools` · `fs` · `workingDirectory`
- `source`: [`packages/document/tool-office/src/index.ts:34`](../packages/document/tool-office/src/index.ts)
- `inject`: `tools` · `fs` · `workingDirectory` · `agents`
- `source`: [`packages/document/tool-office/src/index.ts:37`](../packages/document/tool-office/src/index.ts)
```ts config-catalog
/** Bounds on one render result; deployment attachment limits apply when they are lower. */
/** Activation skills and render bounds; lower deployment attachment limits take precedence. */
export interface Config {
/** Skill names whose successful loading admits all three tools from the following step. */
activationSkills: string[]
/** Maximum images one render returns, including worksheet fragments. */
maxImages: number
/** Maximum pixels of each image. */
+4 -4
View File
@@ -13,8 +13,8 @@ Application listeners are outside this package matrix. Desktop Host subscribes t
| `agent-loop/config-start-failed` | `emit` | [`packages/core/agent-loop/src/index.ts:198`](../packages/core/agent-loop/src/index.ts) | [`agent-loop`](../packages/core/agent-loop) (`events.dispatch`) | - |
| `agent-preset/selected` | `emit` | [`packages/preset/agent-preset-registry/src/types.ts:66`](../packages/preset/agent-preset-registry/src/types.ts) | [`agent-preset-registry`](../packages/preset/agent-preset-registry) (`emit`) | [`cua`](../packages/experimental/cua), `remotes` |
| `agent/assistant-stream` | `emit` | [`packages/core/agent/src/runtime-types.ts:399`](../packages/core/agent/src/runtime-types.ts) | [`agent-loop`](../packages/core/agent-loop) (`emit`) | [`headless`](../packages/bundle/headless), `session-controller` |
| `agent/created` | `serial` | [`packages/core/agent/src/runtime-types.ts:290`](../packages/core/agent/src/runtime-types.ts) | [`agent`](../packages/core/agent) (`serial`) | [`agent-team`](../packages/team/agent-team), `browser-use-runtime`, `claude-code-mods`, [`creation-recommendations`](../packages/experimental/creation-recommendations), [`cua`](../packages/experimental/cua), [`file-reference-local`](../packages/context/file-reference-local), [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`hooks-claude-code`](../packages/experimental/hooks-claude-code), [`hooks-codex`](../packages/experimental/hooks-codex), `liveshare`, [`loader-smoke`](../packages/test-support/loader-smoke), [`permission-presets`](../packages/interaction/permission-presets), `session-controller`, [`tool-subagent`](../packages/subagent/tool-subagent) |
| `agent/disposed` | `emit` | [`packages/core/agent/src/runtime-types.ts:299`](../packages/core/agent/src/runtime-types.ts) | [`agent`](../packages/core/agent) (`events.dispatch`) | [`action-cards`](../packages/experimental/action-cards), [`agent-loop`](../packages/core/agent-loop), `claude-code-mods`, [`creation-recommendations`](../packages/experimental/creation-recommendations), [`file-reference-local`](../packages/context/file-reference-local), [`goal-round-driver`](../packages/goal/goal-round-driver), `server`, `session-controller`, [`subagent`](../packages/subagent/subagent), [`tool-subagent-control`](../packages/subagent/tool-subagent-control) |
| `agent/created` | `serial` | [`packages/core/agent/src/runtime-types.ts:290`](../packages/core/agent/src/runtime-types.ts) | [`agent`](../packages/core/agent) (`serial`) | `browser-use-runtime`, `claude-code-mods`, [`creation-recommendations`](../packages/experimental/creation-recommendations), [`cua`](../packages/experimental/cua), [`file-reference-local`](../packages/context/file-reference-local), [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`hooks-claude-code`](../packages/experimental/hooks-claude-code), [`hooks-codex`](../packages/experimental/hooks-codex), `liveshare`, [`loader-smoke`](../packages/test-support/loader-smoke), [`permission-presets`](../packages/interaction/permission-presets), `session-controller`, [`tool-subagent`](../packages/subagent/tool-subagent) |
| `agent/disposed` | `emit` | [`packages/core/agent/src/runtime-types.ts:299`](../packages/core/agent/src/runtime-types.ts) | [`agent`](../packages/core/agent) (`events.dispatch`) | [`action-cards`](../packages/experimental/action-cards), [`agent-loop`](../packages/core/agent-loop), `claude-code-mods`, [`creation-recommendations`](../packages/experimental/creation-recommendations), [`file-reference-local`](../packages/context/file-reference-local), [`goal-round-driver`](../packages/goal/goal-round-driver), `server`, `session-controller`, [`subagent`](../packages/subagent/subagent), [`tool-office`](../packages/document/tool-office), [`tool-subagent-control`](../packages/subagent/tool-subagent-control) |
| `agent/error` | `emit` | [`packages/core/agent/src/runtime-types.ts:429`](../packages/core/agent/src/runtime-types.ts) | [`agent-loop`](../packages/core/agent-loop) (`emit`) | [`acp`](../packages/acp/acp), [`deepseek-account`](../packages/credentials/deepseek-account), [`goal-round-driver`](../packages/goal/goal-round-driver), [`headless`](../packages/bundle/headless), `server`, `session-controller`, [`session-telemetry`](../packages/session/session-telemetry), [`subagent`](../packages/subagent/subagent) |
| `agent/inbox/claimed` | `emit` | [`packages/core/agent/src/runtime-types.ts:328`](../packages/core/agent/src/runtime-types.ts) | [`agent-loop`](../packages/core/agent-loop) (`emit`) | [`acp`](../packages/acp/acp), [`goal-round-driver`](../packages/goal/goal-round-driver), [`subagent`](../packages/subagent/subagent), [`tool-jobs`](../packages/jobs/tool-jobs), [`user-questions`](../packages/interaction/user-questions) |
| `agent/inbox/discarded` | `emit` | [`packages/core/agent/src/runtime-types.ts:336`](../packages/core/agent/src/runtime-types.ts) | [`agent-loop`](../packages/core/agent-loop) (`emit`) | [`goal-round-driver`](../packages/goal/goal-round-driver), [`subagent`](../packages/subagent/subagent), [`user-questions`](../packages/interaction/user-questions) |
@@ -73,7 +73,7 @@ Application listeners are outside this package matrix. Desktop Host subscribes t
| `session-telemetry/record` | `waterfall` | [`packages/session/session-telemetry/src/index.ts:44`](../packages/session/session-telemetry/src/index.ts) | [`session-telemetry`](../packages/session/session-telemetry) (`waterfall`) | - |
| `session/created` | `emit` | [`packages/core/session/src/index.ts:56`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | `server`, `session-controller`, [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry) |
| `session/disposed` | `emit` | [`packages/core/session/src/index.ts:65`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`agent-loop`](../packages/core/agent-loop), `file-upload`, `forge-session`, [`office-kit`](../packages/document/office-kit), `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-title`](../packages/session/session-title), `ui-trajectory`, [`workspace-changes`](../packages/deliverables/workspace-changes) |
| `session/event` | `emit` | [`packages/core/session/src/index.ts:76`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`acp`](../packages/acp/acp), [`agent-instructions`](../packages/context/agent-instructions), [`agent-loop`](../packages/core/agent-loop), [`agent-preset-registry`](../packages/preset/agent-preset-registry), `claude-code-mods`, `client-ui-forge`, [`compaction-basic`](../packages/compaction/compaction-basic), [`file-reference-local`](../packages/context/file-reference-local), `file-upload`, `forge-session`, [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`headless`](../packages/bundle/headless), [`loader-smoke`](../packages/test-support/loader-smoke), `product-analytics`, [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), `server`, `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-telemetry-otel`](../packages/session/session-telemetry-otel), [`session-title`](../packages/session/session-title), [`subagent`](../packages/subagent/subagent), [`token-meter`](../packages/llm/token-meter), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tool-jobs`](../packages/jobs/tool-jobs), `ui-trajectory`, [`user-questions`](../packages/interaction/user-questions), [`workspace-changes`](../packages/deliverables/workspace-changes) |
| `session/event` | `emit` | [`packages/core/session/src/index.ts:76`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`acp`](../packages/acp/acp), [`agent-instructions`](../packages/context/agent-instructions), [`agent-loop`](../packages/core/agent-loop), [`agent-preset-registry`](../packages/preset/agent-preset-registry), `claude-code-mods`, `client-ui-forge`, [`compaction-basic`](../packages/compaction/compaction-basic), [`file-reference-local`](../packages/context/file-reference-local), `file-upload`, `forge-session`, [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`headless`](../packages/bundle/headless), [`loader-smoke`](../packages/test-support/loader-smoke), `product-analytics`, [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), `server`, `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-telemetry-otel`](../packages/session/session-telemetry-otel), [`session-title`](../packages/session/session-title), [`subagent`](../packages/subagent/subagent), [`token-meter`](../packages/llm/token-meter), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tool-jobs`](../packages/jobs/tool-jobs), [`tool-office`](../packages/document/tool-office), `ui-trajectory`, [`user-questions`](../packages/interaction/user-questions), [`workspace-changes`](../packages/deliverables/workspace-changes) |
| `session/flush` | `parallel` | [`packages/core/session/src/index.ts:84`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-telemetry`](../packages/session/session-telemetry) |
| `settings/document-updated` | `emit` | [`packages/settings/settings/src/types.ts:75`](../packages/settings/settings/src/types.ts) | [`settings`](../packages/settings/settings) (`emit`) | `remotes` |
| `skills/change` | `emit` | [`packages/skill/skill/src/index.ts:296`](../packages/skill/skill/src/index.ts) | [`skill`](../packages/skill/skill) (`events.dispatch`) | - |
@@ -88,7 +88,7 @@ Application listeners are outside this package matrix. Desktop Host subscribes t
| `tools/post-execute` | `waterfall` | [`packages/core/tools/src/events.ts:41`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `claude-code-mods`, [`hooks-claude-code`](../packages/experimental/hooks-claude-code), [`hooks-codex`](../packages/experimental/hooks-codex), [`repeat-tool-reminder`](../packages/guard/repeat-tool-reminder), [`spill-policy`](../packages/spill/spill-policy), [`tool-fs-search`](../packages/fs/tool-fs-search) |
| `tools/pre-execute` | `waterfall` | [`packages/core/tools/src/events.ts:18`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `auto-review`, [`hooks-claude-code`](../packages/experimental/hooks-claude-code), [`hooks-codex`](../packages/experimental/hooks-codex), `liveshare`, [`tool-jobs`](../packages/jobs/tool-jobs), [`workspace-changes`](../packages/deliverables/workspace-changes) |
| `tools/ptc-dispatch-log` | `waterfall` | [`packages/core/tool-executor-ptc/src/runtime-types.ts:46`](../packages/core/tool-executor-ptc/src/runtime-types.ts) | [`tool-executor-ptc`](../packages/core/tool-executor-ptc) (`waterfall`) | [`spill-policy`](../packages/spill/spill-policy) |
| `tools/result` | `emit` | [`packages/core/tools/src/events.ts:49`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`events.dispatch`) | [`action-cards`](../packages/experimental/action-cards), [`agent-instructions`](../packages/context/agent-instructions), `claude-code-mods`, `forge-session`, `liveshare`, [`subagent`](../packages/subagent/subagent), [`tool-present`](../packages/deliverables/tool-present), `ui-trajectory` |
| `tools/result` | `emit` | [`packages/core/tools/src/events.ts:49`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`events.dispatch`) | [`action-cards`](../packages/experimental/action-cards), [`agent-instructions`](../packages/context/agent-instructions), `claude-code-mods`, `forge-session`, `liveshare`, [`subagent`](../packages/subagent/subagent), [`tool-office`](../packages/document/tool-office), [`tool-present`](../packages/deliverables/tool-present), `ui-trajectory` |
| `user-questions/request` | `waterfall` | [`packages/interaction/user-questions/src/types.ts:174`](../packages/interaction/user-questions/src/types.ts) | [`user-questions`](../packages/interaction/user-questions) (`waterfall`) | `remotes`, `server` |
| `web/providers-changed` | `emit` | [`packages/web/web/src/types.ts:21`](../packages/web/web/src/types.ts) | [`web`](../packages/web/web) (`events.dispatch`) | `remotes` |
| `webserver/index-inject` | `emit` | [`packages/host/webserver/src/index.ts:44`](../packages/host/webserver/src/index.ts) | `webserver` (`emit`) | `connection`, `inspector`, `modules`, `remote-access`, `shortcuts`, `ui-sidebar-documentpreview`, `ui-theme` |
+4 -4
View File
@@ -15,8 +15,8 @@
| `agent-loop/config-start-failed` | `emit` | [`packages/core/agent-loop/src/index.ts:198`](../packages/core/agent-loop/src/index.ts) | [`agent-loop`](../packages/core/agent-loop) (`events.dispatch`) | - |
| `agent-preset/selected` | `emit` | [`packages/preset/agent-preset-registry/src/types.ts:66`](../packages/preset/agent-preset-registry/src/types.ts) | [`agent-preset-registry`](../packages/preset/agent-preset-registry) (`emit`) | [`cua`](../packages/experimental/cua), `remotes` |
| `agent/assistant-stream` | `emit` | [`packages/core/agent/src/runtime-types.ts:399`](../packages/core/agent/src/runtime-types.ts) | [`agent-loop`](../packages/core/agent-loop) (`emit`) | [`headless`](../packages/bundle/headless), `session-controller` |
| `agent/created` | `serial` | [`packages/core/agent/src/runtime-types.ts:290`](../packages/core/agent/src/runtime-types.ts) | [`agent`](../packages/core/agent) (`serial`) | [`agent-team`](../packages/team/agent-team), `browser-use-runtime`, `claude-code-mods`, [`creation-recommendations`](../packages/experimental/creation-recommendations), [`cua`](../packages/experimental/cua), [`file-reference-local`](../packages/context/file-reference-local), [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`hooks-claude-code`](../packages/experimental/hooks-claude-code), [`hooks-codex`](../packages/experimental/hooks-codex), `liveshare`, [`loader-smoke`](../packages/test-support/loader-smoke), [`permission-presets`](../packages/interaction/permission-presets), `session-controller`, [`tool-subagent`](../packages/subagent/tool-subagent) |
| `agent/disposed` | `emit` | [`packages/core/agent/src/runtime-types.ts:299`](../packages/core/agent/src/runtime-types.ts) | [`agent`](../packages/core/agent) (`events.dispatch`) | [`action-cards`](../packages/experimental/action-cards), [`agent-loop`](../packages/core/agent-loop), `claude-code-mods`, [`creation-recommendations`](../packages/experimental/creation-recommendations), [`file-reference-local`](../packages/context/file-reference-local), [`goal-round-driver`](../packages/goal/goal-round-driver), `server`, `session-controller`, [`subagent`](../packages/subagent/subagent), [`tool-subagent-control`](../packages/subagent/tool-subagent-control) |
| `agent/created` | `serial` | [`packages/core/agent/src/runtime-types.ts:290`](../packages/core/agent/src/runtime-types.ts) | [`agent`](../packages/core/agent) (`serial`) | `browser-use-runtime`, `claude-code-mods`, [`creation-recommendations`](../packages/experimental/creation-recommendations), [`cua`](../packages/experimental/cua), [`file-reference-local`](../packages/context/file-reference-local), [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`hooks-claude-code`](../packages/experimental/hooks-claude-code), [`hooks-codex`](../packages/experimental/hooks-codex), `liveshare`, [`loader-smoke`](../packages/test-support/loader-smoke), [`permission-presets`](../packages/interaction/permission-presets), `session-controller`, [`tool-subagent`](../packages/subagent/tool-subagent) |
| `agent/disposed` | `emit` | [`packages/core/agent/src/runtime-types.ts:299`](../packages/core/agent/src/runtime-types.ts) | [`agent`](../packages/core/agent) (`events.dispatch`) | [`action-cards`](../packages/experimental/action-cards), [`agent-loop`](../packages/core/agent-loop), `claude-code-mods`, [`creation-recommendations`](../packages/experimental/creation-recommendations), [`file-reference-local`](../packages/context/file-reference-local), [`goal-round-driver`](../packages/goal/goal-round-driver), `server`, `session-controller`, [`subagent`](../packages/subagent/subagent), [`tool-office`](../packages/document/tool-office), [`tool-subagent-control`](../packages/subagent/tool-subagent-control) |
| `agent/error` | `emit` | [`packages/core/agent/src/runtime-types.ts:429`](../packages/core/agent/src/runtime-types.ts) | [`agent-loop`](../packages/core/agent-loop) (`emit`) | [`acp`](../packages/acp/acp), [`deepseek-account`](../packages/credentials/deepseek-account), [`goal-round-driver`](../packages/goal/goal-round-driver), [`headless`](../packages/bundle/headless), `server`, `session-controller`, [`session-telemetry`](../packages/session/session-telemetry), [`subagent`](../packages/subagent/subagent) |
| `agent/inbox/claimed` | `emit` | [`packages/core/agent/src/runtime-types.ts:328`](../packages/core/agent/src/runtime-types.ts) | [`agent-loop`](../packages/core/agent-loop) (`emit`) | [`acp`](../packages/acp/acp), [`goal-round-driver`](../packages/goal/goal-round-driver), [`subagent`](../packages/subagent/subagent), [`tool-jobs`](../packages/jobs/tool-jobs), [`user-questions`](../packages/interaction/user-questions) |
| `agent/inbox/discarded` | `emit` | [`packages/core/agent/src/runtime-types.ts:336`](../packages/core/agent/src/runtime-types.ts) | [`agent-loop`](../packages/core/agent-loop) (`emit`) | [`goal-round-driver`](../packages/goal/goal-round-driver), [`subagent`](../packages/subagent/subagent), [`user-questions`](../packages/interaction/user-questions) |
@@ -75,7 +75,7 @@
| `session-telemetry/record` | `waterfall` | [`packages/session/session-telemetry/src/index.ts:44`](../packages/session/session-telemetry/src/index.ts) | [`session-telemetry`](../packages/session/session-telemetry) (`waterfall`) | - |
| `session/created` | `emit` | [`packages/core/session/src/index.ts:56`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | `server`, `session-controller`, [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry) |
| `session/disposed` | `emit` | [`packages/core/session/src/index.ts:65`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`agent-loop`](../packages/core/agent-loop), `file-upload`, `forge-session`, [`office-kit`](../packages/document/office-kit), `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-title`](../packages/session/session-title), `ui-trajectory`, [`workspace-changes`](../packages/deliverables/workspace-changes) |
| `session/event` | `emit` | [`packages/core/session/src/index.ts:76`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`acp`](../packages/acp/acp), [`agent-instructions`](../packages/context/agent-instructions), [`agent-loop`](../packages/core/agent-loop), [`agent-preset-registry`](../packages/preset/agent-preset-registry), `claude-code-mods`, `client-ui-forge`, [`compaction-basic`](../packages/compaction/compaction-basic), [`file-reference-local`](../packages/context/file-reference-local), `file-upload`, `forge-session`, [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`headless`](../packages/bundle/headless), [`loader-smoke`](../packages/test-support/loader-smoke), `product-analytics`, [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), `server`, `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-telemetry-otel`](../packages/session/session-telemetry-otel), [`session-title`](../packages/session/session-title), [`subagent`](../packages/subagent/subagent), [`token-meter`](../packages/llm/token-meter), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tool-jobs`](../packages/jobs/tool-jobs), `ui-trajectory`, [`user-questions`](../packages/interaction/user-questions), [`workspace-changes`](../packages/deliverables/workspace-changes) |
| `session/event` | `emit` | [`packages/core/session/src/index.ts:76`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`acp`](../packages/acp/acp), [`agent-instructions`](../packages/context/agent-instructions), [`agent-loop`](../packages/core/agent-loop), [`agent-preset-registry`](../packages/preset/agent-preset-registry), `claude-code-mods`, `client-ui-forge`, [`compaction-basic`](../packages/compaction/compaction-basic), [`file-reference-local`](../packages/context/file-reference-local), `file-upload`, `forge-session`, [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`headless`](../packages/bundle/headless), [`loader-smoke`](../packages/test-support/loader-smoke), `product-analytics`, [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), `server`, `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-telemetry-otel`](../packages/session/session-telemetry-otel), [`session-title`](../packages/session/session-title), [`subagent`](../packages/subagent/subagent), [`token-meter`](../packages/llm/token-meter), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tool-jobs`](../packages/jobs/tool-jobs), [`tool-office`](../packages/document/tool-office), `ui-trajectory`, [`user-questions`](../packages/interaction/user-questions), [`workspace-changes`](../packages/deliverables/workspace-changes) |
| `session/flush` | `parallel` | [`packages/core/session/src/index.ts:84`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-telemetry`](../packages/session/session-telemetry) |
| `settings/document-updated` | `emit` | [`packages/settings/settings/src/types.ts:75`](../packages/settings/settings/src/types.ts) | [`settings`](../packages/settings/settings) (`emit`) | `remotes` |
| `skills/change` | `emit` | [`packages/skill/skill/src/index.ts:296`](../packages/skill/skill/src/index.ts) | [`skill`](../packages/skill/skill) (`events.dispatch`) | - |
@@ -90,7 +90,7 @@
| `tools/post-execute` | `waterfall` | [`packages/core/tools/src/events.ts:41`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `claude-code-mods`, [`hooks-claude-code`](../packages/experimental/hooks-claude-code), [`hooks-codex`](../packages/experimental/hooks-codex), [`repeat-tool-reminder`](../packages/guard/repeat-tool-reminder), [`spill-policy`](../packages/spill/spill-policy), [`tool-fs-search`](../packages/fs/tool-fs-search) |
| `tools/pre-execute` | `waterfall` | [`packages/core/tools/src/events.ts:18`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `auto-review`, [`hooks-claude-code`](../packages/experimental/hooks-claude-code), [`hooks-codex`](../packages/experimental/hooks-codex), `liveshare`, [`tool-jobs`](../packages/jobs/tool-jobs), [`workspace-changes`](../packages/deliverables/workspace-changes) |
| `tools/ptc-dispatch-log` | `waterfall` | [`packages/core/tool-executor-ptc/src/runtime-types.ts:46`](../packages/core/tool-executor-ptc/src/runtime-types.ts) | [`tool-executor-ptc`](../packages/core/tool-executor-ptc) (`waterfall`) | [`spill-policy`](../packages/spill/spill-policy) |
| `tools/result` | `emit` | [`packages/core/tools/src/events.ts:49`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`events.dispatch`) | [`action-cards`](../packages/experimental/action-cards), [`agent-instructions`](../packages/context/agent-instructions), `claude-code-mods`, `forge-session`, `liveshare`, [`subagent`](../packages/subagent/subagent), [`tool-present`](../packages/deliverables/tool-present), `ui-trajectory` |
| `tools/result` | `emit` | [`packages/core/tools/src/events.ts:49`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`events.dispatch`) | [`action-cards`](../packages/experimental/action-cards), [`agent-instructions`](../packages/context/agent-instructions), `claude-code-mods`, `forge-session`, `liveshare`, [`subagent`](../packages/subagent/subagent), [`tool-office`](../packages/document/tool-office), [`tool-present`](../packages/deliverables/tool-present), `ui-trajectory` |
| `user-questions/request` | `waterfall` | [`packages/interaction/user-questions/src/types.ts:174`](../packages/interaction/user-questions/src/types.ts) | [`user-questions`](../packages/interaction/user-questions) (`waterfall`) | `remotes`, `server` |
| `web/providers-changed` | `emit` | [`packages/web/web/src/types.ts:21`](../packages/web/web/src/types.ts) | [`web`](../packages/web/web) (`events.dispatch`) | `remotes` |
| `webserver/index-inject` | `emit` | [`packages/host/webserver/src/index.ts:44`](../packages/host/webserver/src/index.ts) | `webserver` (`emit`) | `connection`, `inspector`, `modules`, `remote-access`, `shortcuts`, `ui-sidebar-documentpreview`, `ui-theme` |
+3 -1
View File
@@ -1403,10 +1403,12 @@ flowchart TD
pkg_session_reference --> pkg_subagent
pkg_session_reference --> pkg_system_prompt
pkg_session_reference --> pkg_typert_protocol
pkg_tool_office --> pkg_agent
pkg_tool_office --> pkg_attachment
pkg_tool_office --> pkg_fs
pkg_tool_office --> pkg_llm
pkg_tool_office --> pkg_office_kit
pkg_tool_office --> pkg_skill
pkg_tool_office --> pkg_subagent
pkg_tool_office --> pkg_tools
pkg_tool_office --> pkg_working_directory
@@ -1879,7 +1881,7 @@ flowchart TD
| [`headless`](../packages/bundle/headless) | `bundle` | [`agent`](../packages/core/agent), [`agent-default-model`](../packages/core/agent-default-model), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`permission-presets`](../packages/interaction/permission-presets), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`session-query`](../packages/session-query/session-query), [`subagent`](../packages/subagent/subagent), [`user-approval`](../packages/interaction/user-approval) |
| [`compaction-basic`](../packages/compaction/compaction-basic) | `compaction` | [`agent`](../packages/core/agent), [`commands`](../packages/interaction/commands), [`compaction`](../packages/compaction/compaction), [`compaction-tool-result-pruner`](../packages/compaction/compaction-tool-result-pruner), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`token-meter`](../packages/llm/token-meter) |
| [`session-reference`](../packages/context/session-reference) | `context` | [`agent`](../packages/core/agent), [`compaction`](../packages/compaction/compaction), [`llm`](../packages/llm/llm), [`output-retention`](../packages/util/output-retention), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-query`](../packages/session-query/session-query), [`session-title`](../packages/session/session-title), [`spill`](../packages/spill/spill), [`subagent`](../packages/subagent/subagent), [`system-prompt`](../packages/core/system-prompt), [`typert-protocol`](../packages/typert/protocol) |
| [`tool-office`](../packages/document/tool-office) | `document` | [`attachment`](../packages/attachment/attachment), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`office-kit`](../packages/document/office-kit), [`subagent`](../packages/subagent/subagent), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) |
| [`tool-office`](../packages/document/tool-office) | `document` | [`agent`](../packages/core/agent), [`attachment`](../packages/attachment/attachment), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`office-kit`](../packages/document/office-kit), [`skill`](../packages/skill/skill), [`subagent`](../packages/subagent/subagent), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) |
| [`experimental-subagent-oar`](../packages/experimental/subagent-oar) | `experimental` | [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`subprocess`](../packages/subprocess/subprocess) |
| [`experimental-tool-subagent-oar`](../packages/experimental/tool-subagent-oar) | `experimental` | [`subagent`](../packages/subagent/subagent), [`tools`](../packages/core/tools) |
| [`hooks-claude-code`](../packages/experimental/hooks-claude-code) | `experimental` | [`agent`](../packages/core/agent), [`hook-protocol`](../packages/experimental/hook-protocol), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) |
+3 -1
View File
@@ -1405,10 +1405,12 @@ flowchart TD
pkg_session_reference --> pkg_subagent
pkg_session_reference --> pkg_system_prompt
pkg_session_reference --> pkg_typert_protocol
pkg_tool_office --> pkg_agent
pkg_tool_office --> pkg_attachment
pkg_tool_office --> pkg_fs
pkg_tool_office --> pkg_llm
pkg_tool_office --> pkg_office_kit
pkg_tool_office --> pkg_skill
pkg_tool_office --> pkg_subagent
pkg_tool_office --> pkg_tools
pkg_tool_office --> pkg_working_directory
@@ -1881,7 +1883,7 @@ flowchart TD
| [`headless`](../packages/bundle/headless) | `bundle` | [`agent`](../packages/core/agent), [`agent-default-model`](../packages/core/agent-default-model), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`permission-presets`](../packages/interaction/permission-presets), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`session-query`](../packages/session-query/session-query), [`subagent`](../packages/subagent/subagent), [`user-approval`](../packages/interaction/user-approval) |
| [`compaction-basic`](../packages/compaction/compaction-basic) | `compaction` | [`agent`](../packages/core/agent), [`commands`](../packages/interaction/commands), [`compaction`](../packages/compaction/compaction), [`compaction-tool-result-pruner`](../packages/compaction/compaction-tool-result-pruner), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`token-meter`](../packages/llm/token-meter) |
| [`session-reference`](../packages/context/session-reference) | `context` | [`agent`](../packages/core/agent), [`compaction`](../packages/compaction/compaction), [`llm`](../packages/llm/llm), [`output-retention`](../packages/util/output-retention), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-query`](../packages/session-query/session-query), [`session-title`](../packages/session/session-title), [`spill`](../packages/spill/spill), [`subagent`](../packages/subagent/subagent), [`system-prompt`](../packages/core/system-prompt), [`typert-protocol`](../packages/typert/protocol) |
| [`tool-office`](../packages/document/tool-office) | `document` | [`attachment`](../packages/attachment/attachment), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`office-kit`](../packages/document/office-kit), [`subagent`](../packages/subagent/subagent), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) |
| [`tool-office`](../packages/document/tool-office) | `document` | [`agent`](../packages/core/agent), [`attachment`](../packages/attachment/attachment), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`office-kit`](../packages/document/office-kit), [`skill`](../packages/skill/skill), [`subagent`](../packages/subagent/subagent), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) |
| [`experimental-subagent-oar`](../packages/experimental/subagent-oar) | `experimental` | [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`subprocess`](../packages/subprocess/subprocess) |
| [`experimental-tool-subagent-oar`](../packages/experimental/tool-subagent-oar) | `experimental` | [`subagent`](../packages/subagent/subagent), [`tools`](../packages/core/tools) |
| [`hooks-claude-code`](../packages/experimental/hooks-claude-code) | `experimental` | [`agent`](../packages/core/agent), [`hook-protocol`](../packages/experimental/hook-protocol), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) |
+4 -4
View File
@@ -3,11 +3,11 @@
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write docs/subsystems/office-kit.md
/office-kit:
en: c5b7b74dce426f0d
zh: 5900121507a6cb5f
en: ba1e27aece3a68c3
zh: 50ca71dd6c6a5438
/office-kit/ownership:
en: a5cf821f90b821ad
zh: 0fb670960ec4b771
en: fa3d0415d6cbcfd3
zh: f1f1a9641133f916
/office-kit/requests-and-results:
en: 4ae99f63ed85ce7f
zh: 0db77cfc734788b1
+3 -3
View File
@@ -2,15 +2,15 @@
English | [中文](office-kit.zh.md)
The [document package family](../../packages/document/README.md) renders, converts, and recalculates Office files on the Node Host. Consumers authorize source reads and own presentation; the shared provider owns the engine, bounded admission, transient output reuse, and the private output store. The [`office` tool](../../packages/document/tool-office/README.md) is the model-facing consumer; the provider itself creates no Session event.
The [document package family](../../packages/document/README.md) renders, converts, and recalculates Office files on the Node Host. Consumers authorize source reads and own presentation; the shared provider owns the engine, bounded admission, transient output reuse, and the private output store. The [`office_render`, `office_convert`, and `office_recalculate` tools](../../packages/document/tool-office/README.md) are the model-facing consumers; the provider itself creates no Session event.
## Ownership
| Owner | Responsibility |
|---|---|
| [office-kit](../../packages/document/office-kit/README.md) | `ctx.officeKit`: shared LibreOffice rendering, conversion, and recalculation, bounded admission, output caching, and the per-Session output store; `/locate`, whose contract the package README owns: the caller's Kit entry, engine manifests from that installation, and native paths mapped to ASAR unpacked directories |
| [tool-office](../../packages/document/tool-office/README.md) | The resident `office` tool: rendered images in tool results and converted files returned for a shell copy |
| [Web bundle](../../packages/bundle/web-app/README.md) and [SDK bundle](../../packages/bundle/sdk-app/README.md) | One configurable provider and the `office` tool shared by Host consumers |
| [tool-office](../../packages/document/tool-office/README.md) | The on-demand `office_render`, `office_convert`, and `office_recalculate` tools: rendered images in tool results and converted or recalculated files returned for a shell copy |
| [Web bundle](../../packages/bundle/web-app/README.md) and [SDK bundle](../../packages/bundle/sdk-app/README.md) | One configurable provider and `tool-office` shared by Host consumers |
| [Office preview Client](../../packages/client/ui-sidebar-documentpreview/README.md#office-preview) | Office extension selection, PDF reuse, and missing-font notices |
## Requests and results
+3 -3
View File
@@ -2,15 +2,15 @@
[English](office-kit.md) | 中文
[document 包族](../../packages/document/README.zh.md) 在 Node 宿主上渲染、转换 Office 文件并重算工作簿。消费者负责源文件读取授权与展示;共享提供方负责引擎、有界准入、临时输出复用和私有输出存储。[`office` 工具](../../packages/document/tool-office/README.zh.md)是面向模型的消费者;提供方本身不创建 Session 事件。
[document 包族](../../packages/document/README.zh.md) 在 Node 宿主上渲染、转换 Office 文件并重算工作簿。消费者负责源文件读取授权与展示;共享提供方负责引擎、有界准入、临时输出复用和私有输出存储。[`office_render`、`office_convert` 和 `office_recalculate` 工具](../../packages/document/tool-office/README.zh.md)是面向模型的消费者;提供方本身不创建 Session 事件。
## 所有权
| 所有者 | 职责 |
|---|---|
| [office-kit](../../packages/document/office-kit/README.zh.md) | `ctx.officeKit`:共享 LibreOffice 渲染、转换与重算,有界准入、输出缓存和按 Session 划分的输出存储;`/locate`(契约由包 README 拥有):调用方的 Kit 入口、从该安装定位的引擎清单,以及映射到 ASAR 解包目录的原生路径 |
| [tool-office](../../packages/document/tool-office/README.zh.md) | 常驻的 `office` 工具:工具结果中的渲染图片,以及供 shell 复制的转换文件 |
| [Web bundle](../../packages/bundle/web-app/README.zh.md)与 [SDK bundle](../../packages/bundle/sdk-app/README.zh.md) | 由宿主消费者共享的单个可配置提供方及 `office` 工具 |
| [tool-office](../../packages/document/tool-office/README.zh.md) | 按需激活的 `office_render`、`office_convert` 和 `office_recalculate` 工具:工具结果中的渲染图片,以及供 shell 复制的转换或重算文件 |
| [Web bundle](../../packages/bundle/web-app/README.zh.md)与 [SDK bundle](../../packages/bundle/sdk-app/README.zh.md) | 由宿主消费者共享的单个可配置提供方及 `tool-office` |
| [Office 预览 Client](../../packages/client/ui-sidebar-documentpreview/README.zh.md#office-preview) | Office 扩展名选择、PDF 复用和缺失字体提示 |
## 请求和结果
+24 -18
View File
@@ -9,8 +9,8 @@
en: 6cc2cd9ced70bb09
zh: 1c0e6cb4ba2ed637
/tool-schema-catalog/tool-package-map:
en: 7b5b99bcc5cd46f4
zh: c1697f88326440ff
en: 498f1cb807c03569
zh: 6653d3a378dd0439
/tool-schema-catalog/deepseek-ai-dsh-plugin-manager:
en: e0143916bb634762
zh: e0143916bb634762
@@ -72,8 +72,8 @@
en: 8c8643ef46fd075f
zh: 8c8643ef46fd075f
/tool-schema-catalog/deepseek-ai-dsh-tool-executor-ptc/run-code:
en: 7917e16cbc2c366f
zh: c39eb0420544f04a
en: a5d49232a604a2fb
zh: 720040d11a3e31c2
/tool-schema-catalog/deepseek-ai-dsh-plan-mode:
en: b500b530845e26a9
zh: b500b530845e26a9
@@ -89,9 +89,15 @@
/tool-schema-catalog/deepseek-ai-dsh-tool-office:
en: 8b0373f31520efe7
zh: 8b0373f31520efe7
/tool-schema-catalog/deepseek-ai-dsh-tool-office/office:
en: 039621e749cd26c2
zh: 5fadd41137e921d9
/tool-schema-catalog/deepseek-ai-dsh-tool-office/office-convert:
en: e63dea0f631fbb15
zh: c564452c0ae91632
/tool-schema-catalog/deepseek-ai-dsh-tool-office/office-recalculate:
en: 27a0ac973b1b9387
zh: 29b4dd44a3a6b1ef
/tool-schema-catalog/deepseek-ai-dsh-tool-office/office-render:
en: b5e52a86c0a3c122
zh: 636810250e6a0aaf
/tool-schema-catalog/deepseek-ai-dsh-tool-present:
en: f656575e6df094f6
zh: f656575e6df094f6
@@ -135,8 +141,8 @@
en: 07d595ce1f1a5184
zh: 07d595ce1f1a5184
/tool-schema-catalog/deepseek-ai-dsh-tool-fs/apply-patch:
en: 50b4939c9a1d96ac
zh: e733cc1156e2853c
en: 882f2fa9fac236d6
zh: e8320796a5cb038f
/tool-schema-catalog/deepseek-ai-dsh-tool-fs/edit:
en: 5b6a252adde51af6
zh: 7aa172a5d8b9cbd2
@@ -246,8 +252,8 @@
en: 8daafae6faf7898e
zh: 8daafae6faf7898e
/tool-schema-catalog/deepseek-ai-dsh-experimental-tool-subagent-oar/subagent-oar:
en: 4936c61a65f8cdb2
zh: 5a1bfbb9738a62a9
en: 6283c3023d6ea436
zh: 9c018b8c12a3f1e7
/tool-schema-catalog/deepseek-ai-dsh-tool-subagent:
en: 841abe0dd5913ea7
zh: 841abe0dd5913ea7
@@ -255,23 +261,23 @@
en: 0e21650bbe8c71c7
zh: fe4033efb38d51a3
/tool-schema-catalog/deepseek-ai-dsh-tool-subagent/subagent:
en: 9912eeda5bc40b43
zh: 0cb70f9a0d923bee
en: 430672da3c1a6ca6
zh: bd3a9ab4089f9dbb
/tool-schema-catalog/deepseek-ai-dsh-tool-subagent-control:
en: ab82e130c3413f04
zh: ab82e130c3413f04
/tool-schema-catalog/deepseek-ai-dsh-tool-subagent-control/interrupt-agent:
en: a622b15cc2598d51
zh: ece4b2af6a11c49c
zh: 48e1b05956d63e26
/tool-schema-catalog/deepseek-ai-dsh-tool-subagent-control/list-agents:
en: 8d50c6e19c9517ab
zh: 6ae97d046c5915db
en: a56168133c21c6a0
zh: f9df1c0fe49fa225
/tool-schema-catalog/deepseek-ai-dsh-tool-subagent-control/send-message:
en: b53326fedeab850d
zh: ecb75b6ce31da009
/tool-schema-catalog/deepseek-ai-dsh-tool-subagent-control/wait-agent:
en: 4b95d11b610d34ca
zh: 9b0d9b6012be30d8
en: f3cf5a0c56ddc07a
zh: 7f6754d71e1b4ae4
/tool-schema-catalog/deepseek-ai-dsh-tool-jobs:
en: 9be673b1604d0114
zh: 9be673b1604d0114
+66 -20
View File
@@ -24,7 +24,7 @@ This table connects model-visible tool names to the plugin package and service s
| `@deepseek-ai/dsh-tool-executor-ptc` | `run_code` | `ctx.workingDirectory (Agent executions)`, `ctx.tools`, `ctx.ptcRuntime`, `ctx.systemPrompt` | `tool/call`, `one tool/ptc-dispatch-start + tool/ptc-dispatch pair per bridged sub-call`, `tool/result` | - | The PTC executor exposes only run_code to the model and declares other visible capabilities in a generated SDK in the runtime’s language. Program bindings enter the shared guarded tool pipeline in submission order; concurrency-safe bodies overlap up to maxParallelSubCalls, and nested results remain linked to the outer program. The resolved timeout and maxSubCallsPerMinute set the total call allowance; exceeding it terminates the program. |
| `@deepseek-ai/dsh-plan-mode` | `exit_plan_mode` | `ctx.tools`, `ctx.systemPrompt`, `ctx.agents`, `ctx.userQuestions (execution time, opportunistic)` | `tool/call`, `plan/mode inactive on an approved review`, `tool/result` | - | exit_plan_mode stays in the model-facing schema while planning is inactive so transitions add no tool-catalog churn on top of the plan-policy change. Its execute path rejects calls outside plan mode; in plan mode it presents the plan over the user-questions seam (approve / keep planning with feedback), and approval logs plan mode inactive at the step boundary. |
| `@deepseek-ai/dsh-tool-bash` | `bash` | `ctx.workingDirectory`, `ctx.tools`, `ctx.shell`, `ctx.systemPrompt`, `ctx.shellEnv`, `ctx.jobs for run_in_background and the job-backed foreground path` | `tool/call`, `tool/result` | - | The bash tool is the model-facing consumer of the bash executor seam. With a job registry composed every call registers with the generic `ctx.jobs` runtime as it starts, collected/stopped through the `job_*` tools from `@deepseek-ai/dsh-tool-jobs`; without one, or with `enableRunInBackground: false`, the tool registers a foreground-only schema without the `run_in_background` parameter. |
| `@deepseek-ai/dsh-tool-office` | `office` | `ctx.workingDirectory`, `ctx.tools`, `ctx.fs`, `ctx.officeKit`, `ctx.attachments and ctx.llm for render` | `tool/call`, `tool/result with rendered image attachments`, `temporary converted files in the Office kit output store` | - | The tool is registered whether or not LibreOffice Kit is installed; calls then fail with the Office service's unavailable error. |
| `@deepseek-ai/dsh-tool-office` | `office_convert`, `office_recalculate`, `office_render` | `ctx.workingDirectory`, `ctx.tools`, `ctx.fs`, `ctx.agents`, `ctx.officeKit`, `ctx.attachments and ctx.llm for office_render` | `tool/call`, `tool/result with rendered image attachments`, `temporary converted files in the Office kit output store` | - | Declared to an Agent from the step after it successfully loads an Office skill, and kept while the previous request header declares an Office tool. Admitted calls fail with the Office service's unavailable error when LibreOffice Kit is not installed. |
| `@deepseek-ai/dsh-tool-present` | `present` | `ctx.workingDirectory`, `ctx.tools`, `ctx.fs`, `ctx.agents` | `tool/call`, `deliverables/presented after a successful final result`, `tool/result` | - | Deliveries belong to the calling Session; Web ui-deliverables supplies source-file opening and cards. |
| `@deepseek-ai/dsh-tool-pwsh` | `pwsh` | `ctx.workingDirectory`, `ctx.tools`, `ctx.shell`, `ctx.systemPrompt`, `ctx.shellEnv`, `ctx.jobs for run_in_background and the job-backed foreground path` | `tool/call`, `tool/result` | - | The pwsh tool is the PowerShell-dialect consumer of the bash executor seam for Windows compositions (a PowerShell executor such as `@deepseek-ai/dsh-pwsh-local` backs `ctx.shell`); it mirrors the bash tool call-for-call minus sandbox controls — `run_in_background` runs register with the generic `ctx.jobs` runtime and are collected/stopped through the `job_*` tools, and the managed `DSH_*` environment comes from `@deepseek-ai/dsh-shell-env`. Each call runs in a fresh process (no persistent PTY session), with native `C:\...` paths and `$env:NAME` variables. |
| `@deepseek-ai/dsh-tool-cordis` | `cordis_inspect_list`, `cordis_inspect_query` | `ctx.tools`, `ctx.cordisInspect` | `tool/call`, `tool/result` | - | Creator mode provides two read-only runtime inspection tools. The Cordis host runner supplies the inspection registry; Client queries require a connected page. Author persistent changes as bundles and install them with plugin_manager. |
@@ -739,30 +739,21 @@ The bash tool is the model-facing consumer of the bash executor seam. With a job
## `@deepseek-ai/dsh-tool-office`
### `office`
### `office_convert`
Render document pages as images you can view, convert a document to another format, or recalculate spreadsheet formulas. Accepts Word (doc, docx, odt), Excel (xls, xlsx, ods), and PowerPoint (ppt, pptx, odp) files; render also accepts PDF.
Convert a document to another format. Return a temporary file to copy to its destination with the shell.
```json
{
"type": "object",
"properties": {
"operation": {
"type": "string",
"description": "render returns page images; convert and recalculate return a temporary file to copy to its destination.",
"enum": [
"render",
"convert",
"recalculate"
]
},
"input": {
"type": "string",
"description": "Path of the document to read; it is not modified."
"description": "Path to doc, docx, odt, xls, xlsx, ods, ppt, pptx, or odp; not modified."
},
"format": {
"type": "string",
"description": "convert and recalculate: output format. Word converts to pdf, docx, odt, or txt; Excel to pdf, xlsx, ods, or csv; PowerPoint to pdf, pptx, or odp. recalculate writes xlsx or ods.",
"description": "Word: pdf, docx, odt, txt. Excel: pdf, xlsx, ods, csv. PowerPoint: pdf, pptx, odp.",
"enum": [
"pdf",
"docx",
@@ -775,28 +766,83 @@ Render document pages as images you can view, convert a document to another form
"odp"
]
},
"sheet": {
"type": "string",
"description": "Exact worksheet name for CSV only; required when the workbook has several sheets."
}
},
"required": [
"input",
"format"
]
}
```
Source: [`packages/document/tool-office/src/index.ts`](../packages/document/tool-office/src/index.ts)
### `office_recalculate`
Recalculate spreadsheet formulas. Return a temporary workbook to copy to its destination with the shell.
```json
{
"type": "object",
"properties": {
"input": {
"type": "string",
"description": "Path to an xls, xlsx, or ods workbook; not modified."
},
"format": {
"type": "string",
"description": "Output workbook format.",
"enum": [
"xlsx",
"ods"
]
}
},
"required": [
"input",
"format"
]
}
```
Source: [`packages/document/tool-office/src/index.ts`](../packages/document/tool-office/src/index.ts)
### `office_render`
Render document pages, slides, or worksheet areas as images you can view.
```json
{
"type": "object",
"properties": {
"input": {
"type": "string",
"description": "Path to doc, docx, odt, xls, xlsx, ods, ppt, pptx, odp, or pdf; not modified."
},
"pages": {
"type": "array",
"description": "render: one-based pages or slides; omit for all. Spreadsheets use sheet and range instead.",
"description": "Distinct one-based pages or slides; omit for all. Spreadsheets use sheet and range instead.",
"items": {
"type": "integer"
}
},
"sheet": {
"type": "string",
"description": "Exact worksheet name. render: omit to render every visible sheet. convert: required for CSV from a workbook with several sheets."
"description": "Exact worksheet name; omit to render every visible sheet."
},
"range": {
"type": "string",
"description": "render: A1 range in sheet, such as A1:H40; omit for the used area."
"description": "A1 range, such as A1:H40; requires sheet. Omit for the used area."
},
"dpi": {
"type": "integer",
"description": "render: resolution from 24 to 600; default 144."
"description": "Resolution from 24 to 600; default 144."
}
},
"required": [
"operation",
"input"
]
}
@@ -804,7 +850,7 @@ Render document pages as images you can view, convert a document to another form
Source: [`packages/document/tool-office/src/index.ts`](../packages/document/tool-office/src/index.ts)
The tool is registered whether or not LibreOffice Kit is installed; calls then fail with the Office service's unavailable error.
Declared to an Agent from the step after it successfully loads an Office skill, and kept while the previous request header declares an Office tool. Admitted calls fail with the Office service's unavailable error when LibreOffice Kit is not installed.
<a id="deepseek-aidsh-tool-present"></a>
+66 -20
View File
@@ -28,7 +28,7 @@
| `@deepseek-ai/dsh-tool-executor-ptc` | `run_code` | `ctx.workingDirectory (Agent executions)`、`ctx.tools`、`ctx.ptcRuntime`、`ctx.systemPrompt` | `tool/call`、`one tool/ptc-dispatch-start + tool/ptc-dispatch pair per bridged sub-call`、`tool/result` | - | PTC 执行器只向模型公开 run_code,并在运行时语言生成的 SDK 中声明其他可见能力。程序绑定按提交顺序进入共享的受守卫工具流水线;并行安全的函数体最多重叠 maxParallelSubCalls 个,嵌套结果保持与外层程序关联。最终超时时间与 maxSubCallsPerMinute 决定调用总额度;超限会终止程序。 |
| `@deepseek-ai/dsh-plan-mode` | `exit_plan_mode` | `ctx.tools`、`ctx.systemPrompt`、`ctx.agents`、`ctx.userQuestions (execution time, opportunistic)` | `tool/call`、`plan/mode inactive on an approved review`、`tool/result` | - | 规划未激活时,exit_plan_mode 仍保留在面向模型的 schema 中,这样状态转换不会在规划策略变更之外额外造成工具目录变动。其执行路径会拒绝规划模式之外的调用;在规划模式下,它通过用户交互 seam 提交计划(批准/根据反馈继续规划),批准后会在步骤边界记录规划模式已停用。 |
| `@deepseek-ai/dsh-tool-bash` | `bash` | `ctx.workingDirectory`、`ctx.tools`、`ctx.shell`、`ctx.systemPrompt`、`ctx.shellEnv`、`ctx.jobs for run_in_background and the job-backed foreground path` | `tool/call`、`tool/result` | - | bash 工具是 bash 执行器 seam 面向模型的消费方。组合中有 job 注册表时,每次调用一启动就注册到通用 `ctx.jobs` 运行时,并通过 `job_*` 工具(来自 `@deepseek-ai/dsh-tool-jobs`)收集/停止;没有注册表或 `enableRunInBackground: false` 时,工具注册不带 `run_in_background` 参数的纯前台 schema。 |
| `@deepseek-ai/dsh-tool-office` | `office` | `ctx.workingDirectory`、`ctx.tools`、`ctx.fs`、`ctx.officeKit`、`ctx.attachments and ctx.llm for render` | `tool/call`、`tool/result with rendered image attachments`、`temporary converted files in the Office kit output store` | - | 无论是否安装 LibreOffice Kit,该工具都会注册;未安装时调用以 Office 服务的 unavailable 错误失败。 |
| `@deepseek-ai/dsh-tool-office` | `office_convert`、`office_recalculate`、`office_render` | `ctx.workingDirectory`、`ctx.tools`、`ctx.fs`、`ctx.agents`、`ctx.officeKit`、`ctx.attachments and ctx.llm for office_render` | `tool/call`、`tool/result with rendered image attachments`、`temporary converted files in the Office kit output store` | - | Agent 成功加载 Office 技能后,从下一步起向其声明这些工具;上一次请求头已声明 Office 工具时继续保留。未安装 LibreOffice Kit 时,已声明工具的调用以 Office 服务的 unavailable 错误失败。 |
| `@deepseek-ai/dsh-tool-present` | `present` | `ctx.workingDirectory`、`ctx.tools`, `ctx.fs`, `ctx.agents` | `tool/call`, `deliverables/presented 在成功的最终结果之后`, `tool/result` | - | 交付归调用方 Session 所有;Web ui-deliverables 提供源文件打开与卡片。 |
| `@deepseek-ai/dsh-tool-pwsh` | `pwsh` | `ctx.workingDirectory`、`ctx.tools`、`ctx.shell`、`ctx.systemPrompt`、`ctx.shellEnv`、`ctx.jobs for run_in_background and the job-backed foreground path` | `tool/call`、`tool/result` | - | pwsh 工具是 Windows 组合中 bash 执行器 seam 的 PowerShell 方言消费方(由 `@deepseek-ai/dsh-pwsh-local` 等 PowerShell 执行器为 `ctx.shell` 提供后端);除沙箱接口外,它逐项对应 bash 工具调用。使用 `run_in_background` 的运行会注册到通用 `ctx.jobs` 运行时,并通过 `job_*` 工具收集/停止;托管的 `DSH_*` 环境来自 `@deepseek-ai/dsh-shell-env`。每次调用都在新进程中运行,不使用持久 PTY 会话。路径采用原生 `C:\...` 形式,变量采用 `$env:NAME`。 |
| `@deepseek-ai/dsh-tool-cordis` | `cordis_inspect_list`, `cordis_inspect_query` | `ctx.tools`, `ctx.cordisInspect` | `tool/call`, `tool/result` | - | 创造模式提供两个只读运行时检查工具。Cordis host runner 提供检查注册表;Client 查询需要已连接页面。持久化变更编写为组合包,再通过 plugin_manager 安装。 |
@@ -743,30 +743,21 @@ bash 工具是 bash 执行器 seam 面向模型的消费方。组合中有 job
## `@deepseek-ai/dsh-tool-office`
### `office`
### `office_convert`
将文档页面渲染为你可以查看的图片、把文档转换为另一种格式,或重算电子表格公式。接受 Word(doc、docx、odt)、Excel(xls、xlsx、ods)和 PowerPoint(ppt、pptx、odp)文件;render 还接受 PDF。
将文档转换为另一种格式。返回一个临时文件,用 shell 将其复制到目标位置。
```json
{
"type": "object",
"properties": {
"operation": {
"type": "string",
"description": "render returns page images; convert and recalculate return a temporary file to copy to its destination.",
"enum": [
"render",
"convert",
"recalculate"
]
},
"input": {
"type": "string",
"description": "Path of the document to read; it is not modified."
"description": "Path to doc, docx, odt, xls, xlsx, ods, ppt, pptx, or odp; not modified."
},
"format": {
"type": "string",
"description": "convert and recalculate: output format. Word converts to pdf, docx, odt, or txt; Excel to pdf, xlsx, ods, or csv; PowerPoint to pdf, pptx, or odp. recalculate writes xlsx or ods.",
"description": "Word: pdf, docx, odt, txt. Excel: pdf, xlsx, ods, csv. PowerPoint: pdf, pptx, odp.",
"enum": [
"pdf",
"docx",
@@ -779,28 +770,83 @@ bash 工具是 bash 执行器 seam 面向模型的消费方。组合中有 job
"odp"
]
},
"sheet": {
"type": "string",
"description": "Exact worksheet name for CSV only; required when the workbook has several sheets."
}
},
"required": [
"input",
"format"
]
}
```
来源: [`packages/document/tool-office/src/index.ts`](../packages/document/tool-office/src/index.ts)
### `office_recalculate`
重算电子表格公式。返回一个临时工作簿,用 shell 将其复制到目标位置。
```json
{
"type": "object",
"properties": {
"input": {
"type": "string",
"description": "Path to an xls, xlsx, or ods workbook; not modified."
},
"format": {
"type": "string",
"description": "Output workbook format.",
"enum": [
"xlsx",
"ods"
]
}
},
"required": [
"input",
"format"
]
}
```
来源: [`packages/document/tool-office/src/index.ts`](../packages/document/tool-office/src/index.ts)
### `office_render`
将文档页面、幻灯片或工作表区域渲染为你可以查看的图片。
```json
{
"type": "object",
"properties": {
"input": {
"type": "string",
"description": "Path to doc, docx, odt, xls, xlsx, ods, ppt, pptx, odp, or pdf; not modified."
},
"pages": {
"type": "array",
"description": "render: one-based pages or slides; omit for all. Spreadsheets use sheet and range instead.",
"description": "Distinct one-based pages or slides; omit for all. Spreadsheets use sheet and range instead.",
"items": {
"type": "integer"
}
},
"sheet": {
"type": "string",
"description": "Exact worksheet name. render: omit to render every visible sheet. convert: required for CSV from a workbook with several sheets."
"description": "Exact worksheet name; omit to render every visible sheet."
},
"range": {
"type": "string",
"description": "render: A1 range in sheet, such as A1:H40; omit for the used area."
"description": "A1 range, such as A1:H40; requires sheet. Omit for the used area."
},
"dpi": {
"type": "integer",
"description": "render: resolution from 24 to 600; default 144."
"description": "Resolution from 24 to 600; default 144."
}
},
"required": [
"operation",
"input"
]
}
@@ -808,7 +854,7 @@ bash 工具是 bash 执行器 seam 面向模型的消费方。组合中有 job
来源: [`packages/document/tool-office/src/index.ts`](../packages/document/tool-office/src/index.ts)
无论是否安装 LibreOffice Kit,该工具都会注册;未安装时调用以 Office 服务的 unavailable 错误失败。
Agent 成功加载 Office 技能后,从下一步起向其声明这些工具;上一次请求头已声明 Office 工具时继续保留。未安装 LibreOffice Kit 时,已声明工具的调用以 Office 服务的 unavailable 错误失败。
<a id="deepseek-aidsh-tool-present"></a>
@@ -1,16 +0,0 @@
# Bilingual-pair consistency record for guide.md (docs/i18n/README.md): per heading
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write docs/upgrade-guide/v0.2.2-alpha.2/office-operation-skills/guide.md
/:
en: c4efaffe96465341
zh: 90eca88068e877cf
/office-operation-skills-are-removed:
en: f1302fdba1384201
zh: ad39cc10dd5ee7f2
/office-operation-skills-are-removed/change:
en: 6ceaf46b175af656
zh: ce56c4b9d93b646e
/office-operation-skills-are-removed/migration:
en: c01c3d9a75a3560a
zh: 2430873dac35c23c
@@ -1,31 +0,0 @@
---
kind: upgrade-guide
description: "The bundled `office-render`, `office-recalculate`, and `office-export-pdf` skills are removed; Office operations call the `office` tool directly."
---
# Office operation skills are removed
English | [中文](guide.zh.md)
## Change
`@deepseek-ai/dsh-skill-office` registered seven skills: the `office` router, the `office-docx`, `office-pptx`, and `office-xlsx` authoring skills, and the `office-render`, `office-recalculate`, and `office-export-pdf` operation skills. It now registers only the router and the three authoring skills. The router and the authoring skills direct rendering, recalculation, and PDF export to the [`office` tool](../../../../packages/document/tool-office/README.md) without a separate skill load.
The skill catalog and the `/` menu no longer list the three operation skills, and `skill` calls or `/office-render`, `/office-recalculate`, and `/office-export-pdf` invocations that name them find no skill. Recorded Sessions keep their earlier skill calls and results.
This affects:
- users who invoke the three skills from the `/` menu;
- prompts, skills, and scripts that tell a model to load them;
- tests and tools that expect the seven-skill catalog;
- deployments that set `assetRoot` of the `skill-office` row to their own copy of the skill folders.
## Migration
1. Replace each invocation or load of a removed skill with a request that calls the `office` tool with the matching operation:
- `office-render`: `operation: "render"`;
- `office-recalculate`: `operation: "recalculate"` with `format: "xlsx"` or `"ods"`;
- `office-export-pdf`: `operation: "convert"` with `format: "pdf"`.
2. Update expected skill lists to `office`, `office-docx`, `office-pptx`, and `office-xlsx`.
3. In a copy referenced by `assetRoot`, replace the four remaining folders with those from the installed package's `assets/` and delete `office-render/`, `office-recalculate/`, and `office-export-pdf/`; the provider no longer reads them.
4. Open a new Session and confirm that the `/` menu lists the four Office skills, and that a request to render a document produces an `office` tool call without a skill load other than `office` or an authoring skill.
@@ -1,31 +0,0 @@
---
kind: upgrade-guide
description: "内置的 `office-render`、`office-recalculate` 和 `office-export-pdf` 技能已移除;Office 操作直接调用 `office` 工具。"
---
# 移除 Office 操作技能
[English](guide.md) | 中文
## 变更
`@deepseek-ai/dsh-skill-office` 原先注册七个技能:`office` 路由,`office-docx`、`office-pptx` 和 `office-xlsx` 创作技能,以及 `office-render`、`office-recalculate` 和 `office-export-pdf` 操作技能。现在它只注册路由和三个创作技能。路由和创作技能把渲染、重算和 PDF 导出交给 [`office` 工具](../../../../packages/document/tool-office/README.zh.md),无需另外加载技能。
技能目录和 `/` 菜单不再列出这三个操作技能;指名它们的 `skill` 调用,以及 `/office-render`、`/office-recalculate`、`/office-export-pdf` 调用都找不到技能。已录制的 Session 保留原有的技能调用和结果。
受影响的有:
- 从 `/` 菜单调用这三个技能的用户;
- 指示模型加载它们的提示词、技能和脚本;
- 期望七个技能目录的测试和工具;
- 把 `skill-office` 条目的 `assetRoot` 指向自有技能目录副本的部署。
## 迁移
1. 把每处对已移除技能的调用或加载,改为让模型以对应操作调用 `office` 工具:
- `office-render`:`operation: "render"`;
- `office-recalculate`:`operation: "recalculate"` 并带 `format: "xlsx"` 或 `"ods"`;
- `office-export-pdf`:`operation: "convert"` 并带 `format: "pdf"`。
2. 把期望的技能列表更新为 `office`、`office-docx`、`office-pptx` 和 `office-xlsx`。
3. 在 `assetRoot` 引用的副本中,用已安装包 `assets/` 下的对应目录替换其余四个目录,并删除 `office-render/`、`office-recalculate/` 和 `office-export-pdf/`;提供方不再读取它们。
4. 新建一个 Session,确认 `/` 菜单列出四个 Office 技能,并确认渲染文档的请求会调用 `office` 工具,且除 `office` 或创作技能外不加载其他技能。
@@ -0,0 +1,16 @@
# Bilingual-pair consistency record for guide.md (docs/i18n/README.md): per heading
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write docs/upgrade-guide/v0.2.2-alpha.2/office-operation-tools/guide.md
/:
en: f25812af9f761878
zh: 3a8dbcde68ed75c9
/office-operation-skills-are-replaced-by-office-tools:
en: 4cbd51f0c6f0a9b9
zh: 2dffded2531f5144
/office-operation-skills-are-replaced-by-office-tools/change:
en: 63cc30fc8082d93e
zh: f5e1e4c54aac8bfc
/office-operation-skills-are-replaced-by-office-tools/migration:
en: 4b5517aad30b382e
zh: 9e648a24c9d67b55
@@ -0,0 +1,49 @@
---
kind: upgrade-guide
description: "The `office-render`, `office-recalculate`, and `office-export-pdf` skills, the skill-office `node` and `cli` keys, and two Office CLI environment variables are removed; Office operations use skill-activated tools."
---
# Office operation skills are replaced by Office tools
English | [中文](guide.zh.md)
## Change
`@deepseek-ai/dsh-skill-office` no longer registers the `office-render`, `office-recalculate`, and `office-export-pdf` skills; it registers the `office` router and the `office-docx`, `office-pptx`, and `office-xlsx` authoring skills. Invoking or loading a removed skill finds no skill. After an Office skill loads, the model calls [`office_render`, `office_convert`, and `office_recalculate`](../../../../packages/document/tool-office/README.md) from the following step.
Configuration changes:
| Removed | Replacement |
|---|---|
| `skill-office` keys `node` and `cli` | None; the Office tools run conversions in the Host |
| `DSH_BUNDLED_OFFICE_CLI` and `DSH_BUNDLED_OFFICE_NODE` | None; no component reads them |
| `DSH_BUNDLED_PRIMARY_RUNTIME` | `DSH_PRIMARY_RUNTIME` |
`skill-office` gains `pythonEnvironment`. Its default, `'workspace-dependencies'`, directs the Python skills to `load_workspace_dependencies`; a composition without `@deepseek-ai/dsh-tool-workspace-dependencies` must set `'user'`. `DSH_BUNDLED_OFFICE_SKILLS` keeps its meaning.
The Office tools run the native LibreOffice Kit engine in the Host process, outside the shell sandbox and PTC permissions, so it parses untrusted documents with the Host user's permissions; inputs remain subject to the filesystem backend's read authority. The `office-kit` row gains `outputDirectory` (default `$DSH_HOME/office-kit/outputs`), `outputRetentionMs`, and `maxOutputStoreBytes`.
The Web profile, and the SDK profile without a primary runtime, now list the Office skills in the first request context and `/` menu.
This affects users and prompts that use the removed skills, compositions and launchers that set the removed keys or variables, copies of the skill folders referenced by `assetRoot`, saved `standard` or `ptc` presets, deployments that rely on the shell sandbox for document parsing, and tests that pin the first request context or `/` menu.
## Migration
1. Replace each removed skill with loading `office` and calling the matching tool:
- `office-render`: `office_render`;
- `office-recalculate`: `office_recalculate` with `format: "xlsx"` or `"ods"`;
- `office-export-pdf`: `office_convert` with `format: "pdf"`.
2. Remove `node` and `cli` from every `skill-office` row in `cordis.yml`, patches, and overlays. Set `pythonEnvironment: user` unless the composition mounts `@deepseek-ai/dsh-tool-workspace-dependencies`.
3. Compositions that mount `@deepseek-ai/dsh-skill-office` without the shipped bundles also mount `@deepseek-ai/dsh-office-kit` and `@deepseek-ai/dsh-tool-office`.
4. In launchers, stop setting `DSH_BUNDLED_OFFICE_CLI` and `DSH_BUNDLED_OFFICE_NODE`, and rename `DSH_BUNDLED_PRIMARY_RUNTIME` to `DSH_PRIMARY_RUNTIME`.
5. In a copy referenced by `assetRoot`, replace the four remaining folders with the installed package's `assets/` and delete the three removed skill folders.
6. A `standard` or `ptc` preset saved from the Agent Preset editor replaces the shipped plugin list, so its Sessions lack the Office tools. Add this row to the saved list, or to `config.plugins` of the `preset-standard` or `preset-ptc` row in `$DSH_HOME/profiles/<profile>/cordis.patch.yml` (`<profile>`: `web` or `desktop`):
```yaml
- id: tool-office
name: '@deepseek-ai/dsh-tool-office'
```
7. Deployments that require sandboxed document parsing omit `@deepseek-ai/dsh-tool-office`.
8. Update expected first request contexts and `/` menus to include the Office skills.
9. Confirm: in a new `standard` or `ptc` Session, after `/office`, a PDF export request produces an `office_convert` call that returns a temporary PDF path or the `unavailable` message.
@@ -0,0 +1,49 @@
---
kind: upgrade-guide
description: "删除 `office-render`、`office-recalculate` 和 `office-export-pdf` 技能、skill-office 的 `node` 和 `cli` 配置键,以及两个 Office CLI 环境变量;Office 操作改用由技能激活的工具。"
---
# Office 操作技能由 Office 工具取代
[English](guide.md) | 中文
## 变更
`@deepseek-ai/dsh-skill-office` 不再注册 `office-render`、`office-recalculate` 和 `office-export-pdf` 技能,只注册 `office` 路由技能,以及 `office-docx`、`office-pptx` 和 `office-xlsx` 编写技能。调用或加载已删除的技能会找不到技能。加载 Office 技能后,模型从下一步起调用 [`office_render`、`office_convert` 和 `office_recalculate`](../../../../packages/document/tool-office/README.zh.md)。
配置变化:
| 已删除 | 替代 |
|---|---|
| `skill-office` 配置键 `node` 和 `cli` | 无;Office 工具在 Host 中执行转换 |
| `DSH_BUNDLED_OFFICE_CLI` 和 `DSH_BUNDLED_OFFICE_NODE` | 无;不再有组件读取它们 |
| `DSH_BUNDLED_PRIMARY_RUNTIME` | `DSH_PRIMARY_RUNTIME` |
`skill-office` 新增 `pythonEnvironment`。默认值 `'workspace-dependencies'` 让 Python 技能调用 `load_workspace_dependencies`;没有挂载 `@deepseek-ai/dsh-tool-workspace-dependencies` 的组合必须设为 `'user'`。`DSH_BUNDLED_OFFICE_SKILLS` 含义不变。
Office 工具在 Host 进程内运行原生 LibreOffice Kit 引擎,不受 shell 沙箱和 PTC 权限约束,因此以 Host 用户的权限解析不可信的文档;输入仍受文件系统后端的读取授权限制。`office-kit` 条目新增 `outputDirectory`(默认 `$DSH_HOME/office-kit/outputs`)、`outputRetentionMs` 和 `maxOutputStoreBytes`。
Web profile,以及没有 primary runtime 的 SDK profile,现在会在首次请求上下文和 `/` 菜单中列出 Office 技能。
受影响的有:使用已删除技能的用户和提示词,设置了已删除配置键或环境变量的组合和启动器,`assetRoot` 引用的技能目录副本,已保存的 `standard` 或 `ptc` 预设,依赖 shell 沙箱解析文档的部署,以及固定了首次请求上下文或 `/` 菜单的测试。
## 迁移
1. 把每个已删除的技能替换为加载 `office` 并调用对应工具:
- `office-render`:`office_render`;
- `office-recalculate`:`office_recalculate`,`format` 为 `"xlsx"` 或 `"ods"`;
- `office-export-pdf`:`office_convert`,`format` 为 `"pdf"`。
2. 从 `cordis.yml`、patch 和 overlay 的所有 `skill-office` 行中删除 `node` 和 `cli`。除非组合挂载了 `@deepseek-ai/dsh-tool-workspace-dependencies`,否则设置 `pythonEnvironment: user`。
3. 不使用随发行版 bundle、自行挂载 `@deepseek-ai/dsh-skill-office` 的组合,同时挂载 `@deepseek-ai/dsh-office-kit` 和 `@deepseek-ai/dsh-tool-office`。
4. 在启动器中不再设置 `DSH_BUNDLED_OFFICE_CLI` 和 `DSH_BUNDLED_OFFICE_NODE`,并把 `DSH_BUNDLED_PRIMARY_RUNTIME` 改名为 `DSH_PRIMARY_RUNTIME`。
5. 在 `assetRoot` 引用的副本中,用已安装包 `assets/` 下的对应目录替换其余四个目录,并删除三个已删除技能的目录。
6. 在 Agent 预设编辑器中保存过的 `standard` 或 `ptc` 预设会替换随发行版提供的插件列表,因此其 Session 没有 Office 工具。把下面这一行加入已保存的列表,或加入 `$DSH_HOME/profiles/<profile>/cordis.patch.yml` 中 `preset-standard` 或 `preset-ptc` 行的 `config.plugins`(`<profile>`:`web` 或 `desktop`):
```yaml
- id: tool-office
name: '@deepseek-ai/dsh-tool-office'
```
7. 需要在沙箱中解析文档的部署不挂载 `@deepseek-ai/dsh-tool-office`。
8. 更新首次请求上下文和 `/` 菜单的预期结果,加入 Office 技能。
9. 确认:在 `standard` 或 `ptc` 的新 Session 中执行 `/office` 后,导出 PDF 的请求会产生一次 `office_convert` 调用,返回临时 PDF 路径或 `unavailable` 消息。
@@ -1,16 +0,0 @@
# Bilingual-pair consistency record for guide.md (docs/i18n/README.md): per heading
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write docs/upgrade-guide/v0.2.2-alpha.2/office-tool/guide.md
/:
en: f0d0ff45b1a6e1ba
zh: ebba4868e2b8b524
/office-operations-use-the-office-tool:
en: 23561ffd67a7f731
zh: 5c04aeac11f2c529
/office-operations-use-the-office-tool/change:
en: 2f411d25e158f91d
zh: b257c20dc7fccd2b
/office-operations-use-the-office-tool/migration:
en: 91150015dc40719f
zh: 74536832842a7da5
@@ -1,44 +0,0 @@
---
kind: upgrade-guide
description: "Office operations move from shell-run Kit CLI paths to the Host-run office tool; renders save no image files, skill-office loses node and cli and gains pythonEnvironment, and Web and SDK mount Office skills."
---
# Office operations use the `office` tool
English | [中文](guide.zh.md)
## Change
Office rendering, conversion, and recalculation no longer run the LibreOffice Kit CLI through the shell. The [`@deepseek-ai/dsh-tool-office`](../../../../packages/document/tool-office/README.md) package registers a resident `office` tool. The shipped SDK profile and the `standard` and `ptc` presets of the Web and Desktop profiles mount it, so their requests declare it; `minimal` does not. Configurations and plugins that used the CLI path are affected:
| Removed | Replacement |
|---|---|
| `skill-office` configuration keys `node` and `cli` | None; the Office skills direct operations to the `office` tool |
| Node/CLI paths in the Office skills | The `office` tool; [removed operation skills](../office-operation-skills/guide.md) |
| `DSH_BUNDLED_OFFICE_CLI` and `DSH_BUNDLED_OFFICE_NODE` | None; no component reads them |
| `DSH_BUNDLED_PRIMARY_RUNTIME` | `DSH_PRIMARY_RUNTIME` |
`DSH_BUNDLED_OFFICE_SKILLS` and `DSH_PRIMARY_RUNTIME` keep their meaning. The `office-kit` row gains `outputDirectory`, `outputRetentionMs`, and `maxOutputStoreBytes`.
`render` returns page images only for the model to view and saves no PNG or other image file. Converted and recalculated files return as temporary paths under `$DSH_HOME/office-kit/outputs` for the model to copy with the shell. A request to export pages as images gets an offer of a PDF export; for a file, call `office` with `operation: "convert"` and `format: "pdf"`.
The tool runs model-started Office work in the native LibreOffice Kit engine inside the Host process through `ctx.officeKit`, outside the shell sandbox and PTC permissions; inputs remain subject to the filesystem backend's read authority. The native parser processes untrusted documents with the Host user's permissions, affecting deployments that relied on the shell sandbox for document parsing.
`skill-office` gains `pythonEnvironment`. Its default, `'workspace-dependencies'`, directs the Python skills to `load_workspace_dependencies`; a composition without `@deepseek-ai/dsh-tool-workspace-dependencies` must set `'user'`.
The Web and SDK profiles mount the Office skills by default, including without a primary runtime; new Sessions list them in the first request context and `/` menu.
## Migration
1. Remove `node` and `cli` from every `skill-office` row in `cordis.yml`, patches, and overlays.
2. Compositions that mount `@deepseek-ai/dsh-skill-office` without the shipped bundles also mount `@deepseek-ai/dsh-office-kit` and `@deepseek-ai/dsh-tool-office`, and set `pythonEnvironment: user` unless they mount `@deepseek-ai/dsh-tool-workspace-dependencies`.
3. Stop setting `DSH_BUNDLED_OFFICE_CLI` and `DSH_BUNDLED_OFFICE_NODE` in launchers.
4. Update expected first request contexts and `/` menus of Web or SDK Sessions to include the Office skills.
5. A `standard` or `ptc` preset saved from the Agent Preset editor replaces the shipped plugin list for that preset id, so its sessions lack the `office` tool. Add this row to the saved list in the editor, or to `config.plugins` of the `preset-standard` or `preset-ptc` row in `$DSH_HOME/profiles/<profile>/cordis.patch.yml` (`<profile>`: `web` or `desktop`), then start a new session:
```yaml
- id: tool-office
name: '@deepseek-ai/dsh-tool-office'
```
6. Confirm: a new `standard` or `ptc` Session declares `office`, and `office` with `operation: "convert"` and `format: "pdf"` returns a temporary PDF path or the `unavailable` message.
@@ -1,44 +0,0 @@
---
kind: upgrade-guide
description: "Office 操作从经 shell 执行的 Kit CLI 路径改为在 Host 内运行的 office 工具;渲染不保存图片文件,skill-office 删除 node 和 cli 并新增 pythonEnvironment,Web 和 SDK 默认挂载 Office 技能。"
---
# Office 操作改用 `office` 工具
[English](guide.md) | 中文
## 变更
Office 渲染、转换和重算不再通过 shell 运行 LibreOffice Kit CLI。[`@deepseek-ai/dsh-tool-office`](../../../../packages/document/tool-office/README.zh.md) 包注册常驻的 `office` 工具。随发行版提供的 SDK profile,以及 Web 和 Desktop profile 的 `standard`、`ptc` 预设挂载该工具,因此其请求会声明它;`minimal` 不挂载。使用过 CLI 路径的配置和插件受到影响:
| 已删除 | 替代 |
|---|---|
| `skill-office` 配置键 `node` 和 `cli` | 无;Office 技能让模型调用 `office` 工具执行操作 |
| Office 技能中的 Node/CLI 路径 | `office` 工具;[已删除的操作技能](../office-operation-skills/guide.zh.md) |
| `DSH_BUNDLED_OFFICE_CLI` 和 `DSH_BUNDLED_OFFICE_NODE` | 无;不再有组件读取它们 |
| `DSH_BUNDLED_PRIMARY_RUNTIME` | `DSH_PRIMARY_RUNTIME` |
`DSH_BUNDLED_OFFICE_SKILLS` 和 `DSH_PRIMARY_RUNTIME` 含义不变。`office-kit` 行新增 `outputDirectory`、`outputRetentionMs` 和 `maxOutputStoreBytes`。
`render` 只返回供模型查看的页面图片,不保存 PNG 或其他图片文件。转换和重算的文件以 `$DSH_HOME/office-kit/outputs` 下的临时路径返回,由模型用 shell 复制。把页面导出为图片的请求会得到导出 PDF 的建议;需要文件时,以 `operation: "convert"` 和 `format: "pdf"` 调用 `office`。
该工具通过 `ctx.officeKit` 在 Host 进程内用原生 LibreOffice Kit 引擎执行由模型发起的 Office 操作,不受 shell 沙箱和 PTC 权限约束;输入仍受文件系统后端读取权限的约束。原生解析器以 Host 用户的权限处理不可信的文档,依赖 shell 沙箱约束文档解析的部署因此受到影响。
`skill-office` 新增 `pythonEnvironment`。默认值 `'workspace-dependencies'` 让 Python 技能调用 `load_workspace_dependencies`;没有挂载 `@deepseek-ai/dsh-tool-workspace-dependencies` 的组合必须设为 `'user'`。
Web 和 SDK profile 默认挂载 Office 技能,没有 primary runtime 时也挂载;新 Session 会在首条请求上下文和 `/` 菜单中列出它们。
## 迁移
1. 从 `cordis.yml`、patch 和 overlay 的所有 `skill-office` 行中删除 `node` 和 `cli`。
2. 不使用随发行版 bundle、自行挂载 `@deepseek-ai/dsh-skill-office` 的组合,同时挂载 `@deepseek-ai/dsh-office-kit` 和 `@deepseek-ai/dsh-tool-office`;除非挂载了 `@deepseek-ai/dsh-tool-workspace-dependencies`,否则设置 `pythonEnvironment: user`。
3. 不再在启动器中设置 `DSH_BUNDLED_OFFICE_CLI` 和 `DSH_BUNDLED_OFFICE_NODE`。
4. 把 Web 或 SDK Session 首条请求上下文和 `/` 菜单的预期结果更新为包含 Office 技能。
5. 在 Agent 预设编辑器中保存过的 `standard` 或 `ptc` 预设会按预设 id 替换随发行版提供的插件列表,因此其 Session 没有 `office` 工具。请在编辑器中把下面这一行加入已保存的列表,或加入 `$DSH_HOME/profiles/<profile>/cordis.patch.yml` 中 `preset-standard` 或 `preset-ptc` 行的 `config.plugins`(`<profile>`:`web` 或 `desktop`),然后新建 Session:
```yaml
- id: tool-office
name: '@deepseek-ai/dsh-tool-office'
```
6. 确认:`standard` 或 `ptc` 的新 Session 声明了 `office`;以 `operation: "convert"` 和 `format: "pdf"` 调用 `office` 会返回临时 PDF 路径或 `unavailable` 消息。
+2 -2
View File
@@ -15,8 +15,8 @@
en: ffc55792d6e922e1
zh: 83bd759638857e2d
/packages/package-groups:
en: 6a4fc6ef106d30c0
zh: 438f34cfb37d6f41
en: 704e948001e25580
zh: dcfbb1b483d2a95a
/packages/release-expectations:
en: 236081c1659b25ab
zh: 809110adf003802e
+1 -1
View File
@@ -57,7 +57,7 @@ Every package lives in exactly one group; new packages join existing groups, and
| [`experimental/`](experimental/README.md) | Capabilities under evaluation; [status and support policy](experimental/README.md#status) |
| [`workflow/`](workflow/README.md) | Workflow seam, PTC process engine, and the model-facing `workflow` tool |
| [`web/`](web/README.md) | Web capability family: seam, search/fetch providers, model-facing web tools |
| [`document/`](document/README.md) | Shared Host Office rendering, conversion, and recalculation, the `office` tool, and Kit engine resolution |
| [`document/`](document/README.md) | Shared Host Office rendering, conversion, and recalculation, the Office tools, and Kit engine resolution |
| [`attachment/`](attachment/README.md) | Durable attachment identity, validation, local content-addressed storage |
| [`spill/`](spill/README.md) | Spill capability family: storage seam, local impl, tool-result spill policy |
| [`todo/`](todo/README.md) | The model-facing `todo_write` tool |
+1 -1
View File
@@ -57,7 +57,7 @@ harness 由 `packages/` 下的 npm 包组装而成,按能力系列分组:会
| [`experimental/`](experimental/README.zh.md) | 仍在评估中的能力;[状态与支持策略](experimental/README.zh.md#status) |
| [`workflow/`](workflow/README.zh.md) | 工作流 seam、PTC 进程引擎、面向模型的 `workflow` 工具 |
| [`web/`](web/README.zh.md) | Web 能力系列:seam、搜索/获取提供方、面向模型的 Web 工具 |
| [`document/`](document/README.zh.md) | 共享宿主 Office 渲染、转换与重算、`office` 工具与 Kit 引擎解析 |
| [`document/`](document/README.zh.md) | 共享宿主 Office 渲染、转换与重算、Office 工具与 Kit 引擎解析 |
| [`attachment/`](attachment/README.zh.md) | 持久附件标识、校验、本地内容寻址存储 |
| [`spill/`](spill/README.zh.md) | spill 能力系列:存储 seam、本地实现、工具结果 spill 策略 |
| [`todo/`](todo/README.zh.md) | 面向模型的 `todo_write` 工具 |
+2 -2
View File
@@ -15,8 +15,8 @@
en: 4e53164159b5ce41
zh: 89582dc0294d0776
/deepseek-ai-dsh-sdk-app/use-this-package:
en: 1bdee1369e136a4e
zh: 4397802ec1f2998d
en: b8bd8cefbb8c12a0
zh: 2a3df8cb862a3f7f
/deepseek-ai-dsh-sdk-app/model-experience:
en: 215e7ba838619b7b
zh: a311da3843709f90
+1 -1
View File
@@ -37,7 +37,7 @@ The SDK uses the base `read`, `write`, and `edit` defaults. To add `str_replace_
The model can use [`plugin_manager`](../../boot/plugin-manager/README.md) in native and PTC modes. Every action, including listing, requires full access or approval for that call. The default workspace-write/ask policy needs a client approval responder: enable `approvalRequests` and handle `approval/request` through `harness.client.onRequest()`, or supply an approver in the composition. Without one, the operation is refused as unavailable. For Python package installation/removal, explicitly prepare Node and pnpm with `download_primary_runtime()` before starting the runtime; the packaged launcher then supplies them to plugin management without requiring system pnpm. Without a selected payload, package operations need `pnpm` on `PATH` or an explicit `plugin-manager.pnpmCommand`. See the [interactive approval example](../../../python/sdk/examples/manage_plugins.py). Saved profile changes report `restart-required` with `no-hmr`; the current runtime and its sessions retain their tools until the caller closes and starts the runtime again. Set `tool-plugin-manager.disabled: true` through a profile patch to hide this tool. The standalone `sdk-minimal` profile does not include it.
The Python runtime exposes explicitly downloaded authoring resources and Office sidecars to this profile. `DSH_PRIMARY_RUNTIME` overrides the authoring payload; an empty value disables its query. Office skills, the Office kit, and the [`office` tool](../../document/tool-office/README.md) always load: with an authoring payload the skills use its Office assets and bundled Python environment; without one they use the packaged assets and direct the model to the user's existing Python. The tool reports an unavailable LibreOffice Kit until an Office sidecar is downloaded or selected. Profile patches can disable `skill-office` or replace its `assetRoot` independently of `workspace-dependencies`; filesystem skills with the same name take precedence. See the [runtime package](../../../python/sdk-runtime/README.md) for downloads and configuration.
The Python runtime exposes explicitly downloaded authoring resources and Office sidecars to this profile. `DSH_PRIMARY_RUNTIME` overrides the authoring payload; an empty value disables its query. Office skills, the Office kit, and the [Office tools](../../document/tool-office/README.md) always load: with an authoring payload the skills use its Office assets and bundled Python environment; without one they use the packaged assets and direct the model to the user's existing Python. The tool reports an unavailable LibreOffice Kit until an Office sidecar is downloaded or selected. Profile patches can disable `skill-office` or replace its `assetRoot` independently of `workspace-dependencies`; filesystem skills with the same name take precedence. See the [runtime package](../../../python/sdk-runtime/README.md) for downloads and configuration.
-----
+1 -1
View File
@@ -37,7 +37,7 @@ SDK 使用 base 默认提供的 `read`、`write` 和 `edit`。要添加 `str_rep
模型可以在 native 和 PTC 模式下使用 [`plugin_manager`](../../boot/plugin-manager/README.zh.md)。每个操作(包括列举)都要求完整权限或本次调用的批准。默认 workspace-write/ask 策略需要客户端审批应答方:启用 `approvalRequests`,并通过 `harness.client.onRequest()` 处理 `approval/request`,或在组合中提供审批器。没有应答方时,操作因 unavailable 被拒绝。Python 安装/移除包时,先显式调用 `download_primary_runtime()` 准备 Node 和 pnpm,再启动运行时;打包启动器会将它们提供给插件管理,无需系统 pnpm。未选择载荷时,包操作仍要求 `PATH` 中有 `pnpm`,或显式配置 `plugin-manager.pnpmCommand`。可运行的接入方式见[交互审批示例](../../../python/sdk/examples/manage_plugins.py)。保存的 profile 变更返回 `restart-required` 和 `no-hmr`;当前运行时及其会话保留原有工具,直到调用方关闭并重新启动运行时。通过 profile patch 设置 `tool-plugin-manager.disabled: true` 可隐藏此工具。独立的 `sdk-minimal` profile 不包含它。
Python 运行时向本 profile 提供显式下载的创作资源和 Office sidecar。`DSH_PRIMARY_RUNTIME` 覆盖创作载荷;空值禁用其查询。Office skills、Office 套件和 [`office` 工具](../../document/tool-office/README.zh.md)总是加载:有创作载荷时 skills 使用其 Office assets 和内置 Python 环境;没有时使用包内 assets,并指引模型使用用户已有的 Python。下载或选择 Office sidecar 之前,工具报告 LibreOffice Kit 不可用。Profile patch 可独立于 `workspace-dependencies` 禁用 `skill-office` 或替换其 `assetRoot`;同名文件系统 skills 优先。下载与配置见[运行时包](../../../python/sdk-runtime/README.zh.md)。
Python 运行时向本 profile 提供显式下载的创作资源和 Office sidecar。`DSH_PRIMARY_RUNTIME` 覆盖创作载荷;空值禁用其查询。Office skills、Office 套件和 [Office 工具](../../document/tool-office/README.zh.md)总是加载:有创作载荷时 skills 使用其 Office assets 和内置 Python 环境;没有时使用包内 assets,并指引模型使用用户已有的 Python。下载或选择 Office sidecar 之前,工具报告 LibreOffice Kit 不可用。Profile patch 可独立于 `workspace-dependencies` 禁用 `skill-office` 或替换其 `assetRoot`;同名文件系统 skills 优先。下载与配置见[运行时包](../../../python/sdk-runtime/README.zh.md)。
-----
+2 -2
View File
@@ -28,7 +28,7 @@
# DSH_PRIMARY_RUNTIME names the primary runtime; the packaged launcher fills it
# from its download cache when unset, and an empty value opts out. Each row can
# be patched independently. Office skills and the office tool always load. With
# be patched independently. Office skills and the Office tools always load. With
# a primary runtime the skills use its Office assets and Python environment;
# without one the expressions evaluate to `undefined`, which the skill-office
# schema treats as unset, so the packaged assets and the user's Python apply.
@@ -39,7 +39,7 @@
config:
outputDirectory: !!js dshHomePath('office-kit', 'outputs')
# The office tool stays registered without Kit; calls report the service's unavailable error.
# The Office tools stay registered without Kit; calls report the service's unavailable error.
- id: tool-office
name: '@deepseek-ai/dsh-tool-office'
+2 -2
View File
@@ -33,8 +33,8 @@
en: fdf38cb6e1b24464
zh: c14a8bcac9d4e5cd
/deepseek-ai-dsh-web-app/understand-the-implementation:
en: 236bda6ec3762617
zh: daf55f213f2e2ea4
en: 495b52ed02770027
zh: 4d8c676220125691
/deepseek-ai-dsh-web-app/understand-the-implementation/patch-semantics:
en: a6d126f30b1594d7
zh: 7f0ccc8a55d6f743
+1 -1
View File
@@ -100,7 +100,7 @@ Each browser session selects a shipped preset (`standard` by default). The Agent
<details>
<summary>Implementation internals — click to expand</summary>
The bundle is one patch layer of five files plus one runtime glue plugin: `cordis.patch.yml` carries the host rows and the preset registry, and each `presets/<id>.patch.yml` inserts one shipped preset declaration, applied in the order `dsh.bundle.patch` lists them. The storage stack and projection cache come from `dsh-base`; the web overlay's workspace and message-feedback rows consume that shared `storageDomain` service. The patch restates the surface-specific values the base deliberately omits, inserts the web-only host rows and browser roster, then moves the agent plane behind presets. The glue plugin owns dist serving, the advertised application URL, the plain-HTTP exposure warning, the bash variable, and the readiness announcements. The `office-kit` row mounts one lazy [Office conversion provider](../../document/office-kit/README.md) for Host consumers, including Desktop compositions using this bundle, and keeps converted files under `$DSH_HOME/office-kit/outputs`. The `standard` and `ptc` presets mount the resident [`office` tool](../../document/tool-office/README.md) in every profile, whether or not Kit is installed; the `minimal` preset omits it. The conversion service's Remote methods authorize preview reads, while Document Preview owns the Office viewer and Client cache.
The bundle is one patch layer of five files plus one runtime glue plugin: `cordis.patch.yml` carries the host rows and the preset registry, and each `presets/<id>.patch.yml` inserts one shipped preset declaration, applied in the order `dsh.bundle.patch` lists them. The storage stack and projection cache come from `dsh-base`; the web overlay's workspace and message-feedback rows consume that shared `storageDomain` service. The patch restates the surface-specific values the base deliberately omits, inserts the web-only host rows and browser roster, then moves the agent plane behind presets. The glue plugin owns dist serving, the advertised application URL, the plain-HTTP exposure warning, the bash variable, and the readiness announcements. The `office-kit` row mounts one lazy [Office conversion provider](../../document/office-kit/README.md) for Host consumers, including Desktop compositions using this bundle, and keeps converted files under `$DSH_HOME/office-kit/outputs`. The `standard` and `ptc` presets mount the [Office tools](../../document/tool-office/README.md) in every profile, whether or not Kit is installed, and declare them after an Office skill loads; the `minimal` preset omits them. The conversion service's Remote methods authorize preview reads, while Document Preview owns the Office viewer and Client cache.
The `skill-office` row mounts the [Office skills](../../skill/skill-office/README.md) in every profile. Outside Desktop it selects `pythonEnvironment: 'user'` and reads `DSH_BUNDLED_OFFICE_SKILLS`, which only the [Python SDK launcher](../../../python/sdk-runtime/README.md) sets; an unset variable keeps the packaged assets. Desktop also mounts the bundled dependency-query row, reads the skills from the carrier's primary runtime, and keeps the default `pythonEnvironment: 'workspace-dependencies'`; other profiles leave the dependency-query row disabled. The [Desktop application](../../../apps/desktop/README.md#bundled-workspace-dependencies) owns resource packaging.
+1 -1
View File
@@ -100,7 +100,7 @@ dsh --profile web --no-open --host "$(hostname -i | awk '{print $1}')" --public-
<details>
<summary>实现细节——点击展开</summary>
此 bundle 由一层五个文件的补丁和一个运行时胶水插件组成:`cordis.patch.yml` 承载宿主行和 preset 注册表,每个 `presets/<id>.patch.yml` 插入一条随发行版交付的 preset 声明,按 `dsh.bundle.patch` 列出的顺序应用。存储栈与投影缓存来自 `dsh-base`;Web 叠加层的工作区和消息反馈条目消费共享的 `storageDomain` 服务。补丁重述 base 有意省略的界面专用值,插入 Web 专用宿主条目和浏览器插件列表,再将 Agent 层移到预设后面。胶水插件负责 dist 服务、公告应用 URL、明文 HTTP 暴露警告、bash 变量和就绪通知。`office-kit` 条目为宿主消费者挂载一个延迟创建引擎的 [Office 转换提供方](../../document/office-kit/README.zh.md),使用此 bundle 的 Desktop 组合也共享该提供方,转换后的文件保存在 `$DSH_HOME/office-kit/outputs`。`standard` 和 `ptc` 预设在所有 profile 中挂载常驻的 [`office` 工具](../../document/tool-office/README.zh.md),无论是否安装 Kit;`minimal` 预设不挂载它。转换服务的 Remote 方法负责预览读取授权,Document Preview 负责 Office 查看器和客户端缓存。
此 bundle 由一层五个文件的补丁和一个运行时胶水插件组成:`cordis.patch.yml` 承载宿主行和 preset 注册表,每个 `presets/<id>.patch.yml` 插入一条随发行版交付的 preset 声明,按 `dsh.bundle.patch` 列出的顺序应用。存储栈与投影缓存来自 `dsh-base`;Web 叠加层的工作区和消息反馈条目消费共享的 `storageDomain` 服务。补丁重述 base 有意省略的界面专用值,插入 Web 专用宿主条目和浏览器插件列表,再将 Agent 层移到预设后面。胶水插件负责 dist 服务、公告应用 URL、明文 HTTP 暴露警告、bash 变量和就绪通知。`office-kit` 条目为宿主消费者挂载一个延迟创建引擎的 [Office 转换提供方](../../document/office-kit/README.zh.md),使用此 bundle 的 Desktop 组合也共享该提供方,转换后的文件保存在 `$DSH_HOME/office-kit/outputs`。`standard` 和 `ptc` 预设在所有 profile 中挂载 [Office 工具](../../document/tool-office/README.zh.md),无论是否安装 Kit,并在加载 Office 技能后声明它们;`minimal` 预设不挂载它们。转换服务的 Remote 方法负责预览读取授权,Document Preview 负责 Office 查看器和客户端缓存。
`skill-office` 行在所有 profile 中挂载 [Office 技能](../../skill/skill-office/README.zh.md)。Desktop 之外选择 `pythonEnvironment: 'user'`,并读取 `DSH_BUNDLED_OFFICE_SKILLS`;只有 [Python SDK 启动器](../../../python/sdk-runtime/README.zh.md)会设置该变量,未设置时保留包内 assets。Desktop 还挂载内置依赖查询行,从载体的主运行时读取技能,并保留默认的 `pythonEnvironment: 'workspace-dependencies'`;其他 profile 禁用依赖查询行。资源打包由 [Desktop 应用](../../../apps/desktop/README.zh.md#bundled-workspace-dependencies)负责。
+1
View File
@@ -218,6 +218,7 @@
"@deepseek-ai/cordis": "workspace:~",
"@deepseek-ai/cordis-plugin-include": "workspace:~",
"@deepseek-ai/cordis-plugin-loader": "workspace:~",
"@deepseek-ai/dsh-agent": "workspace:*",
"@deepseek-ai/dsh-agent-loop-testkit": "workspace:*",
"@deepseek-ai/dsh-fs": "workspace:*",
"@deepseek-ai/dsh-fs-local": "workspace:*",
@@ -1,4 +1,4 @@
/** Web application Office rows over a real Loader tree: skills, profile gating, Python, the preset office tool, and failure containment. */
/** Web application Office rows over a real Loader tree: skills, profile gating, Python, preset Office tools, and failure containment. */
import { cp, mkdir, mkdtemp, realpath, rm, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
@@ -6,12 +6,15 @@ import { dirname, join, sep } from 'node:path'
import { fileURLToPath } from 'node:url'
import { Context } from '@deepseek-ai/cordis'
import Loader from '@deepseek-ai/cordis-plugin-loader'
import AgentRegistry from '@deepseek-ai/dsh-agent'
import { loadOverlayPatches } from '@deepseek-ai/dsh-app-boot'
import { provideWorkingDirectoryFixture } from '@deepseek-ai/dsh-agent-loop-testkit'
import LocalFileSystem from '@deepseek-ai/dsh-fs-local'
import { dshHomePath } from '@deepseek-ai/dsh-home-paths'
import { ToolCallId } from '@deepseek-ai/dsh-llm'
import OfficeKit from '@deepseek-ai/dsh-office-kit'
import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { resolveKitModule } from '@deepseek-ai/dsh-office-kit/locate'
import SkillRegistry from '@deepseek-ai/dsh-skill'
import * as SkillOffice from '@deepseek-ai/dsh-skill-office'
@@ -32,6 +35,7 @@ vi.mock('@deepseek-ai/dsh-office-kit/locate', async (original) => {
const assets = fileURLToPath(new URL('../../../skill/skill-office/assets/', import.meta.url))
const names = ['office', 'office-docx', 'office-pptx', 'office-xlsx']
const ROWS = ['office-kit', 'tool-office', 'workspace-dependencies', 'skill-office']
const OFFICE_TOOLS = ['office_convert', 'office_recalculate', 'office_render']
afterEach(() => { vi.unstubAllEnvs() })
@@ -42,7 +46,7 @@ function presetPlugins(preset: string): { id: string; name: string }[] {
return (row!.config as { plugins: { id: string; name: string }[] }).plugins
}
it('mounts the office tool in the standard and PTC presets and omits it from the minimal preset', () => {
it('mounts the Office tools in the standard and PTC presets and omits it from the minimal preset', () => {
const office = (preset: string) => presetPlugins(preset).filter(row => row.id === 'tool-office').map(row => row.name)
expect(office('standard')).toEqual(['@deepseek-ai/dsh-tool-office'])
expect(office('ptc')).toEqual(['@deepseek-ai/dsh-tool-office'])
@@ -76,6 +80,8 @@ async function boot(
ctx.provide('dshHomePath', dshHomePath)
provideWorkingDirectoryFixture(ctx, workspace)
await ctx.plugin(SystemPrompt)
await ctx.plugin(SessionProjectionRegistry)
await ctx.plugin(AgentRegistry)
await ctx.plugin(ToolRuntime)
await ctx.plugin(NativeToolExecutor)
await ctx.plugin(SkillRegistry)
@@ -99,7 +105,22 @@ async function boot(
return { ctx, root, workspace, entries }
}
it('mounts Desktop skills from the primary runtime beside the resident office tool', async () => {
/** Convert through `office_convert` as an Agent whose previous request declared the Office tools. */
async function convertReport(ctx: Context, workspace: string, callId: string) {
const id = SessionId(callId)
const session = Session.create(id, [], { version: SESSION_FORMAT_VERSION, id, createdAt: 0, cwd: workspace, isSeeded: false })
vi.spyOn(session, 'requestHeader').mockReturnValue({ config: { provider: 'fixture', model: 'fixture' }, tools: ctx.tools.schemas() })
const agent = { session, options: {} } as never
const signal = new AbortController().signal
const toolSet = await ctx.tools.resolve({ agent, modelSelection: { provider: 'fixture', model: 'fixture' }, signal })
try {
return await executeToolFixture(ctx, {
signal, callId: ToolCallId(callId), name: 'office_convert', agent, toolSet, arguments: { input: 'report.docx', format: 'pdf' },
})
} finally { toolSet.dispose() }
}
it('mounts Desktop skills from the primary runtime beside the Office tools', async () => {
const { ctx, root } = await boot('desktop', root => join(root, 'primary-runtime'))
// Desktop omits pythonEnvironment; the skill-office default selects the bundled environment.
expect(ctx.loader.resolve('skill-office').fiber?.effectiveConfig).toEqual({
@@ -109,21 +130,18 @@ it('mounts Desktop skills from the primary runtime beside the resident office to
source: join(root, 'primary-runtime'), root: join(root, 'home', 'dsh-runtimes', 'dsh-primary-runtime'),
})
expect((await ctx.skills.list()).map(skill => skill.name)).toEqual(names)
expect(ctx.tools.schemas().map(tool => tool.name).sort()).toEqual(['load_workspace_dependencies', 'office'])
expect(ctx.tools.schemas().map(tool => tool.name).sort()).toEqual(['load_workspace_dependencies', ...OFFICE_TOOLS])
expect(ctx.officeKit.outputDirectory).toBe(join(root, 'home', 'office-kit', 'outputs'))
expect((await ctx.skills.get('office-docx'))?.content).toMatch(/## Python environment\n\n.*`load_workspace_dependencies`/u)
expect((await ctx.skills.get('office'))?.content).toContain('`office` tool')
expect((await ctx.skills.get('office'))?.content).toContain('`office_convert`')
})
it('keeps the office tool and returns the unavailable Kit error to the model when Kit is absent', async () => {
it('keeps the Office tools and returns the unavailable Kit error to the model when Kit is absent', async () => {
const { ctx, workspace } = await boot('web', () => undefined)
await writeFile(join(workspace, 'report.docx'), 'docx bytes')
const warnings: string[] = []
ctx.logger.exporter({ levels: { default: 2 }, export: ({ type, args }) => { if (type === 'warn') warnings.push(String(args[0])) } })
const result = await executeToolFixture(ctx, {
signal: new AbortController().signal, callId: ToolCallId('office-missing-kit'), name: 'office',
arguments: { operation: 'convert', input: 'report.docx', format: 'pdf' },
})
const result = await convertReport(ctx, workspace, 'office-missing-kit')
expect(result.isError).toBe(true)
expect(result.content).toEqual([{ type: 'text', text: `Error: cannot convert "${join(workspace, 'report.docx')}": LibreOffice Kit is not installed. `
+ 'This deployment does not provide LibreOffice Kit; install or enable it as this deployment requires, then retry.'
@@ -132,16 +150,13 @@ it('keeps the office tool and returns the unavailable Kit error to the model whe
expect(warnings.filter(warning => warning.startsWith('OfficeKitError: LibreOffice Kit is not installed.'))).toHaveLength(1)
})
it('mounts the preset office tool without the Office kit row and reaches the service after the row loads', async () => {
it('mounts the preset Office tools without the Office kit row and reaches the service after the row loads', async () => {
const { ctx, workspace, entries } = await boot('web', () => undefined, () => undefined, ROWS.filter(id => id !== 'office-kit'))
vi.mocked(resolveKitModule).mockClear()
await writeFile(join(workspace, 'report.docx'), 'docx bytes')
await ctx.loader.resolve('tool-office').fiber!.await()
expect(ctx.tools.schemas().map(tool => tool.name)).toEqual(['office'])
const convert = () => executeToolFixture(ctx, {
signal: new AbortController().signal, callId: ToolCallId('office-without-service'), name: 'office',
arguments: { operation: 'convert', input: 'report.docx', format: 'pdf' },
})
expect(ctx.tools.schemas().map(tool => tool.name).sort()).toEqual(OFFICE_TOOLS)
const convert = () => convertReport(ctx, workspace, 'office-without-service')
expect((await convert()).content).toEqual([{ type: 'text', text: `Error: cannot convert "${join(workspace, 'report.docx')}": The document converter is unavailable.`
+ ' Tell the user this operation is unavailable; do not substitute system soffice, npx, or another converter.' }])
expect(resolveKitModule).not.toHaveBeenCalled()
@@ -162,7 +177,7 @@ it('mounts Office skills with packaged defaults and the user Python outside the
const docx = (await ctx.skills.get('office-docx'))?.content
expect(docx).toMatch(/## Python environment\n\n.*`python3` or `python` on PATH/u)
expect(docx).not.toContain('load_workspace_dependencies')
expect(ctx.tools.schemas().map(tool => tool.name)).toEqual(['office'])
expect(ctx.tools.schemas().map(tool => tool.name).sort()).toEqual(OFFICE_TOOLS)
})
it('mounts packaged Office skills with the user Python in a Desktop profile launched without a primary runtime', async () => {
@@ -177,7 +192,7 @@ it('mounts packaged Office skills with the user Python in a Desktop profile laun
const docx = (await ctx.skills.get('office-docx'))?.content
expect(docx).toMatch(/## Python environment\n\n.*`python3` or `python` on PATH/u)
expect(docx).not.toContain('load_workspace_dependencies')
expect(ctx.tools.schemas().map(tool => tool.name)).toEqual(['office'])
expect(ctx.tools.schemas().map(tool => tool.name).sort()).toEqual(OFFICE_TOOLS)
})
it('reads Office skills from the launcher skill directory outside the Desktop profile', async () => {
@@ -205,12 +220,12 @@ it('fails only the Office skill rows when the carrier supplies an unusable prima
await expect(ctx.loader.resolve(id).fiber!.await()).rejects.toThrow('absolute')
}
expect(await ctx.skills.list()).toEqual([])
expect(ctx.tools.schemas().map(tool => tool.name)).toEqual(['office'])
expect(ctx.tools.schemas().map(tool => tool.name).sort()).toEqual(OFFICE_TOOLS)
})
it('removes the office tool when its row is disposed', async () => {
it('removes the Office tools when their row is disposed', async () => {
const { ctx } = await boot('web', () => undefined)
expect(ctx.tools.get('office')).toBeDefined()
for (const name of OFFICE_TOOLS) expect(ctx.tools.get(name)).toBeDefined()
await ctx.loader.resolve('tool-office').fiber!.dispose()
expect(ctx.tools.get('office')).toBeUndefined()
for (const name of OFFICE_TOOLS) expect(ctx.tools.get(name)).toBeUndefined()
})
@@ -27,8 +27,8 @@
en: bf1a8ebd1a550396
zh: a4d736010ab6602e
/deepseek-ai-dsh-client-ui-attachment/understand-the-implementation:
en: a6c9b40a9490e4d6
zh: 5bcdb4af4154c942
en: 48ff97eea132b589
zh: 6a7eff27d18d85a3
/deepseek-ai-dsh-client-ui-attachment/further-exploration:
en: 661e8285abb71b5d
zh: 0c421325537cdcda
+1 -1
View File
@@ -55,7 +55,7 @@ While an external file drag is over the page, the full-viewport overlay announce
<details>
<summary>Implementation internals — click to expand</summary>
The plugin provides the root-scoped `conversation.images.content` Factory. Its official `MessageImages` entries fill `conversation.chat.user.images`, `conversation.chat.message.images`, `conversation.trajectory.images`, `tool.call.images`, and `tool.call.office.images` at priority 100 through `ctx.slots.inject`. A lower-priority entry replaces only its own position; removing it restores the official entry. All defaults reuse one gallery with explicit image references, authorized loader, layout hints, and optional complete labels. The Factory owns gallery presentation and default copy, not Session state or read authorization. Each domain owns its Slot declaration. The composer attachment rail remains a separate entry, and the package entry exports no components.
The plugin provides the root-scoped `conversation.images.content` Factory. Its official `MessageImages` entries fill `conversation.chat.user.images`, `conversation.chat.message.images`, `conversation.trajectory.images`, `tool.call.images`, and `tool.call.office_render.images` at priority 100 through `ctx.slots.inject`. A lower-priority entry replaces only its own position; removing it restores the official entry. All defaults reuse one gallery with explicit image references, authorized loader, layout hints, and optional complete labels. The Factory owns gallery presentation and default copy, not Session state or read authorization. Each domain owns its Slot declaration. The composer attachment rail remains a separate entry, and the package entry exports no components.
| File | Role |
|---|---|
+1 -1
View File
@@ -55,7 +55,7 @@ Trajectory 附件行使用 48px 方形缩略图,完整缩放图片而不裁剪
<details>
<summary>实现细节——点击展开</summary>
插件提供 root 作用域的 `conversation.images.content` Factory。官方 `MessageImages` 条目通过 `ctx.slots.inject`,以优先级 100 填入 `conversation.chat.user.images`、`conversation.chat.message.images`、`conversation.trajectory.images`、`tool.call.images` 和 `tool.call.office.images`。较低优先级的条目只替换自身所在位置,移除后恢复官方条目。各默认条目复用同一画廊,显式传入图片引用、授权 loader、布局参数和可选的完整 labels。Factory 负责画廊展示与默认文案,不拥有 Session 状态或读取授权。各领域拥有自己的 Slot 声明。Composer 附件栏仍为独立条目,包入口不导出任何组件。
插件提供 root 作用域的 `conversation.images.content` Factory。官方 `MessageImages` 条目通过 `ctx.slots.inject`,以优先级 100 填入 `conversation.chat.user.images`、`conversation.chat.message.images`、`conversation.trajectory.images`、`tool.call.images` 和 `tool.call.office_render.images`。较低优先级的条目只替换自身所在位置,移除后恢复官方条目。各默认条目复用同一画廊,显式传入图片引用、授权 loader、布局参数和可选的完整 labels。Factory 负责画廊展示与默认文案,不拥有 Session 状态或读取授权。各领域拥有自己的 Slot 声明。Composer 附件栏仍为独立条目,包入口不导出任何组件。
| 文件 | 职责 |
|---|---|
@@ -44,7 +44,7 @@ export function apply(ctx: ClientContext): void {
ctx.slots.inject('tool.call.images', () => ctx.slots.register({
name: 'tool.call.images', priority: 100,
}, MessageImages))
ctx.slots.inject('tool.call.office.images', () => ctx.slots.register({
name: 'tool.call.office.images', priority: 100,
ctx.slots.inject('tool.call.office_render.images', () => ctx.slots.register({
name: 'tool.call.office_render.images', priority: 100,
}, MessageImages))
}
@@ -17,7 +17,7 @@ afterEach(cleanup)
const SLOTS = [
'conversation.chat.user.images', 'conversation.chat.message.images',
'conversation.trajectory.images', 'tool.call.images', 'tool.call.office.images',
'conversation.trajectory.images', 'tool.call.images', 'tool.call.office_render.images',
] as const
async function bench() {
@@ -49,7 +49,7 @@ async function bench() {
'conversation.chat.message.images': { kind: 'single', scope: 'session' },
'conversation.trajectory.images': { kind: 'single', scope: 'session' },
'tool.call.images': { kind: 'single', scope: 'session' },
'tool.call.office.images': { kind: 'single', scope: 'session' },
'tool.call.office_render.images': { kind: 'single', scope: 'session' },
}, ({ renderSlot, SessionProvider }) => <SessionProvider session={session}>
{SLOTS.map(name => <section key={name} data-testid={name}>{renderSlot(name, input)}</section>)}
</SessionProvider>)
@@ -10,7 +10,7 @@ import { MessageImages, MessageImagesContent } from '../src/client/MessageImages
const IMAGE_SLOTS = [
'conversation.chat.message.images', 'conversation.chat.user.images',
'conversation.trajectory.images', 'tool.call.images', 'tool.call.office.images',
'conversation.trajectory.images', 'tool.call.images', 'tool.call.office_render.images',
] as const
async function bench() {
@@ -32,7 +32,7 @@ async function bench() {
'conversation.chat.user.images': { kind: 'single', scope: 'session' },
'conversation.trajectory.images': { kind: 'single', scope: 'session' },
'tool.call.images': { kind: 'single', scope: 'session' },
'tool.call.office.images': { kind: 'single', scope: 'session' },
'tool.call.office_render.images': { kind: 'single', scope: 'session' },
},
} as never, () => null)
const readFileDrag = vi.fn(() => undefined)
@@ -343,9 +343,9 @@ export const zh = {
'tool.title.removeCordis': '移除 Cordis 插件',
'tool.title.pwsh': '运行命令',
'tool.title.readImage': '读取图片',
'tool.title.renderDocument': '渲染文档',
'tool.title.convertDocument': '转换文档',
'tool.title.recalculateWorkbook': '重算工作簿',
'tool.title.officeRender': '渲染文档',
'tool.title.officeConvert': '转换文档',
'tool.title.officeRecalculate': '重算工作簿',
'tool.title.grep': '搜索文件内容',
'tool.title.glob': '查找文件',
'tool.title.webSearch': '网页搜索',
@@ -742,9 +742,9 @@ export const en = {
'tool.title.removeCordis': 'Remove Cordis Plugin',
'tool.title.pwsh': 'Pwsh',
'tool.title.readImage': 'Read image',
'tool.title.renderDocument': 'Render document',
'tool.title.convertDocument': 'Convert document',
'tool.title.recalculateWorkbook': 'Recalculate workbook',
'tool.title.officeRender': 'Render document',
'tool.title.officeConvert': 'Convert document',
'tool.title.officeRecalculate': 'Recalculate workbook',
'tool.title.grep': 'Grep',
'tool.title.glob': 'Glob',
'tool.title.webSearch': 'Search',
@@ -1140,9 +1140,9 @@ export const ja = {
'tool.title.removeCordis': 'Cordis プラグインを削除',
'tool.title.pwsh': 'Pwsh',
'tool.title.readImage': '画像を読み取り',
'tool.title.renderDocument': '文書を描画',
'tool.title.convertDocument': '文書を変換',
'tool.title.recalculateWorkbook': 'ブックを再計算',
'tool.title.officeRender': '文書を描画',
'tool.title.officeConvert': '文書を変換',
'tool.title.officeRecalculate': 'ブックを再計算',
'tool.title.grep': 'Grep',
'tool.title.glob': 'Glob',
'tool.title.webSearch': '検索',
@@ -1531,9 +1531,9 @@ export const es = {
'tool.title.removeCordis': 'Eliminar el complemento Cordis',
'tool.title.pwsh': 'Pwsh',
'tool.title.readImage': 'Leer imagen',
'tool.title.renderDocument': 'Representar documento',
'tool.title.convertDocument': 'Convertir documento',
'tool.title.recalculateWorkbook': 'Recalcular libro',
'tool.title.officeRender': 'Representar documento',
'tool.title.officeConvert': 'Convertir documento',
'tool.title.officeRecalculate': 'Recalcular libro',
'tool.title.grep': 'grep',
'tool.title.glob': 'globo',
'tool.title.webSearch': 'Buscar',
@@ -1929,9 +1929,9 @@ export const fr = {
'tool.title.removeCordis': 'Supprimer le plug-in Cordis',
'tool.title.pwsh': 'Pwsh',
'tool.title.readImage': "Lire l'image",
'tool.title.renderDocument': 'Afficher le document',
'tool.title.convertDocument': 'Convertir le document',
'tool.title.recalculateWorkbook': 'Recalculer le classeur',
'tool.title.officeRender': 'Afficher le document',
'tool.title.officeConvert': 'Convertir le document',
'tool.title.officeRecalculate': 'Recalculer le classeur',
'tool.title.grep': 'Grep',
'tool.title.glob': 'Glob',
'tool.title.webSearch': 'Rechercher',
@@ -2327,9 +2327,9 @@ export const de = {
'tool.title.removeCordis': 'Entfernen Sie das Cordis-Plugin',
'tool.title.pwsh': 'Pwsh',
'tool.title.readImage': 'Bild lesen',
'tool.title.renderDocument': 'Dokument rendern',
'tool.title.convertDocument': 'Dokument konvertieren',
'tool.title.recalculateWorkbook': 'Arbeitsmappe neu berechnen',
'tool.title.officeRender': 'Dokument rendern',
'tool.title.officeConvert': 'Dokument konvertieren',
'tool.title.officeRecalculate': 'Arbeitsmappe neu berechnen',
'tool.title.grep': 'Grep',
'tool.title.glob': 'Globus',
'tool.title.webSearch': 'Suchen',
@@ -2725,9 +2725,9 @@ export const ru = {
'tool.title.removeCordis': 'Удалить плагин Cordis',
'tool.title.pwsh': 'Пшш',
'tool.title.readImage': 'Читать изображение',
'tool.title.renderDocument': 'Отрисовать документ',
'tool.title.convertDocument': 'Преобразовать документ',
'tool.title.recalculateWorkbook': 'Пересчитать книгу',
'tool.title.officeRender': 'Отрисовать документ',
'tool.title.officeConvert': 'Преобразовать документ',
'tool.title.officeRecalculate': 'Пересчитать книгу',
'tool.title.grep': 'Греп',
'tool.title.glob': 'Глоб',
'tool.title.webSearch': 'Поиск',
@@ -3123,9 +3123,9 @@ export const pt = {
'tool.title.removeCordis': 'Remover plug-in Cordis',
'tool.title.pwsh': 'Pwsh',
'tool.title.readImage': 'Ler imagem',
'tool.title.renderDocument': 'Renderizar documento',
'tool.title.convertDocument': 'Converter documento',
'tool.title.recalculateWorkbook': 'Recalcular pasta de trabalho',
'tool.title.officeRender': 'Renderizar documento',
'tool.title.officeConvert': 'Converter documento',
'tool.title.officeRecalculate': 'Recalcular pasta de trabalho',
'tool.title.grep': 'Grep',
'tool.title.glob': 'globo',
'tool.title.webSearch': 'Pesquisar',
+2 -2
View File
@@ -30,8 +30,8 @@
en: 672e63b2f92e689b
zh: ba950ecb480325a6
/deepseek-ai-dsh-client-ui-tool/understand-the-implementation/cards:
en: bebc32b7bc192991
zh: c1458ffbd3a7d5a8
en: 8a00d468597e7800
zh: 1eb6bdde47a55c10
/deepseek-ai-dsh-client-ui-tool/understand-the-implementation/declared-optional-capabilities:
en: c1926deb4e5f3734
zh: c5845f465b94a459
+1 -1
View File
@@ -85,7 +85,7 @@ Tool Definitions own the [lazy argument view](../../util/values/README.md). Rows
### Cards
Every card is read in place in the call tree; there is no second, full-height presentation of a selected call. Row renderers share one pure card model for each terminal, read, diff, search, and web card, and the image card's gallery renders through the tool-owned `tool.call.images` slot (`tool.call.office.images` for `office` renders), followed by the full recorded path and each attached image's pixel size (with the original size when downscaled) and byte count. These models validate raw call arguments, result content, failure state, persisted metadata, PTC dispatch `parentCallId`, and Session path facts. Unsupported or malformed inputs use flattened Tool result text. A file-path summary opens the file through the owner's `openFile`, which the chat view routes to the right Sidebar's text preview; `inspect` opens the trajectory view and is absent when that View is unavailable; cards then omit Inspect. Card-specific limits and fallback rules for the terminal, diff, read, search, and web cards remain in [the ui-primitives README](../ui-primitives/README.md); the image card's model in this package carries its own fallback rules.
Every card is read in place in the call tree; there is no second, full-height presentation of a selected call. Row renderers share one pure card model for each terminal, read, diff, search, and web card, and the image card's gallery renders through the tool-owned `tool.call.images` slot (`tool.call.office_render.images` for `office_render` renders), followed by the full recorded path and each attached image's pixel size (with the original size when downscaled) and byte count. These models validate raw call arguments, result content, failure state, persisted metadata, PTC dispatch `parentCallId`, and Session path facts. Unsupported or malformed inputs use flattened Tool result text. A file-path summary opens the file through the owner's `openFile`, which the chat view routes to the right Sidebar's text preview; `inspect` opens the trajectory view and is absent when that View is unavailable; cards then omit Inspect. Card-specific limits and fallback rules for the terminal, diff, read, search, and web cards remain in [the ui-primitives README](../ui-primitives/README.md); the image card's model in this package carries its own fallback rules.
Search cards treat an exact empty `include` as omitted; invalid types, whitespace-only values, negated filters, and comma-separated lists remain generic.
+1 -1
View File
@@ -85,7 +85,7 @@ Tool Definition 拥有[懒计算参数视图](../../util/values/README.zh.md)。
### 卡片
每张卡片都直接在调用树中查看;选中调用后不会再显示第二个全高视图。行 renderer 为 terminal、read、diff、search 和 web 卡片各复用同一个纯 card model,image 卡片的图库经由工具自有 `tool.call.images` slot(`office` 渲染使用 `tool.call.office.images`)渲染,其下显示完整的记录路径以及每张附件图片的像素尺寸(缩小时附原图尺寸)和字节数。这些 model 校验原始调用参数、结果内容、失败状态、持久 metadata、PTC dispatch 的 `parentCallId` 与会话路径信息。不受支持或格式错误的输入使用压平的工具结果文本。文件路径摘要经属主的 `openFile` 打开文件,chat 视图把它路由到右侧 Sidebar 的文本预览;`inspect` 打开轨迹视图;该视图不可用时不提供此回调,卡片随之隐藏 Inspect。terminal、diff、read、search 与 web 卡片的上限与 fallback 规则仍由 [ui-primitives README](../ui-primitives/README.zh.md) 负责;image 卡片的 fallback 规则由本包内的 card model 自行承载。
每张卡片都直接在调用树中查看;选中调用后不会再显示第二个全高视图。行 renderer 为 terminal、read、diff、search 和 web 卡片各复用同一个纯 card model,image 卡片的图库经由工具自有 `tool.call.images` slot(`office_render` 渲染使用 `tool.call.office_render.images`)渲染,其下显示完整的记录路径以及每张附件图片的像素尺寸(缩小时附原图尺寸)和字节数。这些 model 校验原始调用参数、结果内容、失败状态、持久 metadata、PTC dispatch 的 `parentCallId` 与会话路径信息。不受支持或格式错误的输入使用压平的工具结果文本。文件路径摘要经属主的 `openFile` 打开文件,chat 视图把它路由到右侧 Sidebar 的文本预览;`inspect` 打开轨迹视图;该视图不可用时不提供此回调,卡片随之隐藏 Inspect。terminal、diff、read、search 与 web 卡片的上限与 fallback 规则仍由 [ui-primitives README](../ui-primitives/README.zh.md) 负责;image 卡片的 fallback 规则由本包内的 card model 自行承载。
搜索卡片将值恰好为空字符串的 `include` 视为省略;类型错误、仅含空白的值、否定过滤器和逗号分隔列表仍使用通用显示。
@@ -39,8 +39,8 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
* slot.
*/
'tool.call.images': { kind: 'single'; scope: 'session'; owner: ToolImagesOwnerProps }
/** Rendered page images of a settled `office` render; the attachment presentation plugin fills it like `tool.call.images`. */
'tool.call.office.images': { kind: 'single'; scope: 'session'; owner: ToolImagesOwnerProps }
/** Rendered page images of a settled `office_render` call; the attachment presentation plugin fills it like `tool.call.images`. */
'tool.call.office_render.images': { kind: 'single'; scope: 'session'; owner: ToolImagesOwnerProps }
}
}
@@ -1,20 +1,20 @@
/** Pure `office` row derivation from the frozen call slice and settled result. @module */
/** Pure Office row derivation from the tool name, frozen call slice, and settled result. @module */
import type { LocaleKeysOf } from '@deepseek-ai/dsh-client-ui-slots'
import { abbreviateHomePath, isAbsoluteWorkspacePath, relativizeToCwd } from '@deepseek-ai/dsh-util-workspace-path'
import { fullyRendered, imageReferences, type ImageCardModel } from './image-card-model.ts'
import { recordedAbsolutePath } from './recorded-path.ts'
import type { ToolCallBlock } from './tool-call-model.ts'
type OfficeTitleKey = Extract<LocaleKeysOf<'conversation'>, 'tool.title.renderDocument' | 'tool.title.convertDocument'
| 'tool.title.recalculateWorkbook' | 'tool.title.generic'>
type OfficeTitleKey = Extract<LocaleKeysOf<'conversation'>, 'tool.title.officeRender' | 'tool.title.officeConvert'
| 'tool.title.officeRecalculate' | 'tool.title.generic'>
const TITLE_KEYS: Readonly<Record<string, OfficeTitleKey>> = {
render: 'tool.title.renderDocument',
convert: 'tool.title.convertDocument',
recalculate: 'tool.title.recalculateWorkbook',
office_render: 'tool.title.officeRender',
office_convert: 'tool.title.officeConvert',
office_recalculate: 'tool.title.officeRecalculate',
}
/** The `office` row's operation title, path summary, openable input, and rendered images. */
/** The Office row's tool title, path summary, openable input, and rendered images. */
export interface OfficeRowModel {
titleKey: OfficeTitleKey
/** Input, plus the output format of a conversion or recalculation; empty until the input argument completes. */
@@ -32,24 +32,24 @@ function completeText(block: ToolCallBlock, key: string): string | undefined {
}
/**
* Derive the `office` row from wire values, declining malformed images to the text output.
* @param block - preparing, running, or settled `office` block.
* Derive an Office row from wire values, declining malformed images to the text output.
* @param toolName - wire tool name used for title and image dispatch.
* @param block - preparing, running, or settled Office block.
* @param cwd - Session workspace root used to shorten paths.
* @param home - Host account home shown as `~`.
* @returns the row title, summary, openable path, and optional image card.
*/
export function officeRowModel(block: ToolCallBlock, cwd?: string, home?: string): OfficeRowModel {
const operation = completeText(block, 'operation')
const titleKey = (operation === undefined ? undefined : TITLE_KEYS[operation]) ?? 'tool.title.generic'
export function officeRowModel(toolName: string, block: ToolCallBlock, cwd?: string, home?: string): OfficeRowModel {
const titleKey = TITLE_KEYS[toolName] ?? 'tool.title.generic'
const input = completeText(block, 'input')
const format = operation === 'render' ? undefined : completeText(block, 'format')
const format = toolName === 'office_render' ? undefined : completeText(block, 'format')
const short = (path: string): string => abbreviateHomePath(relativizeToCwd(path, cwd), home)
const summary = input === undefined ? '' : format === undefined ? short(input) : `${short(input)} → ${format}`
const settled = 'kind' in block
const recorded = settled ? recordedAbsolutePath(block.meta, 'path') : undefined
const filePath = recorded ?? (input !== undefined && isAbsoluteWorkspacePath(input) ? input : undefined)
let image: ImageCardModel | null = null
if (settled && !block.isError && operation === 'render' && recorded !== undefined && fullyRendered(block.content)) {
if (settled && !block.isError && toolName === 'office_render' && recorded !== undefined && fullyRendered(block.content)) {
const refs = imageReferences(block.content)
const texts = block.content.flatMap(part => part.type === 'text' ? [part.text] : [])
if (refs !== null) image = { path: recorded, images: refs.map(attachment => ({ attachment })), extraText: texts.length === 0 ? null : texts.join('\n') }
@@ -1,31 +1,55 @@
// office toolview registrant. Claiming the `office` key replaces the generic row
// for every office call, so the row covers preparing, running, failed, written-file,
// and rendered results. A successful render shows its images through the Tool-owned
// `tool.call.office.images` slot; every other state keeps the flattened text output.
// Office toolview links target the input, not the temporary output. Only office_render
// owns an image slot; conversion and recalculation retain flattened result text.
import { useCallback } from 'react'
import { IconBrowseOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
import type { Context } from '@deepseek-ai/cordis'
import type { ContextMenuBindings } from '@deepseek-ai/dsh-client-ui-context-menu/client'
import { toolFileInject } from '../file-menu.ts'
import type { ToolImagesOwnerProps } from '../../contract/slots.ts'
import { officeRowModel } from '../models/office-card-model.ts'
import { officeRowModel, type OfficeRowModel } from '../models/office-card-model.ts'
import { toolRowModel } from '../models/tool-call-model.ts'
import { ToolRow } from '../components/ToolRow.tsx'
import { ToolRow, type ToolRowProps } from '../components/ToolRow.tsx'
import type { PropsRenderSlots } from '@deepseek-ai/dsh-client-ui-slots'
import type { ReadFamilyRowProps } from './read-family-row.tsx'
import { CONVERSATION_NS as NS } from '../../locale.ts'
/** office row props: the runtime share, the declared image child slot, and the locale seat. */
export type OfficeRowProps = ReadFamilyRowProps & PropsRenderSlots<'tool.call.office.images'>
/** Office file row props: the runtime share, file actions, and locale seat. */
export type OfficeRowProps = ReadFamilyRowProps
/** office row: operation title, input path summary, and the rendered images as its card body. */
/** Office render row props include its declared image child slot. */
export type OfficeRenderRowProps = OfficeRowProps & PropsRenderSlots<'tool.call.office_render.images'>
/**
* Show conversion or recalculation output with input-path navigation.
* @param props - tool call, file actions, and locale seat.
* @returns the file result row.
*/
export function OfficeRow(props: OfficeRowProps) {
const { toolName, block, cwd, home, openFile, resolveFilePath, sessionId, inspect, useDisclosure, renderSlot, loadImage, t } = props
const { getTriggerProps } = props.useContextMenu()
return officeRow(props, officeRowModel(props.toolName, props.block, props.cwd, props.home), getTriggerProps)
}
/**
* Show successful renders through the render tool's gallery slot.
* @param props - tool call, file actions, locale seat, and image child renderer.
* @returns the render result row.
*/
export function OfficeRenderRow(props: OfficeRenderRowProps) {
const { getTriggerProps } = props.useContextMenu()
const { renderSlot } = props
const renderImages = useCallback((owner: ToolImagesOwnerProps) => renderSlot('tool.call.office_render.images', owner), [renderSlot])
return officeRow(props, officeRowModel(props.toolName, props.block, props.cwd, props.home), getTriggerProps, renderImages)
}
function officeRow(
{ toolName, block, cwd, home, openFile, resolveFilePath, sessionId, inspect, useDisclosure, loadImage, t }: OfficeRowProps,
office: OfficeRowModel,
getTriggerProps: ContextMenuBindings['getTriggerProps'],
renderImages?: ToolRowProps['renderImages'],
) {
const row = toolRowModel(toolName, block, cwd, home)
const office = officeRowModel(block, cwd, home)
const path = office.filePath
const renderImages = useCallback((owner: ToolImagesOwnerProps) => renderSlot('tool.call.office.images', owner), [renderSlot])
return (
<ToolRow
fileContextMenuProps={getTriggerProps(path === undefined ? undefined : () => ({
@@ -52,22 +76,25 @@ export function OfficeRow(props: OfficeRowProps) {
)
}
/** Registers the office tool's conversation row with its image gallery child slot. */
/** Registers the three Office toolviews; only rendering owns an image gallery child slot. */
export const officeToolview = {
name: 'office-toolview',
inject: ['slots', 'sessions'],
/**
* Register the office row into the Tool-owned keyed view slot.
* Register Office rows into the Tool-owned keyed view slot.
* @param ctx - registrant context (disposal rides ctx.effect inside slots.register).
*/
apply(ctx: Context): void {
ctx.slots.inject('tool.call.toolview', () =>
ctx.slots.register({
ctx.slots.inject('tool.call.toolview', function* () {
yield ctx.slots.register({
name: 'tool.call.toolview',
key: 'office',
key: 'office_render',
locale: NS,
inject: toolFileInject(ctx),
children: { 'tool.call.office.images': { kind: 'single', scope: 'session' } },
}, OfficeRow))
children: { 'tool.call.office_render.images': { kind: 'single', scope: 'session' } },
}, OfficeRenderRow)
yield ctx.slots.register({ name: 'tool.call.toolview', key: 'office_convert', locale: NS, inject: toolFileInject(ctx) }, OfficeRow)
yield ctx.slots.register({ name: 'tool.call.toolview', key: 'office_recalculate', locale: NS, inject: toolFileInject(ctx) }, OfficeRow)
})
},
}
@@ -1,73 +1,82 @@
// @vitest-environment jsdom
// The office row: its pure model over raw arguments, persisted metadata, and result
// content, and the keyed toolview that renders a successful render's images through
// the tool-owned `tool.call.office.images` slot.
// Office rows dispatch by tool name and retain input navigation and settled output.
import { afterEach, describe, expect, it, vi } from 'vitest'
import { afterEach, describe, expect, it, onTestFinished, vi } from 'vitest'
import { useDisclosure } from '@deepseek-ai/dsh-client-ui-chat/src/client/chat/use-disclosure.ts'
import { cleanup, fireEvent, render } from '@testing-library/react'
import { Context } from '@deepseek-ai/cordis'
import { contextMenuHook, bindSnapshotSelector, makeTranslate } from '@deepseek-ai/dsh-client-test-runtime'
import { contextMenuHook, bindSnapshotSelector, makeTranslate, SlotTestRuntime } from '@deepseek-ai/dsh-client-test-runtime'
import { LocaleRuntime } from '@deepseek-ai/dsh-client-locale/client'
import { createSnapshotStore } from '@deepseek-ai/dsh-client-store'
import { zh as commonZh } from '@deepseek-ai/dsh-client-locale/src/locales/zh.ts'
import type { StartedToolCall, ToolResultNode } from '@deepseek-ai/dsh-client-ui-chat/client'
import type { SessionListState } from '@deepseek-ai/dsh-api-session-controller/client'
import type { SessionId } from '@deepseek-ai/dsh-session/types'
import type { MessageImageLoader } from '@deepseek-ai/dsh-client-ui-conversation/client'
import { zh } from '@deepseek-ai/dsh-client-ui-conversation/src/client/locales.ts'
import { zh, en, ja, es, fr, de, ru, pt } from '@deepseek-ai/dsh-client-ui-conversation/src/client/locales.ts'
import { PartialArguments } from '@deepseek-ai/dsh-util-values'
import { AttachmentId, type ImageAttachmentRef } from '@deepseek-ai/dsh-attachment'
import type { ToolTreeProps } from '../src/client/contract/slots.ts'
import { officeRowModel } from '../src/client/tool/models/office-card-model.ts'
import { OfficeRow, officeToolview, type OfficeRowProps } from '../src/client/tool/toolviews/office-row.tsx'
import { OfficeRow, OfficeRenderRow, officeToolview, type OfficeRenderRowProps } from '../src/client/tool/toolviews/office-row.tsx'
afterEach(cleanup)
const SID = 's1' as SessionId
const t: ToolTreeProps['t'] = makeTranslate(zh, commonZh)
const RENDER_ARGS = '{"operation":"render","input":"docs/deck.pptx"}'
const RENDER_ARGS = '{"input":"docs/deck.pptx"}'
const image: ImageAttachmentRef = {
attachmentId: AttachmentId(`sha256:${'b'.repeat(64)}`), mediaType: 'image/png', bytes: 120, width: 800, height: 600,
}
const SUMMARY = 'Rendered 1 image of /w/app/docs/deck.pptx (3 in the document) at 144 DPI.'
const running = (argsRaw = RENDER_ARGS): StartedToolCall => ({
phase: 'start', args: PartialArguments.fromText(argsRaw), callId: 'c1', name: 'office', argsRaw,
const running = (argsRaw = RENDER_ARGS, name = 'office_render'): StartedToolCall => ({
phase: 'start', args: PartialArguments.fromText(argsRaw), callId: 'c1', name, argsRaw,
turn: 1, step: 1, time: 1_000, subCalls: [],
})
const settled = (over: Partial<ToolResultNode> = {}, argsRaw = RENDER_ARGS): ToolResultNode => ({
kind: 'tool-result', seq: 10, time: 2_000, callId: 'c1', name: 'office',
args: PartialArguments.fromText(argsRaw), call: { name: 'office', argsRaw }, callTime: 1_000,
const settled = (over: Partial<ToolResultNode> = {}, argsRaw = RENDER_ARGS, name = 'office_render'): ToolResultNode => ({
kind: 'tool-result', seq: 10, time: 2_000, callId: 'c1', name,
args: PartialArguments.fromText(argsRaw), call: { name, argsRaw }, callTime: 1_000,
content: [{ type: 'text', text: SUMMARY }, { type: 'text', text: 'Page 2: 800x600 px' }, { type: 'image', attachment: image }],
isError: false, meta: { path: '/w/app/docs/deck.pptx' }, subCalls: [], ...over,
})
describe('officeRowModel', () => {
it('derives a render card from the recorded input path and result images', () => {
expect(officeRowModel(settled(), '/w/app')).toEqual({
titleKey: 'tool.title.renderDocument', summary: 'docs/deck.pptx', filePath: '/w/app/docs/deck.pptx',
expect(officeRowModel('office_render', settled(), '/w/app')).toEqual({
titleKey: 'tool.title.officeRender', summary: 'docs/deck.pptx', filePath: '/w/app/docs/deck.pptx',
image: { path: '/w/app/docs/deck.pptx', images: [{ attachment: image }], extraText: `${SUMMARY}\nPage 2: 800x600 px` },
})
})
it('titles each operation and summarizes written outputs', () => {
const convert = '{"operation":"convert","input":"/w/app/deck.pptx","format":"pdf"}'
expect(officeRowModel(running(convert), '/w/app')).toEqual({
titleKey: 'tool.title.convertDocument', summary: 'deck.pptx → pdf', filePath: '/w/app/deck.pptx', image: null,
it('titles each tool and summarizes written outputs without an operation argument', () => {
const convert = '{"input":"/w/app/deck.pptx","format":"pdf"}'
expect(officeRowModel('office_convert', running(convert, 'office_convert'), '/w/app')).toEqual({
titleKey: 'tool.title.officeConvert', summary: 'deck.pptx → pdf', filePath: '/w/app/deck.pptx', image: null,
})
expect(officeRowModel(running('{"operation":"recalculate","input":"book.xlsx"}'))).toMatchObject({
titleKey: 'tool.title.recalculateWorkbook', summary: 'book.xlsx', filePath: undefined,
expect(officeRowModel('office_recalculate', running('{"input":"book.xlsx"}', 'office_recalculate'))).toMatchObject({
titleKey: 'tool.title.officeRecalculate', summary: 'book.xlsx', filePath: undefined,
})
expect(officeRowModel(running('{"operation":"other"'))).toMatchObject({ titleKey: 'tool.title.generic', summary: '' })
expect(officeRowModel('other', running('{"input":"unfinished'))).toMatchObject({ titleKey: 'tool.title.generic', summary: '' })
})
it.each([
['office_render', 'tool.title.officeRender'], ['office_convert', 'tool.title.officeConvert'],
['office_recalculate', 'tool.title.officeRecalculate'],
])('selects %s from its wire name even when operation metadata conflicts', (name, titleKey) => {
const block = settled({ meta: { path: '/w/app/docs/deck.pptx', operation: 'convert' } },
'{"operation":"render","input":"docs/deck.pptx"}', name)
const model = officeRowModel(name, block)
expect(model.titleKey).toBe(titleKey)
expect(model.image !== null).toBe(name === 'office_render')
})
it('declines the image card for failures, malformed metadata, unknown blocks, and malformed images', () => {
expect(officeRowModel(settled({ isError: true })).image).toBeNull()
expect(officeRowModel(settled({ meta: { path: 'relative.pptx' } })).image).toBeNull()
expect(officeRowModel(settled({ content: [{ type: 'text', text: SUMMARY }, { type: 'reasoning', text: 'x' } as never] })).image).toBeNull()
expect(officeRowModel(settled({ content: [{ type: 'text', text: SUMMARY }] })).image).toBeNull()
expect(officeRowModel(settled({ content: [{ type: 'image', attachment: image }] })).image).toEqual({
expect(officeRowModel('office_render', settled({ isError: true })).image).toBeNull()
expect(officeRowModel('office_render', settled({ meta: { path: 'relative.pptx' } })).image).toBeNull()
expect(officeRowModel('office_render', settled({ content: [{ type: 'text', text: SUMMARY }, { type: 'reasoning', text: 'x' } as never] })).image).toBeNull()
expect(officeRowModel('office_render', settled({ content: [{ type: 'text', text: SUMMARY }] })).image).toBeNull()
expect(officeRowModel('office_render', settled({ content: [{ type: 'image', attachment: image }] })).image).toEqual({
path: '/w/app/docs/deck.pptx', images: [{ attachment: image }], extraText: null,
})
})
@@ -80,35 +89,80 @@ describe('OfficeRow', () => {
phase: 'ready', projectionsBySession: {},
}))
const loadImage: MessageImageLoader = vi.fn(() => Promise.reject(new Error('not used')))
const props = (block: StartedToolCall | ToolResultNode, renderSlot = vi.fn(() => <div data-images />)): OfficeRowProps => ({
useDisclosure, callId: 'c1', toolName: 'office',
const props = (block: StartedToolCall | ToolResultNode, renderSlot = vi.fn(() => <div data-images />)): OfficeRenderRowProps => ({
useDisclosure, callId: 'c1', toolName: block.name,
...'kind' in block ? { phase: 'result' as const, block } : { phase: block.phase, block },
openFile: vi.fn(), renderSlot, loadImage, useContextMenu: contextMenuHook(), resolveFilePath: path => path,
sessionId: SID, useSessions: list(), cwd: '/w/app', t,
} as OfficeRowProps)
} as OfficeRenderRowProps)
it('expands a render to its images through the office image slot', () => {
const renderSlot = vi.fn(() => <div data-images />)
const view = render(<OfficeRow {...props(settled(), renderSlot)} />)
const view = render(<OfficeRenderRow {...props(settled(), renderSlot)} />)
expect(view.container.textContent).toContain('渲染文档')
fireEvent.click(view.container.querySelector('[data-expandable]')!)
expect(renderSlot).toHaveBeenLastCalledWith('tool.call.office.images', { images: [{ attachment: image }], loadImage, align: 'start' })
expect(renderSlot).toHaveBeenLastCalledWith('tool.call.office_render.images', { images: [{ attachment: image }], loadImage, align: 'start' })
expect(view.container.textContent).toContain(SUMMARY)
expect(view.container.textContent).toContain('Page 2: 800x600 px')
})
it('shows a running call without images', () => {
const renderSlot = vi.fn(() => <div data-images />)
const view = render(<OfficeRow {...props(running(), renderSlot)} />)
const view = render(<OfficeRenderRow {...props(running(), renderSlot)} />)
expect(view.container.textContent).toContain('docs/deck.pptx')
expect(renderSlot).not.toHaveBeenCalled()
})
it('registers the keyed office toolview with its image child slot', () => {
const ctx = new Context()
const register = vi.fn()
ctx.provide('slots', { inject: (_name: string, factory: () => unknown) => factory(), register } as never)
officeToolview.apply(ctx)
expect(register).toHaveBeenCalledWith(expect.objectContaining({
name: 'tool.call.toolview', key: 'office', children: { 'tool.call.office.images': { kind: 'single', scope: 'session' } },
}), OfficeRow)
it.each([
['office_convert', 'pdf', '转换文档', 'Converted', ', 3 pages'],
['office_recalculate', 'xlsx', '重算工作簿', 'Recalculated', ''],
])('keeps the %s result text and output path while its title link opens the input', (name, format, title, verb, pages) => {
const input = '/w/app/input.xlsx'
const file = `/tmp/office/output.${format}`
const output = `${verb} ${input} to ${format} (123 bytes${pages}): ${file}\n`
+ 'Copy this temporary file to its destination with the shell now; it is deleted when this conversation ends.'
const warning = 'Fonts not installed and substituted: Example font.'
const block = settled({ meta: { path: input, file }, content: [{ type: 'text', text: output }, { type: 'text', text: warning }] },
JSON.stringify({ input: 'input.xlsx', format }), name)
const rowProps = props(block)
const view = render(<OfficeRow {...rowProps} />)
expect(view.container.textContent).toContain(title)
fireEvent.click(view.getByRole('button', { name: `input.xlsx → ${format}` }))
expect(rowProps.openFile).toHaveBeenCalledWith(input)
fireEvent.click(view.container.querySelector('[data-expandable]')!)
expect(view.container.textContent).toContain(`${output}\n${warning}`)
expect(rowProps.renderSlot).not.toHaveBeenCalled()
})
it('registers all three wire names, declares images only for render, and removes them on disposal', async () => {
const runtime = await SlotTestRuntime.create()
onTestFinished(() => runtime.dispose())
const locale = new LocaleRuntime(runtime.ctx)
locale.register('conversation', { en, zh })
runtime.ctx.provide('locale', locale)
runtime.slots.installLocale(locale)
const fiber = await runtime.mount(officeToolview)
expect(runtime.slots.entries('tool.call.toolview')).toHaveLength(0)
await runtime.root.declare({ 'tool.call.toolview': { kind: 'keyed', scope: 'session' } }, () => null)
expect(runtime.slots.entries('tool.call.toolview').map(entry => [entry.options.key, entry.component])).toEqual([
['office_render', OfficeRenderRow], ['office_convert', OfficeRow], ['office_recalculate', OfficeRow],
])
expect(runtime.slots.spec('tool.call.office_render.images')).toEqual({ kind: 'single', scope: 'session' })
await fiber.dispose()
expect(runtime.slots.entries('tool.call.toolview')).toHaveLength(0)
expect(runtime.slots.spec('tool.call.office_render.images')).toBeUndefined()
})
})
it.each([
['zh', zh, ['渲染文档', '转换文档', '重算工作簿']],
['en', en, ['Render document', 'Convert document', 'Recalculate workbook']],
['ja', ja, ['文書を描画', '文書を変換', 'ブックを再計算']],
['es', es, ['Representar documento', 'Convertir documento', 'Recalcular libro']],
['fr', fr, ['Afficher le document', 'Convertir le document', 'Recalculer le classeur']],
['de', de, ['Dokument rendern', 'Dokument konvertieren', 'Arbeitsmappe neu berechnen']],
['ru', ru, ['Отрисовать документ', 'Преобразовать документ', 'Пересчитать книгу']],
['pt', pt, ['Renderizar documento', 'Converter documento', 'Recalcular pasta de trabalho']],
] as const)('keeps the %s Office titles on the dedicated keys', (_language, dictionary, titles) => {
expect([dictionary['tool.title.officeRender'], dictionary['tool.title.officeConvert'], dictionary['tool.title.officeRecalculate']]).toEqual(titles)
})
@@ -171,6 +171,28 @@ describe('keyed toolview hole through the real machinery', () => {
await b.runtime.dispose()
})
it.each([
['office_render', 'Render document'],
['office_convert', 'Convert document'],
['office_recalculate', 'Recalculate workbook'],
])('dispatches %s to its Office row through the real call tree', async (name, title) => {
const output = `${name} result`
const args = { input: 'input.xlsx', ...name === 'office_render' ? {} : { format: 'xlsx' } }
const b = await bench([
toolResult(3, 'office-call', name, JSON.stringify(args), {
meta: { path: '/w/input.xlsx' }, content: [{ type: 'text', text: output }],
}),
])
try {
const view = b.runtime.renderRoot()
expect(view.getByText(title)).toBeTruthy()
expect(view.queryByText('Tool call')).toBeNull()
expect(view.getByRole('button', { name: name === 'office_render' ? 'input.xlsx' : 'input.xlsx → xlsx' })).toBeTruthy()
fireEvent.click(view.container.querySelector('[data-expandable]')!)
expect(view.getByText(output)).toBeTruthy()
} finally { await b.runtime.dispose() }
})
it('renders Auto denial copy through the real machinery', async () => {
const b = await bench([
toolResult(
@@ -32,7 +32,7 @@ describe('gen-tool-catalog collectToolCatalog', () => {
'create_goal', 'create_worktree', 'edit', 'exit_plan_mode', 'get_goal', 'glob', 'grep',
'interrupt_agent', 'job_kill', 'job_list', 'job_output',
'list_agents', 'list_mcp_resource_templates', 'list_mcp_resources',
'list_subagent_models', 'load_workspace_dependencies', 'lsp', 'office', 'plugin_manager', 'plugin_market', 'present', 'propose_action', 'pwsh', 'pwsh', 'ralph',
'list_subagent_models', 'load_workspace_dependencies', 'lsp', 'office_convert', 'office_recalculate', 'office_render', 'plugin_manager', 'plugin_market', 'present', 'propose_action', 'pwsh', 'pwsh', 'ralph',
'read', 'read_image', 'read_mcp_resource', 'run_code', 'schedule_create', 'schedule_edit',
'schedule_list', 'schedule_view', 'send_message', 'session_event_read', 'session_event_search',
'session_event_trace', 'session_search', 'session_trace', 'skill',
+5 -5
View File
@@ -3,20 +3,20 @@
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write packages/document/README.md
/:
en: af5a48d0437be195
en: d9a998354c825d52
zh: ebfa0348be528b01
/document-office-documents:
en: 3e516b9627deabcd
zh: 0f42f57278733204
/document-office-documents/summary:
en: 63d586f950af4ff3
zh: f1366c7e85fea7fc
en: 34bf8811e9365492
zh: 9a71bb7bbd57649a
/document-office-documents/table-of-contents:
en: 1eb35b015a6c423f
zh: a8a3dceee2c9e943
/document-office-documents/packages:
en: b310efe9569867c7
zh: 9247d29e13d3e36e
en: d5b4923f86ec13e1
zh: 312ff5ac4ddf0e57
/document-office-documents/related-documentation:
en: b9691c6ee2c4db99
zh: 133970f11bfb85ee
+3 -3
View File
@@ -1,5 +1,5 @@
---
description: "Package map for Host Office rendering, conversion, and the model-facing office tool."
description: "Package map for Host Office rendering, conversion, and the model-facing Office tools."
kind: "package-group"
---
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
## Summary
Render, convert, and recalculate authorized Office files on the Host, for previews and for the model's `office` tool. The shared service runs LibreOffice kit. Targets with a declared native engine use it; other targets use Node WASM.
Render, convert, and recalculate authorized Office files on the Host, for previews and for the model's Office tools. The shared service runs LibreOffice kit. Targets with a declared native engine use it; other targets use Node WASM.
## Table of Contents
@@ -27,7 +27,7 @@ Each package owns its configuration and lifetime rules; the subsystem reference
| Package | Role | ctx key |
|---|---|---|
| [office-kit](office-kit/README.md) | Authorized Office bytes to complete PDFs, PNG images, converted files, and recalculated workbooks with bounded queues and caching; consumer-anchored Kit entry and engine manifests through `/locate` | `ctx.officeKit` |
| [tool-office](tool-office/README.md) | The resident `office` tool: render pages as images in the tool result, convert documents, and recalculate workbooks | — |
| [tool-office](tool-office/README.md) | `office_render`, `office_convert`, and `office_recalculate`, declared after an Office skill loads: render pages as images in the tool result, convert documents, and recalculate workbooks | — |
-----
+2 -2
View File
@@ -9,7 +9,7 @@ kind: "package-group"
## 摘要
在宿主上为预览和模型的 `office` 工具渲染、转换已授权的 Office 文件并重算工作簿。共享服务运行 LibreOffice kit。声明了原生引擎的目标使用原生引擎,其余目标使用 Node WASM。
在宿主上为预览和模型的 Office 工具渲染、转换已授权的 Office 文件并重算工作簿。共享服务运行 LibreOffice kit。声明了原生引擎的目标使用原生引擎,其余目标使用 Node WASM。
## 目录
@@ -27,7 +27,7 @@ kind: "package-group"
| 包 | 职责 | ctx 键 |
|---|---|---|
| [office-kit](office-kit/README.zh.md) | 将已授权 Office 字节转换为完整 PDF、PNG 图片、转换后的文件和重算后的工作簿,并提供有界队列和缓存;通过 `/locate` 以消费方 Kit 为起点定位 Kit 入口和引擎清单 | `ctx.officeKit` |
| [tool-office](tool-office/README.zh.md) | 常驻的 `office` 工具:在工具结果中把页面渲染为图片、转换文档、重算工作簿 | — |
| [tool-office](tool-office/README.zh.md) | 加载 Office 技能后声明的 `office_render`、`office_convert` 和 `office_recalculate`:在工具结果中把页面渲染为图片、转换文档、重算工作簿 | — |
-----
@@ -15,8 +15,8 @@
en: 8454159e70cbfb27
zh: ce266c78e285fe9c
/deepseek-ai-dsh-office-kit/use-this-package:
en: bc20abe587e9a72c
zh: 91a39f3dfcf5fccf
en: f702b6276686309f
zh: 29cdbd809f2db3c9
/deepseek-ai-dsh-office-kit/locate-kit:
en: a660d273bd72217c
zh: 99ddb3b5531b02dd
@@ -27,8 +27,8 @@
en: 9c62c26d46625e8b
zh: 9d0b734d70fdf948
/deepseek-ai-dsh-office-kit/model-experience:
en: 3d46ce458ad72f7d
zh: c358d7bb3eb70d22
en: 5b001842f3d350a1
zh: 244c53b867fff8d0
/deepseek-ai-dsh-office-kit/model-experience/kv-cache-effect:
en: cd1110fd1b70aaa0
zh: 623d77245348d129
+3 -3
View File
@@ -26,7 +26,7 @@ Render Office documents as PDFs or PNG images, convert them between formats, and
<a id="use-this-package"></a>
## Use this package
The [Web bundle](../../bundle/web-app/README.md) and the [SDK bundle](../../bundle/sdk-app/README.md) mount this provider as `office-kit`; the [`office` tool](../tool-office/README.md) is its model-facing consumer. Independent compositions mount `@deepseek-ai/dsh-office-kit` as a `cordis.yml` row.
The [Web bundle](../../bundle/web-app/README.md) and the [SDK bundle](../../bundle/sdk-app/README.md) mount this provider as `office-kit`; the [Office tools](../tool-office/README.md) are its model-facing consumers. Independent compositions mount `@deepseek-ai/dsh-office-kit` as a `cordis.yml` row.
Callers submit authorized source identity, version, optional byte size, a deferred bounded read, input extension, and scheduling priority. A changed source version rejects the operation. Cancellation rejects with its reason; failures use `OfficeKitError`. Every result carries the conversion generation, which changes on configuration replacement, and the missing fonts.
@@ -37,7 +37,7 @@ Callers submit authorized source identity, version, optional byte size, a deferr
| `convertTo()` | conversion to the format of `format`; CSV takes a `sheet` | the saved file's Host path, size, and PDF page count |
| `recalculate()` | XLS, XLSX, or ODS recalculation to XLSX or ODS | the saved workbook's Host path and size |
`renderImages()` requires `maxImages`, `maxPixels`, `maxDimension`, and `maxBytes`. The engine rejects a selection with more images than `maxImages` or an image above the pixel or dimension limit; the provider rejects images whose total PNG bytes exceed `maxBytes` with `output-too-large`, before and while reading them. A page, sheet, range, resolution, or format selection the engine rejects fails with `invalid-request` and the engine's description. Converted and recalculated files obey `maxOutputBytes`. The provider never writes into a workspace: it saves each output in its own owner-only directory under `outputDirectory`, grouped by the request's `output.owner` (the `office` tool passes the root Session of the caller's subagent tree), and returns the absolute Host path. A file is deleted after `outputRetentionMs`, when newer outputs need room within `maxOutputStoreBytes` (oldest first), when the Session whose id equals the owner is disposed, or when the provider unloads; a file larger than `maxOutputStoreBytes` fails with `output-too-large`. A file counts toward `maxOutputStoreBytes` until its deletion succeeds; a failed deletion is logged and retried by later eviction, release, and unload, and a save that cannot free enough room fails with `unavailable`. Unload waits for deletions in progress. Startup also removes expired output directories of earlier processes, considering only real directories, not links or junctions, with the names the provider generates: `session-` and 24 lowercase hexadecimal digits directly under `outputDirectory`, each holding lowercase UUID v4 output directories. Other entries are left untouched. `outputDirectory` is exposed on the service so consumers can check that their execution world reads it.
`renderImages()` requires `maxImages`, `maxPixels`, `maxDimension`, and `maxBytes`. The engine rejects a selection with more images than `maxImages` or an image above the pixel or dimension limit; the provider rejects images whose total PNG bytes exceed `maxBytes` with `output-too-large`, before and while reading them. A page, sheet, range, resolution, or format selection the engine rejects fails with `invalid-request` and the engine's description. Converted and recalculated files obey `maxOutputBytes`. The provider never writes into a workspace: it saves each output in its own owner-only directory under `outputDirectory`, grouped by the request's `output.owner` (`office_convert` and `office_recalculate` pass the root Session of the caller's subagent tree), and returns the absolute Host path. A file is deleted after `outputRetentionMs`, when newer outputs need room within `maxOutputStoreBytes` (oldest first), when the Session whose id equals the owner is disposed, or when the provider unloads; a file larger than `maxOutputStoreBytes` fails with `output-too-large`. A file counts toward `maxOutputStoreBytes` until its deletion succeeds; a failed deletion is logged and retried by later eviction, release, and unload, and a save that cannot free enough room fails with `unavailable`. Unload waits for deletions in progress. Startup also removes expired output directories of earlier processes, considering only real directories, not links or junctions, with the names the provider generates: `session-` and 24 lowercase hexadecimal digits directly under `outputDirectory`, each holding lowercase UUID v4 output directories. Other entries are left untouched. `outputDirectory` is exposed on the service so consumers can check that their execution world reads it.
The provider depends on the independently published [`@deepseek-ai/libreoffice-kit`](https://github.com/deepseek-ai/dsh-libreoffice-kit) npm API at kit version `0.2.3`. Application packaging selects the matching native package declared in the kit’s `optionalDependencies`, or WASM when no native package is declared for that target. A missing declared native engine rejects packaging without selecting WASM. The [release ownership decision](../../../.agents/notes/implemented/architecture/2026-09-14-independent-libreoffice-kit.md) defines the independent kit and Harness responsibilities.
@@ -118,7 +118,7 @@ Remote file reads recheck content authorization and source version before consul
<a id="model-experience"></a>
## Model Experience
Indirectly, through [the `office` tool](../tool-office/README.md#model-experience), which returns rendered images and converted files from this service.
Indirectly, through [the Office tools](../tool-office/README.md#model-experience), which return rendered images and converted files from this service.
#### KV Cache effect
+3 -3
View File
@@ -26,7 +26,7 @@ kind: "package-reference"
<a id="use-this-package"></a>
## 使用此包
[Web bundle](../../bundle/web-app/README.zh.md)和 [SDK bundle](../../bundle/sdk-app/README.zh.md)以 `office-kit` 条目挂载此提供方;[`office` 工具](../tool-office/README.zh.md)是其面向模型的消费方。独立组合通过 `cordis.yml` 条目挂载 `@deepseek-ai/dsh-office-kit`。
[Web bundle](../../bundle/web-app/README.zh.md)和 [SDK bundle](../../bundle/sdk-app/README.zh.md)以 `office-kit` 条目挂载此提供方;[Office 工具](../tool-office/README.zh.md)是其面向模型的消费方。独立组合通过 `cordis.yml` 条目挂载 `@deepseek-ai/dsh-office-kit`。
调用方提交已授权源的标识、版本、可选字节数、延迟的有界读取、输入扩展名和调度优先级。源版本变化会拒绝操作。取消以原因为拒绝值,失败使用 `OfficeKitError`。每个结果都携带转换 generation(配置替换后随之改变)和缺失字体。
@@ -37,7 +37,7 @@ kind: "package-reference"
| `convertTo()` | 转换为 `format` 指定的格式;CSV 需要 `sheet` | 已保存文件的 Host 路径、大小和 PDF 页数 |
| `recalculate()` | 把 XLS、XLSX 或 ODS 重算为 XLSX 或 ODS | 已保存工作簿的 Host 路径和大小 |
`renderImages()` 要求提供 `maxImages`、`maxPixels`、`maxDimension` 和 `maxBytes`。图片数超过 `maxImages`,或单张图片超过像素或尺寸上限时,引擎拒绝该选择;图片 PNG 总字节数超过 `maxBytes` 时,提供方在读取前和读取过程中以 `output-too-large` 拒绝。引擎拒绝的页、工作表、区域、分辨率或格式选择以 `invalid-request` 失败,并附带引擎的说明。转换和重算的文件受 `maxOutputBytes` 限制。提供方从不写入工作区:它把每个输出保存在 `outputDirectory` 下各自仅属主可访问的目录中,按请求的 `output.owner`(`office` 工具传入调用方 subagent 树的根 Session)分组,并返回绝对 Host 路径。文件在 `outputRetentionMs` 到期、较新的输出需要 `maxOutputStoreBytes` 内的空间(最旧的先删)、id 等于 owner 的 Session 卸载或提供方卸载时删除;单个文件超过 `maxOutputStoreBytes` 时以 `output-too-large` 失败。文件在删除成功之前一直计入 `maxOutputStoreBytes`;删除失败时记录日志,并在之后的淘汰、释放和卸载时重试,腾不出足够空间的保存以 `unavailable` 失败。卸载会等待进行中的删除结束。启动时还会删除之前进程留下的、超过保留期的输出目录,但只处理名字符合提供方生成格式的真实目录,不处理链接或 junction:`outputDirectory` 下一级为 `session-` 加 24 位小写十六进制数字,其下为小写 UUID v4 的输出目录。其他条目保持不动。服务公开 `outputDirectory`,供消费方检查其执行环境能否读取。
`renderImages()` 要求提供 `maxImages`、`maxPixels`、`maxDimension` 和 `maxBytes`。图片数超过 `maxImages`,或单张图片超过像素或尺寸上限时,引擎拒绝该选择;图片 PNG 总字节数超过 `maxBytes` 时,提供方在读取前和读取过程中以 `output-too-large` 拒绝。引擎拒绝的页、工作表、区域、分辨率或格式选择以 `invalid-request` 失败,并附带引擎的说明。转换和重算的文件受 `maxOutputBytes` 限制。提供方从不写入工作区:它把每个输出保存在 `outputDirectory` 下各自仅属主可访问的目录中,按请求的 `output.owner`(`office_convert` 和 `office_recalculate` 传入调用方 subagent 树的根 Session)分组,并返回绝对 Host 路径。文件在 `outputRetentionMs` 到期、较新的输出需要 `maxOutputStoreBytes` 内的空间(最旧的先删)、id 等于 owner 的 Session 卸载或提供方卸载时删除;单个文件超过 `maxOutputStoreBytes` 时以 `output-too-large` 失败。文件在删除成功之前一直计入 `maxOutputStoreBytes`;删除失败时记录日志,并在之后的淘汰、释放和卸载时重试,腾不出足够空间的保存以 `unavailable` 失败。卸载会等待进行中的删除结束。启动时还会删除之前进程留下的、超过保留期的输出目录,但只处理名字符合提供方生成格式的真实目录,不处理链接或 junction:`outputDirectory` 下一级为 `session-` 加 24 位小写十六进制数字,其下为小写 UUID v4 的输出目录。其他条目保持不动。服务公开 `outputDirectory`,供消费方检查其执行环境能否读取。
此 provider 依赖独立发布的 [`@deepseek-ai/libreoffice-kit`](https://github.com/deepseek-ai/dsh-libreoffice-kit) npm API,kit 版本为 `0.2.3`。应用打包选择 kit 的 `optionalDependencies` 中声明的匹配原生包;目标没有声明原生包时选择 WASM。已声明的原生引擎缺失时拒绝打包,不会选择 WASM。[发布归属决策](../../../.agents/notes/implemented/architecture/2026-09-14-independent-libreoffice-kit.zh.md)定义独立 kit 与 Harness 各自的职责。
@@ -118,7 +118,7 @@ Remote 文件读取在查询转换缓存前重新检查内容读取授权和源
<a id="model-experience"></a>
## 模型体验
间接地,通过 [`office` 工具](../tool-office/README.zh.md#model-experience),该工具返回此服务渲染的图片和转换的文件。
间接地,通过 [Office 工具](../tool-office/README.zh.md#model-experience),这些工具返回此服务渲染的图片和转换的文件。
#### KV Cache effect
+1 -1
View File
@@ -1,6 +1,6 @@
{
"meta": {
"title": "Office-Kit",
"description": "Rendert, konvertiert und berechnet Word-, Excel- und PowerPoint-Dokumente für Vorschauen und das Werkzeug office neu."
"description": "Rendert, konvertiert und berechnet Word-, Excel- und PowerPoint-Dokumente für Vorschauen und die Office-Werkzeuge neu."
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"meta": {
"title": "Office kit",
"description": "Renders, converts, and recalculates Word, Excel, and PowerPoint documents for previews and the office tool."
"description": "Renders, converts, and recalculates Word, Excel, and PowerPoint documents for previews and the Office tools."
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"meta": {
"title": "Kit de Office",
"description": "Representa, convierte y recalcula documentos de Word, Excel y PowerPoint para las vistas previas y la herramienta office."
"description": "Representa, convierte y recalcula documentos de Word, Excel y PowerPoint para las vistas previas y las herramientas de Office."
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"meta": {
"title": "Kit Office",
"description": "Affiche, convertit et recalcule les documents Word, Excel et PowerPoint pour les aperçus et l'outil office."
"description": "Affiche, convertit et recalcule les documents Word, Excel et PowerPoint pour les aperçus et les outils Office."
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"meta": {
"title": "Office キット",
"description": "プレビューと office ツールのために Word、Excel、PowerPoint 文書を描画・変換し、ブックを再計算します。"
"description": "プレビューと Office ツールのために Word、Excel、PowerPoint 文書を描画・変換し、ブックを再計算します。"
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"meta": {
"title": "Kit do Office",
"description": "Renderiza, converte e recalcula documentos do Word, Excel e PowerPoint para pré-visualizações e a ferramenta office."
"description": "Renderiza, converte e recalcula documentos do Word, Excel e PowerPoint para pré-visualizações e as ferramentas do Office."
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"meta": {
"title": "Набор Office",
"description": "Отрисовывает, преобразует и пересчитывает документы Word, Excel и PowerPoint для предпросмотра и инструмента office."
"description": "Отрисовывает, преобразует и пересчитывает документы Word, Excel и PowerPoint для предпросмотра и инструментов Office."
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"meta": {
"title": "Office 套件",
"description": "为预览和 office 工具渲染、转换 Word、Excel 和 PowerPoint 文档,并重算工作簿。"
"description": "为预览和 Office 工具渲染、转换 Word、Excel 和 PowerPoint 文档,并重算工作簿。"
}
}
+24 -24
View File
@@ -3,44 +3,44 @@
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write packages/document/tool-office/README.md
/:
en: 15d530cb03d97b74
zh: d0d9f6941f0963ba
en: 2ec7e66cd18356df
zh: 4862555b5a4c9f51
/deepseek-ai-dsh-tool-office:
en: e9153903d819e2a7
zh: 3f50cf3c768a1af5
/deepseek-ai-dsh-tool-office/summary:
en: 4455c304b557b80f
zh: 1c14fd34ced755ed
en: e74f50cd7e13fad9
zh: f234831ae934f60a
/deepseek-ai-dsh-tool-office/table-of-contents:
en: d152484eb41ac6b4
zh: 09388d293f9be9cb
/deepseek-ai-dsh-tool-office/use-this-package:
en: 0d4e3ab4fefd478c
zh: a6926f482c0c7576
en: 2b035f2b430c9e92
zh: 67c4ce315c067e17
/deepseek-ai-dsh-tool-office/understand-the-implementation:
en: b90e60b4bf9a200b
zh: fbc977cf7c31d169
en: 091801006a805958
zh: 229337e4add16130
/deepseek-ai-dsh-tool-office/further-exploration:
en: 6ead94ce84c2f528
zh: 0a37f6980e2bc08d
en: 5d20d2318d1957cf
zh: 8b8111099ab8bb46
/deepseek-ai-dsh-tool-office/model-experience:
en: 215e7ba838619b7b
zh: a311da3843709f90
/deepseek-ai-dsh-tool-office/model-experience/office:
en: e5917dbf18bf2d87
zh: e5917dbf18bf2d87
/deepseek-ai-dsh-tool-office/model-experience/office/what-the-model-sees:
en: b3fead1235d01b07
zh: 1c840d1c577fabbf
/deepseek-ai-dsh-tool-office/model-experience/office/token-effect:
en: 2aa995229da70fb3
zh: a3f814324f8660b7
/deepseek-ai-dsh-tool-office/model-experience/office/kv-cache-effect:
en: 22f03adf19cc71a5
zh: a053a4a469bcb189
/deepseek-ai-dsh-tool-office/model-experience/office-render-office-convert-office-recalculate:
en: 3bc9eb9e036e6224
zh: 3bc9eb9e036e6224
/deepseek-ai-dsh-tool-office/model-experience/office-render-office-convert-office-recalculate/what-the-model-sees:
en: 71b1bbd1d32af598
zh: 3eecd8daeb3fe8e3
/deepseek-ai-dsh-tool-office/model-experience/office-render-office-convert-office-recalculate/token-effect:
en: b8d5d8c33c7563d4
zh: 5b6cb183b690bdba
/deepseek-ai-dsh-tool-office/model-experience/office-render-office-convert-office-recalculate/kv-cache-effect:
en: c4e3595dab58a800
zh: 65f7fcf46b1e3130
/deepseek-ai-dsh-tool-office/known-limitations-and-deferred-work:
en: 58a7524b04e6c103
zh: 1720b0ac2c75a7df
en: c423feeb59afcf62
zh: 9ddc3edb7f1cad76
/deepseek-ai-dsh-tool-office/known-limitations-and-deferred-work/dev-note:
en: e67f633dc6fe7773
zh: e88aeb617ffb74ea
+24 -11
View File
@@ -1,5 +1,5 @@
---
description: "The office tool: render document pages as images the model sees, convert documents, and recalculate workbooks through the shared Office kit."
description: "Skill-activated Office tools for viewing document pages, converting documents, and recalculating workbooks."
kind: "package-reference"
---
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
## Summary
Give the model one `office` tool for Office operations. `render` returns document pages, slides, or worksheet areas as images in the tool result, so the model inspects layout without temporary files or a separate image read. `convert` produces a document in another format and `recalculate` a workbook with refreshed formula results, each as a temporary file that the model copies to its destination with the shell; the tool itself writes no workspace file. All three run through the shared [Office kit](../office-kit/README.md) service in the Host process, in standard and PTC modes alike.
After an Office skill loads, the model gains three tools. `office_render` returns document pages, slides, or worksheet areas as images for layout inspection, without temporary image files or a separate image read. `office_convert` produces a document in another format; `office_recalculate` refreshes workbook formulas. Both return a temporary file to copy to its destination with the shell. The tools do not modify inputs or write workspace files, and work in standard and PTC modes alike.
## Table of Contents
@@ -25,7 +25,11 @@ Give the model one `office` tool for Office operations. `render` returns documen
<a id="use-this-package"></a>
## Use this package
The [Web bundle](../../bundle/web-app/README.md) and the [SDK bundle](../../bundle/sdk-app/README.md) mount this tool with `office-kit` in Desktop, ordinary `dsh web`, and the SDK; in the Web bundle the `standard` and `ptc` agent presets include it and the `minimal` preset does not. The tool is registered whether or not LibreOffice Kit is installed or the `office-kit` service is mounted, and it reads that service at each call. When Kit is missing, every call fails with the Office service's `unavailable` message; while the service is absent, every call fails with `The document converter is unavailable.` Both failures tell the model to tell the user the operation is unavailable without substituting system soffice, npx, or another converter. The [Office skills](../../skill/skill-office/README.md) tell the model when to render and how to check results.
The [Web bundle](../../bundle/web-app/README.md) and the [SDK bundle](../../bundle/sdk-app/README.md) mount this plugin with `office-kit` in Desktop, ordinary `dsh web`, and the SDK; in the Web bundle the `standard` and `ptc` agent presets include it and the `minimal` preset does not. Loading any configured [Office skill](../../skill/skill-office/README.md) activates all three tools from the next model step, whether loaded by a model `skill` call, a nested PTC call, or direct user invocation such as `/office`. Failed loads and other skills do not activate them. Calls before activation return `UNKNOWN_TOOL`.
Activation matches only the skill names listed in `activationSkills`, so mount [`@deepseek-ai/dsh-skill-office`](../../skill/skill-office/README.md) or another provider that registers skills with those names; without one, the three tools never appear.
The tools read the Office kit service at each call. When Kit is missing, calls fail with the service's `unavailable` message; while the service is absent, calls fail with `The document converter is unavailable.` Both failures tell the model to inform the user without substituting system soffice, npx, or another converter.
```yaml
- name: '@deepseek-ai/dsh-office-kit'
@@ -36,6 +40,7 @@ The [Web bundle](../../bundle/web-app/README.md) and the [SDK bundle](../../bund
| Field | Default | Meaning |
|---|---|---|
| `activationSkills` | `[office, office-docx, office-xlsx, office-pptx]` | Nonempty list of kebab-case skill names whose successful loading activates all three tools |
| `maxImages` | `20` | Maximum images one render returns, including worksheet fragments |
| `maxImagePixels` | `8388608` | Maximum pixels of each image |
| `maxImageDimension` | `8192` | Maximum width and height of each image |
@@ -43,7 +48,9 @@ The [Web bundle](../../bundle/web-app/README.md) and the [SDK bundle](../../bund
A render applies the lower of each field and the attachment store's corresponding image limit (`maxImagesPerMessage`, `maxImagePixels`, `maxImageDimension`, `maxMessageImageBytes`), and refuses any single image above `maxImageBytes` of the store. A selection beyond a bound fails instead of being truncated. Rendering requires an attachment store and a calling model route that declares image input. The tool reads that route from the latest model request of the Session, or from the agent options before the first request, and refuses a model whose input modalities omit images or are not declared before any rendering work starts.
Inputs resolve against the Session working directory and use the filesystem backend's read authority, as `read` and Office previews do, so files outside the workspace are readable. The input extension selects the document family, and `format` selects the output of `convert` and `recalculate`. Their result names a file in the Office kit's private [output store](../office-kit/README.md#use-this-package) under the Harness home; the model copies it with the shell, so the shell's sandbox and approvals govern where it lands. When the filesystem backend cannot read Host files, such as an SSH workspace, `convert` and `recalculate` fail before converting; `render` still works.
Inputs resolve against the Session working directory and use the filesystem backend's read authority, as `read` and Office previews do, so files outside the workspace are readable. The input extension selects the document family. `office_convert` accepts Word, Excel, and PowerPoint documents: Word exports to pdf, docx, odt, or txt; Excel to pdf, xlsx, ods, or csv; PowerPoint to pdf, pptx, or odp. CSV export requires a worksheet name for a workbook with several sheets. `office_recalculate` accepts xls, xlsx, and ods workbooks and requires xlsx or ods output. `office_render` also accepts PDF.
Conversion and recalculation results name a file in the Office kit's private [output store](../office-kit/README.md#use-this-package) under the Harness home; the model copies it with the shell, so the shell's sandbox and approvals govern where it lands. When the filesystem backend cannot read Host files, such as an SSH workspace, these two tools fail before converting; rendering still works.
Every request enters the Office kit's shared queue with `foreground` priority, the same class as an open preview. Foreground work runs before background prewarming and can evict queued background jobs, so speculative previews cannot starve tool calls; tool calls and open previews share admission in arrival order.
@@ -57,7 +64,11 @@ Every request enters the Office kit's shared queue with `foreground` priority, t
The tool resolves the input through `ctx.fs`, requires a regular file, reads its first byte through `fs.readByteRange`, and stats it again, so a call without content read access, or for a file replaced since its stat, fails before the Office kit can answer from its cache. It then passes the Office kit an authorized source whose deferred read stats the file before and after a bounded `fs.readBytes` and rejects a changed version. Render results are committed through `attachments.saveImages()` before the result returns, so the `tool/result` event carries durable image references; resume, fork, and replay restore the same images, and image offload applies to them like any other tool-result image. The canonical value carries attachment references and image locations; `output.render` produces one summary text, then a location label and image block per rendered page or area. `presentationMeta` records the canonical input path, plus the temporary file path for conversions. Output store files are owned by the root Session of the caller's subagent tree, read through `subagents.rootOf()` when that service is mounted and otherwise the calling Session, and are named after the input with the new extension.
Argument rules that the schema cannot express — operation-specific parameters, distinct one-based pages, the dpi range, and the input and output formats of each operation — are checked before any file access. Office kit errors are reported as `cannot <operation> "<path>": <message>`, with a hint for `unavailable` to tell the user, a retry hint for `busy`, and a selection hint for oversized renders. Nested PTC calls re-enter the same execution pipeline, so policy and logging apply to them; a nested render's images are attached after the program run.
Each tool declares its own parameters and result schema. The supported schema subset cannot express page uniqueness, numeric bounds, or cross-parameter rules, so those render selections and input-dependent conversion formats are checked at runtime. Office kit errors are reported as `cannot <operation> "<path>": <message>`, with a hint for `unavailable` to tell the user, a retry hint for `busy`, and a selection hint for oversized renders. Nested PTC calls re-enter the same execution pipeline, so policy and logging apply to them; a nested render's images are attached after the program run.
Successful `tools/result` notifications mark the calling Agent in a plugin-owned WeakSet. The post-commit `session/event` feed also marks direct user skill invocations, without depending on pre-step listener order. `agent/disposed` clears the mark. The three tools share one `when`: the Agent is marked, or the Session's latest public `requestHeader()` lists any Office tool. No additional projection or Session event is registered.
Native request headers retain Office declarations across resume and fork, including the first request after restoration; compaction replaces conversation content without removing request headers. PTC records only `run_code` in its request header, so a resumed or forked PTC Agent must load an Office skill again. Losing an Agent's memory before a native Office declaration is recorded also loses activation; calling `skill` again restores it on the following step.
</details>
@@ -67,25 +78,25 @@ Argument rules that the schema cannot express — operation-specific parameters,
## Further Exploration
- [Office kit](../office-kit/README.md) — conversion queue, limits, and Kit location.
- [Office tool decision](../../../.agents/notes/implemented/architecture/2026-10-31-native-office-tool.md) — why Office operations use a resident Host tool.
- [Office tool decision](../../../.agents/notes/implemented/architecture/2026-10-31-native-office-tool.md) — why Office operations run through the Host.
- [Tool authoring reference](../../../docs/cookbook/adding-a-tool.md) — execution and presentation contracts.
<a id="model-experience"></a>
## Model Experience
### office
### office_render, office_convert, office_recalculate
#### What the model sees
The [office schema](../../../docs/tool-catalog.md#office) is always present while the plugin is mounted. A render result opens with `Rendered <count> image(s) of <absolute input path> (<pageCount> in the document) at <dpi> DPI.`, adds `Fonts not installed and substituted: <families>.` when fonts are missing, then gives each image as a `Page <n>: <width>x<height> px` or `Sheet "<name>" <range>: <width>x<height> px` label followed by the image. A conversion reports `Converted <input> to <format> (<bytes> bytes[, <n> pages]): <temporary file>` (or `Recalculated …`), then `Copy this temporary file to its destination with the shell now; it is deleted when this conversation ends.` and the same font line. Failures read `cannot <operation> "<path>": <reason>`.
The three declarations are documented in the [tool catalog](../../../docs/tool-catalog.md). A render result opens with `Rendered <count> image(s) of <absolute input path> (<pageCount> in the document) at <dpi> DPI.`, adds `Fonts not installed and substituted: <families>.` when fonts are missing, then gives each image as a `Page <n>: <width>x<height> px` or `Sheet "<name>" <range>: <width>x<height> px` label followed by the image. A conversion reports `Converted <input> to <format> (<bytes> bytes[, <n> pages]): <temporary file>` (or `Recalculated …`), then `Copy this temporary file to its destination with the shell now; it is deleted when this conversation ends.` and the same font line. Failures read `cannot <operation> "<path>": <reason>`.
#### Token effect
One fixed tool schema per request while mounted. Each render adds its summary, one short label per image, and the images, bounded by the configured and attachment image limits; image tokens depend on the route's image pricing. Conversions add two lines.
No Office declarations before activation; three fixed tool schemas afterward, represented as program bindings in PTC mode. Each render adds its summary, one short label per image, and the images, bounded by the configured and attachment image limits; image tokens depend on the route's image pricing. Conversions add two lines.
#### KV Cache effect
The schema is static for the mount lifetime and does not depend on loaded skills, so the tool-declaration prefix stays stable. Results append to the conversation; image offload may later replace an image occurrence with placeholder text through its own logged event.
In native mode, activation during a conversation appends one `developer/message` with `tool-addition` blocks; a route that declares `toolUpdate` keeps the request prefix unchanged, and other routes start one new request series. Native resume and fork retain the declarations. In PTC mode, the three tools are bindings listed in the `run_code` section of the system prompt, so activation rewrites the system prompt: a route that declares `systemPromptUpdate: in-history` appends one system message, and other routes start one new request series. PTC resume or fork loses the in-memory mark, so the system prompt changes twice: the next step removes the bindings, and loading an Office skill again adds them back. Results append to the conversation; image offload may later replace an image occurrence with placeholder text through its own logged event.
## Known Limitations and Deferred Work
@@ -93,8 +104,10 @@ The schema is static for the mount lifetime and does not depend on loaded skills
- **Converted files need a shell copy** — the filesystem service creates no binary files, so the model copies each temporary file with the shell. Deployments without a shell tool cannot deliver converted files, and the temporary file is deleted after the Office kit's retention or when the root Session of the caller's subagent tree is disposed; a file a subagent produced stays after that subagent ends.
- **No conversion on remote workspaces** — the Office kit runs on the Host, and a remote shell cannot read its output store.
- **Render saves no image file** — `render` returns images only for the model to view and writes no PNG or other image file. A user who needs the pages as a file gets a PDF through `convert` with `format: "pdf"`.
- **Render saves no image file** — `office_render` returns images only for the model to view and writes no PNG or other image file. A user who needs the pages as a file gets a PDF through `office_convert` with `format: "pdf"`.
- **Native engine in the Host process** — rendering, conversion, and recalculation that the model starts run the native LibreOffice Kit engine inside the Host process through `ctx.officeKit`, so the shell sandbox and PTC permissions do not confine them. Inputs remain subject to the filesystem backend's read authority. The native parser processes an untrusted document with the Host user's permissions.
- **PTC activation does not survive resume or fork** — the PTC request header records only `run_code`, so a resumed or forked PTC Agent offers no Office bindings until the model loads an Office skill again; the removal and the re-addition each rewrite the system prompt, with the cache effect described under KV Cache effect.
- **Plugin reload clears activation** — hot reload, or disabling and re-enabling the plugin, clears the in-memory marks. If a step runs in the meantime, its request header omits the three tools, and the model must load an Office skill again to restore them.
- Rendering fidelity, fonts, and pagination follow LibreOffice Kit and can differ from Microsoft Office.
<a id="dev-note"></a>
+24 -11
View File
@@ -1,5 +1,5 @@
---
description: "office 工具:把文档页面渲染为模型可直接查看的图片,并通过共享 Office 套件转换文档、重算工作簿。"
description: "由技能激活的 Office 工具,用于查看文档页面、转换文档和重算工作簿。"
kind: "package-reference"
---
@@ -9,7 +9,7 @@ kind: "package-reference"
## 概述
为模型提供一个用于 Office 操作的 `office` 工具。`render` 把文档页面、幻灯片或工作表区域作为图片放进工具结果,模型无需临时文件或单独读取图片即可检查版式。`convert` 生成另一种格式的文档,`recalculate` 生成公式结果已刷新的工作簿,二者都给出一个临时文件,由模型用 shell 复制到目标位置;工具本身不写工作区文件。三种操作都在 Host 进程中通过共享的 [Office 套件](../office-kit/README.zh.md)服务执行,标准模式与 PTC 模式相同。
加载 Office 技能后,模型获得三个工具。`office_render` 将文档页面、幻灯片或工作表区域作为图片返回,用于检查版式,无需临时图片文件或单独读取图片。`office_convert` 生成另一种格式的文档;`office_recalculate` 刷新工作簿公式。二者都返回临时文件,由模型用 shell 复制到目标位置。工具不修改输入,也不写工作区文件,标准模式与 PTC 模式行为相同。
## 目录
@@ -25,7 +25,11 @@ kind: "package-reference"
<a id="use-this-package"></a>
## 使用本包
[Web bundle](../../bundle/web-app/README.zh.md)和 [SDK bundle](../../bundle/sdk-app/README.zh.md)在 Desktop、普通 `dsh web` 和 SDK 中随 `office-kit` 挂载此工具;Web bundle 中由 `standard` 和 `ptc` Agent 预设包含它,`minimal` 预设不包含。无论是否安装 LibreOffice Kit、是否挂载 `office-kit` 服务,工具都会注册,并在每次调用时读取该服务。Kit 缺失时,每次调用都以 Office 服务的 `unavailable` 消息失败;服务不存在时,每次调用都以 `The document converter is unavailable.` 失败。两种失败都提示模型告知用户该操作不可用,不改用系统 soffice、npx 或其他转换工具。[Office 技能](../../skill/skill-office/README.zh.md)告诉模型何时渲染以及如何检查结果。
[Web bundle](../../bundle/web-app/README.zh.md)和 [SDK bundle](../../bundle/sdk-app/README.zh.md)在 Desktop、普通 `dsh web` 和 SDK 中随 `office-kit` 挂载此插件;Web bundle 中由 `standard` 和 `ptc` Agent 预设包含它,`minimal` 预设不包含。加载任一配置的 [Office 技能](../../skill/skill-office/README.zh.md)后,三个工具从模型的下一步起全部激活,无论技能由模型调用 `skill`、PTC 嵌套调用,还是用户以 `/office` 等方式直接调用。加载失败或加载其他技能不会激活工具。激活前调用返回 `UNKNOWN_TOOL`。
激活只匹配 `activationSkills` 中列出的技能名,因此须同时挂载 [`@deepseek-ai/dsh-skill-office`](../../skill/skill-office/README.zh.md),或其他注册了同名技能的 provider;否则三个工具永远不会出现。
工具在每次调用时读取 Office 套件服务。Kit 缺失时,调用以该服务的 `unavailable` 消息失败;服务不存在时,调用以 `The document converter is unavailable.` 失败。两种失败都提示模型告知用户,不改用系统 soffice、npx 或其他转换工具。
```yaml
- name: '@deepseek-ai/dsh-office-kit'
@@ -36,6 +40,7 @@ kind: "package-reference"
| 字段 | 默认值 | 含义 |
|---|---|---|
| `activationSkills` | `[office, office-docx, office-xlsx, office-pptx]` | 非空 kebab-case 技能名列表;成功加载其中任一技能即激活三个工具 |
| `maxImages` | `20` | 一次渲染返回的最大图片数,含工作表分片 |
| `maxImagePixels` | `8388608` | 每张图片的最大像素数 |
| `maxImageDimension` | `8192` | 每张图片的最大宽度和高度 |
@@ -43,7 +48,9 @@ kind: "package-reference"
渲染对每个字段取其与附件存储对应图片上限(`maxImagesPerMessage`、`maxImagePixels`、`maxImageDimension`、`maxMessageImageBytes`)中的较小值,并拒绝超过存储 `maxImageBytes` 的单张图片。超出上限的选择直接失败,不会被截断。渲染要求挂载附件存储,且调用方模型路由声明支持图片输入。工具从会话最近一次模型请求读取该路由,首次请求之前则读取 agent 选项;模型的输入模态不含图片或未声明时,在开始任何渲染工作之前就会被拒绝。
输入相对 Session 工作目录解析,并沿用文件系统后端的读取权限,与 `read` 和 Office 预览一致,因此可以读取工作区外的文件。输入扩展名决定文档类别,`format` 决定 `convert` 和 `recalculate` 的输出格式。其结果给出 Office 套件私有[输出存储](../office-kit/README.zh.md#use-this-package)中位于 Harness 主目录下的一个文件;模型用 shell 复制它,因此文件落在哪里由 shell 的沙箱和审批决定。文件系统后端无法读取 Host 文件时(例如 SSH 工作区),`convert` 和 `recalculate` 在转换前即失败;`render` 不受影响。
输入相对 Session 工作目录解析,并沿用文件系统后端的读取权限,与 `read` 和 Office 预览一致,因此可以读取工作区外的文件。输入扩展名决定文档类别。`office_convert` 接受 Word、Excel 和 PowerPoint 文档:Word 可导出 pdf、docx、odt 或 txt;Excel 可导出 pdf、xlsx、ods 或 csv;PowerPoint 可导出 pdf、pptx 或 odp。多工作表工作簿导出 CSV 时必须指定工作表名。`office_recalculate` 接受 xls、xlsx 和 ods 工作簿,输出必须为 xlsx 或 ods。`office_render` 还接受 PDF。
转换和重算结果给出 Office 套件私有[输出存储](../office-kit/README.zh.md#use-this-package)中位于 Harness 主目录下的一个文件;模型用 shell 复制它,因此文件落在哪里由 shell 的沙箱和审批决定。文件系统后端无法读取 Host 文件时(例如 SSH 工作区),这两个工具在转换前即失败;渲染不受影响。
每个请求都以 `foreground` 优先级进入 Office 套件的共享队列,与打开的预览同级。前台工作先于后台预热执行,并可驱逐排队中的后台任务,因此推测性预览不会饿死工具调用;工具调用与打开的预览按到达顺序共享准入。
@@ -57,7 +64,11 @@ kind: "package-reference"
工具通过 `ctx.fs` 解析输入并要求其为普通文件,用 `fs.readByteRange` 读取其第一个字节后再 stat 一次,因此没有内容读取权限的调用,或文件在 stat 之后被替换的调用,会在 Office 套件可能从缓存应答之前失败。随后工具向 Office 套件提交已授权的源;其延迟读取在有界的 `fs.readBytes` 前后各 stat 一次,版本变化时拒绝。渲染结果在返回前通过 `attachments.saveImages()` 提交,因此 `tool/result` 事件携带持久的图片引用;恢复、分叉和回放会还原相同的图片,图片卸载也像对待其他工具结果图片一样适用于它们。规范值携带附件引用和图片位置;`output.render` 先生成一条摘要文本,再为每个渲染的页面或区域生成位置标签和图片块。`presentationMeta` 记录规范化的输入路径,转换时还记录临时文件路径。输出存储中的文件归调用方 subagent 树的根 Session 所有:挂载 `subagents` 服务时通过 `subagents.rootOf()` 读取,否则为调用方 Session;文件以输入文件名加新扩展名命名。
schema 无法表达的参数规则——各操作专用的参数、互不重复的从 1 开始的页码、dpi 范围以及各操作的输入输出格式——在访问任何文件之前检查。Office 套件的错误报告为 `cannot <operation> "<path>": <message>`,`unavailable` 附带告知用户的提示,`busy` 附带重试提示,渲染过大时附带缩小选择的提示。PTC 嵌套调用重新进入同一执行管线,因此策略和日志同样适用;嵌套渲染的图片在程序运行结束后附加。
每个工具分别声明参数和结果 schema。受支持的 schema 子集无法表达页码唯一性、数值范围和跨参数规则,因此这些渲染选择以及依赖输入类型的转换格式在运行时检查。Office 套件的错误报告为 `cannot <operation> "<path>": <message>`,`unavailable` 附带告知用户的提示,`busy` 附带重试提示,渲染过大时附带缩小选择的提示。PTC 嵌套调用重新进入同一执行管线,因此策略和日志同样适用;嵌套渲染的图片在程序运行结束后附加。
成功的 `tools/result` 通知将调用方 Agent 记入插件拥有的 WeakSet。提交后的 `session/event` 事件流也会标记用户直接调用的技能,不依赖 pre-step 监听器顺序。`agent/disposed` 清除标记。三个工具共用一个 `when`:Agent 已被标记,或 Session 最新的公开 `requestHeader()` 中列出了任一 Office 工具。不注册额外的 projection 或 Session 事件。
原生请求头在恢复和分叉后保留 Office 声明,包括还原后的首次请求;压缩只替换对话内容,不删除请求头。PTC 的请求头只记录 `run_code`,因此恢复或分叉后的 PTC Agent 必须重新加载 Office 技能。如果 Agent 在原生 Office 声明落盘前丢失内存,激活状态也会丢失;再次调用 `skill` 即可在下一步恢复。
</details>
@@ -67,25 +78,25 @@ schema 无法表达的参数规则——各操作专用的参数、互不重复
## 进一步探索
- [Office 套件](../office-kit/README.zh.md) — 转换队列、上限和 Kit 定位。
- [Office 工具决策](../../../.agents/notes/implemented/architecture/2026-10-31-native-office-tool.zh.md) — Office 操作为何使用常驻的 Host 工具。
- [Office 工具决策](../../../.agents/notes/implemented/architecture/2026-10-31-native-office-tool.zh.md) — Office 操作为何通过 Host 执行。
- [工具编写参考](../../../docs/cookbook/adding-a-tool.zh.md) — 执行与展示契约。
<a id="model-experience"></a>
## 模型体验
### office
### office_render, office_convert, office_recalculate
#### 模型看到的内容
插件挂载期间,[office schema](../../../docs/tool-catalog.zh.md#office) 始终存在。渲染结果以 `Rendered <count> image(s) of <absolute input path> (<pageCount> in the document) at <dpi> DPI.` 开头,缺少字体时追加 `Fonts not installed and substituted: <families>.`,随后每张图片先给出 `Page <n>: <width>x<height> px` 或 `Sheet "<name>" <range>: <width>x<height> px` 标签,再给出图片。转换时报告 `Converted <input> to <format> (<bytes> bytes[, <n> pages]): <temporary file>`(或 `Recalculated …`),随后是 `Copy this temporary file to its destination with the shell now; it is deleted when this conversation ends.` 和相同的字体行。失败为 `cannot <operation> "<path>": <reason>`。
三个工具的声明见[工具目录](../../../docs/tool-catalog.zh.md)。渲染结果以 `Rendered <count> image(s) of <absolute input path> (<pageCount> in the document) at <dpi> DPI.` 开头,缺少字体时追加 `Fonts not installed and substituted: <families>.`,随后每张图片先给出 `Page <n>: <width>x<height> px` 或 `Sheet "<name>" <range>: <width>x<height> px` 标签,再给出图片。转换时报告 `Converted <input> to <format> (<bytes> bytes[, <n> pages]): <temporary file>`(或 `Recalculated …`),随后是 `Copy this temporary file to its destination with the shell now; it is deleted when this conversation ends.` 和相同的字体行。失败为 `cannot <operation> "<path>": <reason>`。
#### Token 影响
挂载期间每个请求包含一份固定的工具 schema。每次渲染追加摘要、每张图片一条简短标签以及图片本身,受配置与附件图片上限约束;图片 token 取决于路由的图片计价。转换时追加两行。
激活前没有 Office 声明;激活后包含三份固定的工具 schema,在 PTC 模式下表示为程序绑定。每次渲染追加摘要、每张图片一条简短标签以及图片本身,受配置与附件图片上限约束;图片 token 取决于路由的图片计价。转换时追加两行。
#### KV Cache 影响
schema 在挂载期间保持不变,且不依赖已加载的技能,因此工具声明前缀保持稳定。结果追加到对话末尾;图片卸载之后可能通过其自身记录的事件把某个图片出现替换为占位文本。
原生模式下,工具在对话中途激活时追加一条带 `tool-addition` 块的 `developer/message`;声明了 `toolUpdate` 的路由保持请求前缀不变,其他路由开始一次新的请求序列。原生模式的恢复和分叉保留这些声明。PTC 模式下,三个工具是系统提示中 `run_code` 一节列出的程序绑定,因此激活会重写系统提示:声明了 `systemPromptUpdate: in-history` 的路由追加一条系统消息,其他路由开始一次新的请求序列。PTC 恢复或分叉会丢失内存中的标记,因此系统提示会变化两次:下一步移除这些绑定,再次加载 Office 技能后又加回。结果追加到对话末尾;图片卸载之后可能通过其自身记录的事件把某个图片出现替换为占位文本。
## 已知限制与延期工作
@@ -93,8 +104,10 @@ schema 在挂载期间保持不变,且不依赖已加载的技能,因此工
- **转换后的文件需要 shell 复制** — 文件系统服务不创建二进制文件,因此模型用 shell 复制每个临时文件。没有 shell 工具的部署无法交付转换后的文件;临时文件在 Office 套件的保留期满或调用方 subagent 树的根 Session 卸载后删除;subagent 产出的文件在该 subagent 结束后仍然保留。
- **远程工作区不支持转换** — Office 套件运行在 Host 上,远程 shell 读不到其输出存储。
- **渲染不保存图片文件** — `render` 只返回供模型查看的图片,不写出 PNG 或其他图片文件。需要以文件形式获得页面的用户,通过 `convert` 并设置 `format: "pdf"` 获得 PDF。
- **渲染不保存图片文件** — `office_render` 只返回供模型查看的图片,不写出 PNG 或其他图片文件。需要以文件形式获得页面的用户,通过 `office_convert` 并设置 `format: "pdf"` 获得 PDF。
- **原生引擎在 Host 进程内运行** — 由模型发起的渲染、转换和重算通过 `ctx.officeKit` 在 Host 进程内运行原生 LibreOffice Kit 引擎,因此不受 shell 沙箱和 PTC 权限约束。输入仍受文件系统后端读取权限的约束。原生解析器以 Host 用户的权限处理不可信的文档。
- **PTC 激活状态不跨恢复和分叉保留** — PTC 请求头只记录 `run_code`,因此恢复或分叉后的 PTC Agent 在模型重新加载 Office 技能前不提供 Office 绑定;移除和重新加入各重写一次系统提示,缓存影响见 KV Cache 影响一节。
- **插件重载会清除激活状态** — 热重载、或停用后再启用插件,会清空内存中的标记。如果期间运行过一步,该步的请求头不再包含这三个工具,模型须重新加载 Office 技能才能恢复。
- 渲染保真度、字体和分页取决于 LibreOffice Kit,可能与 Microsoft Office 不同。
<a id="dev-note"></a>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"meta": {
"title": "Office-Werkzeug",
"title": "Office-Werkzeuge",
"description": "Lässt den Agenten Dokumentseiten als Bilder ansehen, Dokumente in andere Formate konvertieren und Tabellen neu berechnen."
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"meta": {
"title": "Office tool",
"title": "Office tools",
"description": "Lets the agent view document pages as images, convert documents to other formats, and recalculate spreadsheets."
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"meta": {
"title": "Herramienta de Office",
"title": "Herramientas de Office",
"description": "Permite al agente ver páginas de documentos como imágenes, convertir documentos a otros formatos y recalcular hojas de cálculo."
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"meta": {
"title": "Outil Office",
"title": "Outils Office",
"description": "Permet à l'agent de voir les pages des documents sous forme d'images, de convertir des documents dans d'autres formats et de recalculer des feuilles de calcul."
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"meta": {
"title": "Ferramenta do Office",
"title": "Ferramentas do Office",
"description": "Permite ao agente ver páginas de documentos como imagens, converter documentos para outros formatos e recalcular planilhas."
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"meta": {
"title": "Инструмент Office",
"title": "Инструменты Office",
"description": "Позволяет агенту просматривать страницы документов как изображения, преобразовывать документы в другие форматы и пересчитывать таблицы."
}
}
+6 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@deepseek-ai/dsh-tool-office",
"description": "Model-facing office tool that renders, converts, and recalculates documents through the shared Office kit",
"description": "Model-facing Office tools for rendering, converting, and recalculating documents",
"version": "0.2.2-alpha.2",
"publishConfig": {
"access": "public"
@@ -33,10 +33,12 @@
},
"peerDependencies": {
"@deepseek-ai/cordis": "workspace:~",
"@deepseek-ai/dsh-agent": "workspace:*",
"@deepseek-ai/dsh-attachment": "workspace:*",
"@deepseek-ai/dsh-fs": "workspace:*",
"@deepseek-ai/dsh-llm": "workspace:*",
"@deepseek-ai/dsh-office-kit": "workspace:*",
"@deepseek-ai/dsh-skill": "workspace:*",
"@deepseek-ai/dsh-subagent": "workspace:*",
"@deepseek-ai/dsh-tools": "workspace:*",
"@deepseek-ai/dsh-working-directory": "workspace:*"
@@ -53,11 +55,14 @@
"@deepseek-ai/dsh-office-kit": "workspace:*",
"@deepseek-ai/dsh-scope": "workspace:*",
"@deepseek-ai/dsh-session": "workspace:*",
"@deepseek-ai/dsh-session-persistence-jsonl": "workspace:*",
"@deepseek-ai/dsh-session-projection": "workspace:*",
"@deepseek-ai/dsh-skill": "workspace:*",
"@deepseek-ai/dsh-subagent": "workspace:*",
"@deepseek-ai/dsh-system-prompt": "workspace:*",
"@deepseek-ai/dsh-tool-executor-native": "workspace:*",
"@deepseek-ai/dsh-tool-executor-ptc": "workspace:*",
"@deepseek-ai/dsh-tool-skill": "workspace:*",
"@deepseek-ai/dsh-tool-testkit": "workspace:*",
"@deepseek-ai/dsh-tools": "workspace:*",
"@deepseek-ai/dsh-working-directory": "workspace:*"
+3 -3
View File
@@ -1,5 +1,5 @@
/**
* Canonical `office` results and their model-facing content.
* Canonical Office tool results and their model-facing content.
* @module @deepseek-ai/dsh-tool-office/content
*/
@@ -37,8 +37,8 @@ export interface OfficeRenderValue {
}
/** Canonical result of `convert` and `recalculate`. */
export interface OfficeFileValue {
operation: 'convert' | 'recalculate'
export interface OfficeFileValue<Operation extends 'convert' | 'recalculate' = 'convert' | 'recalculate'> {
operation: Operation
/** Canonical absolute input path in the filesystem execution world. */
path: string
/** Absolute path of the temporary output file in the filesystem execution world. */
+49 -34
View File
@@ -1,9 +1,9 @@
/**
* Office document families, accepted operation formats, and argument rules of the `office` tool.
* Office document families, accepted formats, and input-dependent argument rules.
* @module @deepseek-ai/dsh-tool-office/formats
*/
/** Operation requested by one `office` call. */
/** Operation requested by one Office tool call. */
export type OfficeOperationName = 'render' | 'convert' | 'recalculate'
/** Document family selected by an input extension. */
@@ -23,23 +23,52 @@ export const CONVERSION_OUTPUTS: Readonly<Record<Exclude<OfficeFamily, 'pdf'>, r
presentation: ['pdf', 'pptx', 'odp'],
}
/** Recalculation outputs. */
export const RECALCULATION_OUTPUTS: readonly string[] = ['xlsx', 'ods']
/** Every conversion or recalculation output format. */
export const OUTPUT_FORMATS = ['pdf', 'docx', 'odt', 'txt', 'xlsx', 'ods', 'csv', 'pptx', 'odp'] as const
/** Validated arguments of one `office` call. */
export interface OfficeArgs {
operation: OfficeOperationName
/** Arguments for rendering document pages or worksheet areas. */
export interface OfficeRenderArgs {
input: string
format?: string
pages?: number[]
sheet?: string
range?: string
dpi?: number
}
/** Arguments for converting a document. */
export interface OfficeConvertArgs {
input: string
format: typeof OUTPUT_FORMATS[number]
sheet?: string
}
/** Arguments for recalculating a workbook. */
export interface OfficeRecalculateArgs {
input: string
format: 'xlsx' | 'ods'
}
/** Model-facing Office tool name. */
export type OfficeToolName = 'office_render' | 'office_convert' | 'office_recalculate'
/**
* Refuse argument keys the called tool does not declare, because the open parameter object would otherwise ignore
* them; a key that another Office tool declares names that tool.
* @param tool - called tool.
* @param args - call arguments.
* @param declared - parameter names of every Office tool.
* @throws Error naming the undeclared key and the Office tools that accept it.
*/
export function checkParameterNames(
tool: OfficeToolName, args: object, declared: Readonly<Record<OfficeToolName, readonly string[]>>,
): void {
for (const key of Object.keys(args)) {
if (declared[tool].includes(key)) continue
const owners = (Object.keys(declared) as OfficeToolName[]).filter(other => declared[other].includes(key))
throw new Error(owners.length === 0 ? `${tool} does not accept ${key}` : `${key} applies only to ${owners.join(' or ')}`)
}
}
/**
* Lowercase file extension of a path without its dot.
* @param path - resolved or model-supplied path.
@@ -73,24 +102,12 @@ export function inputFamily(operation: OfficeOperationName, path: string): Offic
}
/**
* Check the arguments that apply to the requested operation and input family.
* Check render selections that the tool schema subset cannot express.
* @param args - schema-validated call arguments.
* @param family - input family selected by {@link inputFamily}.
* @throws Error naming the misplaced or malformed argument.
*/
export function checkArguments(args: OfficeArgs, family: OfficeFamily): void {
const misplaced = (name: string, scope: string): Error => new Error(`${name} applies only to ${scope}`)
if (args.operation === 'render') {
if (args.format !== undefined) throw misplaced('format', 'convert and recalculate')
} else {
if (args.format === undefined) throw new Error(`${args.operation} requires format`)
if (args.pages !== undefined) throw misplaced('pages', 'render')
if (args.range !== undefined) throw misplaced('range', 'render')
if (args.dpi !== undefined) throw misplaced('dpi', 'render')
if (args.sheet !== undefined && (args.operation === 'recalculate' || args.format !== 'csv')) {
throw misplaced('sheet', 'render and CSV conversion')
}
}
export function checkRenderArguments(args: OfficeRenderArgs, family: OfficeFamily): void {
if (args.pages !== undefined) {
if (family === 'spreadsheet') throw new Error('pages does not apply to spreadsheets; select sheet and range instead')
if (args.pages.length === 0 || args.pages.some(page => !Number.isSafeInteger(page) || page < 1)
@@ -98,7 +115,7 @@ export function checkArguments(args: OfficeArgs, family: OfficeFamily): void {
throw new Error('pages must list distinct one-based page numbers')
}
}
if (args.operation === 'render' && family !== 'spreadsheet' && args.sheet !== undefined) throw misplaced('sheet', 'spreadsheets')
if (family !== 'spreadsheet' && args.sheet !== undefined) throw new Error('sheet applies only to spreadsheets')
if (args.range !== undefined && args.sheet === undefined) throw new Error('range requires sheet')
if (args.sheet !== undefined && args.sheet.trim() === '') throw new Error('sheet must be an exact worksheet name')
if (args.dpi !== undefined && (!Number.isSafeInteger(args.dpi) || args.dpi < 24 || args.dpi > 600)) {
@@ -107,18 +124,16 @@ export function checkArguments(args: OfficeArgs, family: OfficeFamily): void {
}
/**
* Check the output format of a conversion or recalculation.
* @param operation - `convert` or `recalculate`.
* Check conversion formats and worksheet selection against the input family.
* @param args - schema-validated conversion arguments.
* @param family - input family.
* @param input - input path named in the refusal.
* @param format - requested output format.
* @throws Error naming the formats available for this input.
*/
export function checkOutputFormat(
operation: Exclude<OfficeOperationName, 'render'>, family: Exclude<OfficeFamily, 'pdf'>, input: string, format: string,
): void {
const accepted = operation === 'recalculate' ? RECALCULATION_OUTPUTS : CONVERSION_OUTPUTS[family]
if (!accepted.includes(format)) {
throw new Error(`cannot ${operation} "${input}" to ${format}: this file ${operation === 'recalculate' ? 'recalculates' : 'converts'} to ${accepted.join(', ')}`)
export function checkConversionArguments(args: OfficeConvertArgs, family: Exclude<OfficeFamily, 'pdf'>): void {
const accepted = CONVERSION_OUTPUTS[family]
if (!accepted.includes(args.format)) {
throw new Error(`cannot convert "${args.input}" to ${args.format}: this file converts to ${accepted.join(', ')}`)
}
if (args.sheet !== undefined && args.format !== 'csv') throw new Error('sheet applies only to CSV conversion')
if (args.sheet !== undefined && args.sheet.trim() === '') throw new Error('sheet must be an exact worksheet name')
}
+195 -131
View File
@@ -1,25 +1,29 @@
/**
* The model-facing `office` tool: render document pages as images the model sees, convert documents between formats,
* and recalculate workbooks through the shared `officeKit` service. The tool stays registered while that service is
* absent, and each call then fails as `unavailable`. Reads use the filesystem backend's read authority; each call reads
* Model-facing Office tools render document pages, convert documents, and recalculate workbooks through the shared
* `officeKit` service. Tools are admitted after an Office skill loads; a missing service makes admitted calls fail
* as `unavailable`. Reads use the filesystem backend's read authority; each call reads
* one source byte before the service runs, so a cached result never answers a call that cannot read the source.
* Converted files stay in the Office kit's private output store; the model copies them into the workspace with the
* shell, so this tool writes no workspace file.
* shell, so these tools write no workspace file.
* @module @deepseek-ai/dsh-tool-office
*/
import { basename } from 'node:path'
import type { Context } from '@deepseek-ai/cordis'
import z from '@deepseek-ai/schemastery'
import type { Agent } from '@deepseek-ai/dsh-agent'
import type { ImageAttachmentRef } from '@deepseek-ai/dsh-attachment'
import type {} from '@deepseek-ai/dsh-attachment'
import type { FsInfo, FsTarget } from '@deepseek-ai/dsh-fs'
import type {} from '@deepseek-ai/dsh-llm'
import type {} from '@deepseek-ai/dsh-subagent'
import type {} from '@deepseek-ai/dsh-skill'
import { OfficeKitError, OfficeSourceKey, type OfficeKit, type OfficeKitSource } from '@deepseek-ai/dsh-office-kit'
import { defineTool, type GenericCallView, type ToolExecution } from '@deepseek-ai/dsh-tools'
import { defineTool, type ToolActivationContext, type ToolExecution } from '@deepseek-ai/dsh-tools'
import type {} from '@deepseek-ai/dsh-working-directory'
import { checkArguments, checkOutputFormat, extensionOf, inputFamily, OUTPUT_FORMATS, type OfficeArgs, type OfficeFamily } from './formats.ts'
import { checkParameterNames, checkRenderArguments, checkConversionArguments, extensionOf, inputFamily, OUTPUT_FORMATS,
type OfficeRenderArgs, type OfficeConvertArgs, type OfficeRecalculateArgs, type OfficeFamily, type OfficeOperationName,
type OfficeToolName } from './formats.ts'
import { renderFileContent, renderImagesContent, type OfficeFileValue, type OfficeRenderValue } from './content.ts'
export type { OfficeFileValue, OfficeRenderValue, OfficeRenderedImage } from './content.ts'
@@ -28,10 +32,12 @@ export type { OfficeFileValue, OfficeRenderValue, OfficeRenderedImage } from './
export const name = 'tool-office'
/** Required services; `officeKit` is read at each call, and `attachments` and `llm` are checked when rendering. */
export const inject = ['tools', 'fs', 'workingDirectory']
export const inject = ['tools', 'fs', 'workingDirectory', 'agents']
/** Bounds on one render result; deployment attachment limits apply when they are lower. */
/** Activation skills and render bounds; lower deployment attachment limits take precedence. */
export interface Config {
/** Skill names whose successful loading admits all three tools from the following step. */
activationSkills: string[]
/** Maximum images one render returns, including worksheet fragments. */
maxImages: number
/** Maximum pixels of each image. */
@@ -42,8 +48,10 @@ export interface Config {
maxImageBytes: number
}
/** Validated render bounds. */
/** Validated activation skills and render bounds. */
export const Config: z<Partial<Config>, Config> = z.object({
activationSkills: z.array(z.string().pattern(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)).min(1)
.default(['office', 'office-docx', 'office-xlsx', 'office-pptx']),
maxImages: z.natural().min(1).max(10_000).default(20),
maxImagePixels: z.natural().min(1).max(16_777_216).default(8_388_608),
maxImageDimension: z.natural().min(1).max(16_777_216).default(8192),
@@ -70,109 +78,168 @@ const IMAGE_SCHEMA = {
} as const
const MISSING_FONTS_SCHEMA = { type: 'array', required: true, items: { type: 'string' } } as const
const OFFICE_TOOL_NAMES: readonly string[] = ['office_render', 'office_convert', 'office_recalculate']
/**
* Register the `office` tool.
* @param ctx - registration scope; disposing it removes the tool.
* @param config - validated render bounds.
*/
export function apply(ctx: Context, config: Config): void {
ctx.tools.register(defineTool({
name: 'office',
description: 'Render document pages as images you can view, convert a document to another format, or recalculate spreadsheet formulas. '
+ 'Accepts Word (doc, docx, odt), Excel (xls, xlsx, ods), and PowerPoint (ppt, pptx, odp) files; render also accepts PDF.',
parameters: {
operation: {
type: 'string', required: true, enum: ['render', 'convert', 'recalculate'],
description: 'render returns page images; convert and recalculate return a temporary file to copy to its destination.',
},
input: { type: 'string', required: true, description: 'Path of the document to read; it is not modified.' },
format: {
type: 'string', enum: OUTPUT_FORMATS,
description: 'convert and recalculate: output format. Word converts to pdf, docx, odt, or txt; Excel to pdf, xlsx, ods, or csv; '
+ 'PowerPoint to pdf, pptx, or odp. recalculate writes xlsx or ods.',
},
pages: {
type: 'array', items: { type: 'integer' },
description: 'render: one-based pages or slides; omit for all. Spreadsheets use sheet and range instead.',
},
sheet: {
type: 'string',
description: 'Exact worksheet name. render: omit to render every visible sheet. convert: required for CSV from a workbook with several sheets.',
},
range: { type: 'string', description: 'render: A1 range in sheet, such as A1:H40; omit for the used area.' },
dpi: { type: 'integer', description: 'render: resolution from 24 to 600; default 144.' },
},
output: {
schema: {
oneOf: [
{
type: 'object', additionalProperties: false,
properties: {
operation: { type: 'string', const: 'render', required: true },
path: { type: 'string', required: true, description: 'Canonical absolute input path.' },
pageCount: { type: 'integer', required: true, description: 'Pages or slides of a document, or visible worksheets.' },
dpi: { type: 'integer', required: true },
images: { type: 'array', required: true, items: IMAGE_SCHEMA },
missingFonts: MISSING_FONTS_SCHEMA,
},
},
{
type: 'object', additionalProperties: false,
properties: {
operation: { type: 'string', enum: ['convert', 'recalculate'], required: true },
path: { type: 'string', required: true, description: 'Canonical absolute input path.' },
file: { type: 'string', required: true, description: 'Absolute path of the temporary output file.' },
format: { type: 'string', required: true },
bytes: { type: 'integer', required: true },
pageCount: { type: 'integer', description: 'Pages of a PDF output.' },
missingFonts: MISSING_FONTS_SCHEMA,
},
},
],
},
render: (_args, value) => value.operation === 'render' ? renderImagesContent(value) : renderFileContent(value),
presentationMeta: (_args, value) => value.operation === 'render' ? { path: value.path } : { path: value.path, file: value.file },
},
isConcurrencySafe: args => args.operation === 'render',
async execute(args: OfficeArgs, exec): Promise<OfficeRenderValue | OfficeFileValue> {
const family = inputFamily(args.operation, args.input)
checkArguments(args, family)
const resolveOptions = await sessionResolveOptions(ctx, exec)
const { target, info } = await readableInput(ctx, args.input, resolveOptions)
try {
await authorizeContent(ctx, target, info, exec.signal)
} catch (error) { throw officeFailure(args.operation, target.displayPath, error) }
const kit = ctx.get('officeKit')
if (kit === undefined) {
throw officeFailure(args.operation, target.displayPath, new OfficeKitError('unavailable', 'The document converter is unavailable.'))
}
const source = officeSource(ctx, exec, target, info)
if (args.operation === 'render') return render(ctx, kit, config, exec, args, target, source)
// `inputFamily` rejects PDF for convert and recalculate.
return convertFile(ctx, kit, exec, args, family as Exclude<OfficeFamily, 'pdf'>, target, source)
},
presentCall(args): GenericCallView {
const title = args.operation === 'render' ? `Render ${args.input}`
: args.operation === 'convert' ? `Convert ${args.input}${args.format === undefined ? '' : ` to ${args.format}`}`
: `Recalculate ${args.input}`
return {
card: 'generic', title, kind: args.operation === 'render' ? 'read' : 'other',
locations: [{ path: args.input }],
}
},
}))
const RENDER_PARAMETERS = {
input: { type: 'string', required: true, description: 'Path to doc, docx, odt, xls, xlsx, ods, ppt, pptx, odp, or pdf; not modified.' },
pages: {
type: 'array', items: { type: 'integer' },
description: 'Distinct one-based pages or slides; omit for all. Spreadsheets use sheet and range instead.',
},
sheet: {
type: 'string',
description: 'Exact worksheet name; omit to render every visible sheet.',
},
range: { type: 'string', description: 'A1 range, such as A1:H40; requires sheet. Omit for the used area.' },
dpi: { type: 'integer', description: 'Resolution from 24 to 600; default 144.' },
} as const
const CONVERT_PARAMETERS = {
input: { type: 'string', required: true, description: 'Path to doc, docx, odt, xls, xlsx, ods, ppt, pptx, or odp; not modified.' },
format: {
type: 'string', required: true, enum: OUTPUT_FORMATS,
description: 'Word: pdf, docx, odt, txt. Excel: pdf, xlsx, ods, csv. PowerPoint: pdf, pptx, odp.',
},
sheet: { type: 'string', description: 'Exact worksheet name for CSV only; required when the workbook has several sheets.' },
} as const
const RECALCULATE_PARAMETERS = {
input: { type: 'string', required: true, description: 'Path to an xls, xlsx, or ods workbook; not modified.' },
format: { type: 'string', required: true, enum: ['xlsx', 'ods'], description: 'Output workbook format.' },
} as const
const PARAMETER_NAMES: Readonly<Record<OfficeToolName, readonly string[]>> = {
office_render: Object.keys(RENDER_PARAMETERS),
office_convert: Object.keys(CONVERT_PARAMETERS),
office_recalculate: Object.keys(RECALCULATE_PARAMETERS),
}
/** Resolution options for the Session's current directory and the call's cancellation. */
async function sessionResolveOptions(ctx: Context, exec: ToolExecution): Promise<{ cwd?: string; signal: AbortSignal }> {
const cwd = exec.agent === undefined ? undefined : await ctx.workingDirectory.ensure(exec.agent, exec.signal)
return { ...cwd === undefined ? {} : { cwd }, signal: exec.signal }
const FILE_PROPERTIES = {
path: { type: 'string', required: true, description: 'Canonical absolute input path.' },
file: { type: 'string', required: true, description: 'Absolute path of the temporary output file.' },
format: { type: 'string', required: true },
bytes: { type: 'integer', required: true },
pageCount: { type: 'integer', description: 'Pages of a PDF output.' },
missingFonts: MISSING_FONTS_SCHEMA,
} as const
/**
* Register Office tools admitted after a successful skill load or an earlier Office declaration.
* @param ctx - registration scope; disposing it removes the tools.
* @param config - validated activation skills and render bounds.
*/
export function apply(ctx: Context, config: Config): void {
const skills = new Set(config.activationSkills)
const marked = new WeakSet<Agent>()
ctx.on('tools/result', (exec, result) => {
if (exec.agent === undefined || exec.name !== 'skill' || result.isError) return
const args = exec.arguments
if (typeof args === 'object' && args !== null && 'name' in args && typeof args.name === 'string' && skills.has(args.name)) {
marked.add(exec.agent)
}
})
ctx.on('session/event', (session, event) => {
if (event.type !== 'user/message' || event.data.source.kind !== 'skill-invocation' || !skills.has(event.data.source.name)) return
const agent = ctx.agents.get(session.id)
if (agent?.session === session) marked.add(agent)
})
ctx.on('agent/disposed', ({ agent }) => { marked.delete(agent) })
// Native request headers retain these declarations across resume and fork. PTC headers contain only run_code;
// after losing the in-memory mark, a PTC agent must load an Office skill again.
const when = ({ agent }: ToolActivationContext): boolean => marked.has(agent)
|| agent.session.requestHeader()?.tools?.some(tool => OFFICE_TOOL_NAMES.includes(tool.name)) === true
ctx.tools.register(defineTool({
name: 'office_render',
description: 'Render document pages, slides, or worksheet areas as images you can view.',
parameters: RENDER_PARAMETERS,
output: {
schema: {
type: 'object', additionalProperties: false,
properties: {
operation: { type: 'string', const: 'render', required: true },
path: { type: 'string', required: true, description: 'Canonical absolute input path.' },
pageCount: { type: 'integer', required: true, description: 'Pages or slides of a document, or visible worksheets.' },
dpi: { type: 'integer', required: true },
images: { type: 'array', required: true, items: IMAGE_SCHEMA },
missingFonts: MISSING_FONTS_SCHEMA,
},
},
render: (_args, value) => renderImagesContent(value),
presentationMeta: (_args, value) => ({ path: value.path }),
},
isConcurrencySafe: () => true,
async execute(args, exec): Promise<OfficeRenderValue> {
checkParameterNames('office_render', args, PARAMETER_NAMES)
checkRenderArguments(args, inputFamily('render', args.input))
const { agent, kit, target, source } = await prepareInput(ctx, exec, 'render', args.input)
return render(ctx, kit, config, agent, exec.signal, args, target, source)
},
presentCall: args => ({ card: 'generic', title: `Render ${args.input}`, kind: 'read', locations: [{ path: args.input }] }),
}), { when })
ctx.tools.register(defineTool({
name: 'office_convert',
description: 'Convert a document to another format. Return a temporary file to copy to its destination with the shell.',
parameters: CONVERT_PARAMETERS,
output: {
schema: { type: 'object', additionalProperties: false, properties: {
operation: { type: 'string', const: 'convert', required: true }, ...FILE_PROPERTIES,
} },
render: (_args, value) => renderFileContent(value),
presentationMeta: (_args, value) => ({ path: value.path, file: value.file }),
},
isConcurrencySafe: () => false,
async execute(args, exec): Promise<OfficeFileValue<'convert'>> {
checkParameterNames('office_convert', args, PARAMETER_NAMES)
// `inputFamily` rejects PDF for convert and recalculate.
const family = inputFamily('convert', args.input) as Exclude<OfficeFamily, 'pdf'>
const { agent, kit, target, source } = await prepareInput(ctx, exec, 'convert', args.input)
checkConversionArguments({ ...args, input: target.displayPath }, family)
return convertFile(ctx, kit, agent, exec.signal, 'convert', args, target, source)
},
presentCall: args => ({ card: 'generic', title: `Convert ${args.input} to ${args.format}`, kind: 'other', locations: [{ path: args.input }] }),
}), { when })
ctx.tools.register(defineTool({
name: 'office_recalculate',
description: 'Recalculate spreadsheet formulas. Return a temporary workbook to copy to its destination with the shell.',
parameters: RECALCULATE_PARAMETERS,
output: {
schema: { type: 'object', additionalProperties: false, properties: {
operation: { type: 'string', const: 'recalculate', required: true }, ...FILE_PROPERTIES,
} },
render: (_args, value) => renderFileContent(value),
presentationMeta: (_args, value) => ({ path: value.path, file: value.file }),
},
isConcurrencySafe: () => false,
async execute(args, exec): Promise<OfficeFileValue<'recalculate'>> {
checkParameterNames('office_recalculate', args, PARAMETER_NAMES)
inputFamily('recalculate', args.input)
const { agent, kit, target, source } = await prepareInput(ctx, exec, 'recalculate', args.input)
return convertFile(ctx, kit, agent, exec.signal, 'recalculate', args, target, source)
},
presentCall: args => ({ card: 'generic', title: `Recalculate ${args.input}`, kind: 'other', locations: [{ path: args.input }] }),
}), { when })
}
/** Authorize each read before a cache lookup and resolve the calling Agent and the current Office service. */
async function prepareInput(ctx: Context, exec: ToolExecution, operation: OfficeOperationName, input: string) {
const { agent, signal } = exec
// Conditional registrations execute only through a step tool set, which the calling Agent resolves.
if (agent === undefined) throw new Error(`cannot ${operation} "${input}": Office tools run only in an Agent step`)
const cwd = await ctx.workingDirectory.ensure(agent, signal)
const { target, info } = await readableInput(ctx, input, { cwd, signal })
try {
await authorizeContent(ctx, target, info, signal)
} catch (error) { throw officeFailure(operation, target.displayPath, error) }
const kit = ctx.get('officeKit')
if (kit === undefined) {
throw officeFailure(operation, target.displayPath, new OfficeKitError('unavailable', 'The document converter is unavailable.'))
}
return { agent, kit, target, source: officeSource(ctx, agent, target, info) }
}
/** Resolve an input through the filesystem backend and require a regular file. */
async function readableInput(
ctx: Context, path: string, options: { cwd?: string; signal: AbortSignal },
ctx: Context, path: string, options: { cwd: string; signal: AbortSignal },
): Promise<{ target: FsTarget; info: FsInfo }> {
const target = await ctx.fs.resolve(path, options)
const info = await ctx.fs.stat(target, options.signal)
@@ -197,9 +264,9 @@ async function authorizeContent(ctx: Context, target: FsTarget, info: FsInfo, si
}
/** A deferred bounded read that refuses a source changed since its authorizing stat. */
function officeSource(ctx: Context, exec: ToolExecution, target: FsTarget, info: FsInfo): OfficeKitSource {
function officeSource(ctx: Context, agent: Agent, target: FsTarget, info: FsInfo): OfficeKitSource {
return {
key: OfficeSourceKey(JSON.stringify([exec.agent?.session.id ?? null, ctx.fs.processPath(target)])),
key: OfficeSourceKey(JSON.stringify([agent.session.id, ctx.fs.processPath(target)])),
version: info.version,
...info.size === undefined ? {} : { bytes: info.size },
async read(signal, maxBytes) {
@@ -231,25 +298,26 @@ function officeFailure(verb: string, path: string, error: unknown): unknown {
* Require the calling model route to declare image input. The route is the Session's latest request header
* configuration, falling back to the agent options; a model whose capability is unknown is refused.
*/
async function assertRenderRoute(ctx: Context, exec: ToolExecution, displayPath: string): Promise<void> {
async function assertRenderRoute(ctx: Context, agent: Agent, signal: AbortSignal, displayPath: string): Promise<void> {
const llm = ctx.get('llm')
const header = exec.agent?.session.requestHeader()?.config
const model = header?.model ?? exec.agent?.options.model
const provider = header?.provider ?? exec.agent?.options.provider
const header = agent.session.requestHeader()?.config
const model = header?.model ?? agent.options.model
const provider = header?.provider ?? agent.options.provider
if (llm === undefined || provider === undefined || model === undefined) {
throw new Error(`cannot render "${displayPath}": the current model route could not be resolved`)
}
const { inputModalities = [] } = await llm.resolveModelInfo(provider, model, exec.signal)
const { inputModalities = [] } = await llm.resolveModelInfo(provider, model, signal)
if (!inputModalities.includes('image')) throw new Error(`cannot render "${displayPath}": model "${model}" does not accept images`)
}
async function render(
ctx: Context, kit: OfficeKit, config: Config, exec: ToolExecution, args: OfficeArgs, target: FsTarget, source: OfficeKitSource,
ctx: Context, kit: OfficeKit, config: Config, agent: Agent, signal: AbortSignal, args: OfficeRenderArgs, target: FsTarget,
source: OfficeKitSource,
): Promise<OfficeRenderValue> {
const path = ctx.fs.processPath(target)
const attachments = ctx.get('attachments')
if (attachments === undefined) throw new Error(`cannot render "${target.displayPath}": no attachment service is mounted`)
await assertRenderRoute(ctx, exec, target.displayPath)
await assertRenderRoute(ctx, agent, signal, target.displayPath)
const limits = attachments.imageLimits
let result
try {
@@ -265,7 +333,7 @@ async function render(
maxPixels: Math.min(config.maxImagePixels, limits.maxImagePixels),
maxDimension: Math.min(config.maxImageDimension, limits.maxImageDimension),
maxBytes: Math.min(config.maxImageBytes, limits.maxMessageImageBytes),
}, exec.signal)
}, signal)
} catch (error) { throw officeFailure('render', target.displayPath, error) }
const oversized = result.images.find(image => image.png.byteLength > limits.maxImageBytes)
if (oversized !== undefined) {
@@ -301,40 +369,36 @@ async function render(
* Output-store owner for a conversion: the root Session of the caller's subagent tree, so a subagent's output stays
* until the conversation that delegated it ends. Without the `subagents` service every Agent is its own root.
*/
function outputOwner(ctx: Context, exec: ToolExecution): string {
if (exec.agent === undefined) return 'agentless'
return (ctx.get('subagents')?.rootOf(exec.agent) ?? exec.agent).session.id
function outputOwner(ctx: Context, agent: Agent): string {
return (ctx.get('subagents')?.rootOf(agent) ?? agent).session.id
}
async function convertFile(
ctx: Context, kit: OfficeKit, exec: ToolExecution, args: OfficeArgs, family: Exclude<OfficeFamily, 'pdf'>,
async function convertFile<Operation extends 'convert' | 'recalculate'>(
ctx: Context, kit: OfficeKit, agent: Agent, signal: AbortSignal, operation: Operation, args: OfficeConvertArgs | OfficeRecalculateArgs,
target: FsTarget, source: OfficeKitSource,
): Promise<OfficeFileValue> {
const operation = args.operation as 'convert' | 'recalculate'
// `checkArguments` requires format for convert and recalculate.
const format = args.format as string
checkOutputFormat(operation, family, target.displayPath, format)
): Promise<OfficeFileValue<Operation>> {
const { format } = args
if (ctx.fs.processPathFromHostPath(kit.outputDirectory) === undefined) {
throw new Error(`cannot ${operation} "${target.displayPath}": converted files are not available when the workspace is on a remote host`)
}
const extension = extensionOf(args.input)
const stem = basename(target.displayPath).replace(/\.[^.]*$/u, '')
const output = { owner: outputOwner(ctx, exec), name: `${stem}.${format}` }
const output = { owner: outputOwner(ctx, agent), name: `${stem}.${format}` }
let result
try {
result = operation === 'convert'
? await kit.convertTo({
// `inputFamily` and `checkOutputFormat` admitted both extensions.
// `inputFamily` and `checkConversionArguments` admitted both extensions.
extension: extension as Parameters<OfficeKit['convertTo']>[0]['extension'],
format: format as Parameters<OfficeKit['convertTo']>[0]['format'],
...args.sheet === undefined ? {} : { sheet: args.sheet },
format,
...'sheet' in args ? { sheet: args.sheet } : {},
priority: 'foreground', source, output,
}, exec.signal)
}, signal)
: await kit.recalculate({
extension: extension as Parameters<OfficeKit['recalculate']>[0]['extension'],
format: format as Parameters<OfficeKit['recalculate']>[0]['format'],
priority: 'foreground', source, output,
}, exec.signal)
}, signal)
} catch (error) { throw officeFailure(operation, target.displayPath, error) }
return {
operation, path: ctx.fs.processPath(target),
@@ -0,0 +1,257 @@
/** Skill activation and request-header retention through real AgentLoop and Session lifecycles. */
import { Context } from '@deepseek-ai/cordis'
import { randomUUID } from 'node:crypto'
import { mkdtemp, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { describe, expect, it, onTestFinished, vi } from 'vitest'
import type { Agent } from '@deepseek-ai/dsh-agent'
import { mountAgentLoopTestDependencies, mountAgentLoopTestHarness } from '@deepseek-ai/dsh-agent-loop-testkit'
import { createUserMessage, LlmAdapter, ToolCallId, type GenerateOptions, type StreamChunk } from '@deepseek-ai/dsh-llm'
import { PtcRuntime, type PtcRunRequest, type PtcRunResult, type PtcRunSpec } from '@deepseek-ai/dsh-ptc-runtime'
import { SessionId, SessionLogOffset } from '@deepseek-ai/dsh-session'
import * as JsonlPersistence from '@deepseek-ai/dsh-session-persistence-jsonl'
import SkillRegistry from '@deepseek-ai/dsh-skill'
import * as ToolSkill from '@deepseek-ai/dsh-tool-skill'
import { executeToolFixture } from '@deepseek-ai/dsh-tool-testkit'
import * as ToolOffice from '../src/index.ts'
const NAMES = ['office_convert', 'office_recalculate', 'office_render']
const SKILLS = ['office', 'office-docx', 'office-xlsx', 'office-pptx']
const signal = new AbortController().signal
function response(name?: string, args: object = {}): StreamChunk[] {
if (name === undefined) return [
{ type: 'block-start', index: 0, blockType: 'text' },
{ type: 'text-delta', index: 0, text: 'Done' },
{ type: 'block-end', index: 0, block: { type: 'text', text: 'Done' } },
{ type: 'finish', reason: { kind: 'stop' } },
]
const block = { type: 'tool-call' as const, id: ToolCallId('load'), name, arguments: JSON.stringify(args) }
return [
{ type: 'block-start', index: 0, blockType: 'tool-call' },
{ type: 'tool-call-delta', index: 0, id: block.id, name, argumentsDelta: block.arguments },
{ type: 'block-end', index: 0, block },
{ type: 'finish', reason: { kind: 'tool-calls' } },
]
}
class ScriptedAdapter extends LlmAdapter {
readonly requests: GenerateOptions[] = []
constructor(private readonly script: StreamChunk[][]) { super() }
override async * stream(options: GenerateOptions): AsyncIterable<StreamChunk> {
this.requests.push(options)
const next = this.script.shift()
if (next === undefined) throw new Error('Office test script exhausted')
yield* next
}
}
class SkillRuntime extends PtcRuntime {
readonly language = 'typescript'
readonly isolation = 'fixture'
skill = 'office'
resolve(request: PtcRunRequest): PtcRunSpec {
return { ...request, cwd: request.cwd ?? process.cwd(), timeoutMs: request.timeoutMs ?? 120_000 }
}
async run(request: PtcRunRequest): Promise<PtcRunResult> {
return { logs: [], value: await request.bindings[0]!.functions.skill!({ name: this.skill }) }
}
}
async function harness(script: StreamChunk[][] = [], options: {
ptc?: boolean
root?: string
skills?: string[]
officeFirst?: boolean
} = {}) {
const ctx = new Context()
const cwd = await mkdtemp(join(tmpdir(), 'office-activation-'))
onTestFinished(async () => { await ctx.fiber.dispose(); await rm(cwd, { recursive: true, force: true }) })
await mountAgentLoopTestDependencies(ctx, { workingDirectory: true, tools: { mode: options.ptc ? 'ptc' : 'native' } })
if (options.ptc) await ctx.plugin(SkillRuntime)
if (options.root !== undefined) await ctx.plugin(JsonlPersistence, { root: options.root, compression: 'none' })
const loop = await mountAgentLoopTestHarness(ctx)
await ctx.plugin(SkillRegistry)
for (const name of [...SKILLS, 'other', 'custom-office']) ctx.skills.register({ name, source: 'runtime', description: name, content: `${name} instructions` })
if (!options.officeFirst) await ctx.plugin(ToolSkill)
const fiber = await ctx.plugin(ToolOffice, options.skills === undefined ? {} : { activationSkills: options.skills })
if (options.officeFirst) await ctx.plugin(ToolSkill)
const adapter = new ScriptedAdapter(script)
ctx.llm.registerAdapter(['fixture'], adapter)
const agent = await loop.create(SessionId(`office-${randomUUID()}`), { provider: 'fixture', model: 'fixture' }, { cwd })
return { ctx, agent, adapter, fiber }
}
async function turn(agent: Agent, text = 'Continue'): Promise<void> {
agent.followup(createUserMessage({ content: [{ type: 'text', text }], source: { kind: 'user' } }))
await agent.whenIdle()
}
function names(request: GenerateOptions | undefined): string[] {
return request?.tools?.map(tool => tool.name).filter(name => NAMES.includes(name)) ?? []
}
async function admitted(ctx: Context, agent: Agent): Promise<string[]> {
const toolSet = await ctx.tools.resolve({ agent, modelSelection: { provider: 'fixture', model: 'fixture' }, signal })
try { return ctx.tools.schemas(agent, toolSet).map(tool => tool.name).filter(name => NAMES.includes(name)).sort() }
finally { toolSet.dispose() }
}
describe('Office skill admission', () => {
it.each(SKILLS)('admits all tools on the step after the model loads %s', async (name) => {
const { agent, adapter } = await harness([response('skill', { name }), response()])
await turn(agent)
expect(adapter.requests).toHaveLength(2)
expect(names(adapter.requests[0])).toEqual([])
expect(names(adapter.requests[1])).toEqual(NAMES)
})
it('observes successful nested PTC results and admits the next step bindings', async () => {
const { ctx, agent, adapter } = await harness([
response('run_code', { code: 'return tools.skill({name: "office"})', description: 'Load Office' }), response(),
], { ptc: true })
const nested: boolean[] = []
ctx.on('tools/result', (exec, result) => { if (exec.name === 'skill') nested.push(exec.parent !== undefined && !result.isError) })
await turn(agent)
expect(nested).toEqual([true])
expect(adapter.requests).toHaveLength(2)
expect(adapter.requests[0]?.messages.some(message => JSON.stringify(message.content).includes('office_render'))).toBe(false)
expect(adapter.requests[1]?.messages.some(message => JSON.stringify(message.content).includes('office_render'))).toBe(true)
expect(agent.session.requestHeader()?.tools?.map(tool => tool.name)).toEqual(['run_code'])
})
it.each([false, true])('ignores failed Office loads and other skills (PTC=%s)', async (ptc) => {
for (const name of ['office', 'other']) {
const { ctx, agent } = await harness([
ptc ? response('run_code', { code: 'return tools.skill({name: "fixture"})', description: 'Load skill' }) : response('skill', { name }), response(),
], { ptc })
if (ptc) (ctx.ptcRuntime as SkillRuntime).skill = name
if (name === 'office') vi.spyOn(ctx.skills, 'get').mockRejectedValueOnce(new Error('Skill file is unreadable'))
const errors: boolean[] = []
ctx.on('tools/result', (exec, result) => { if (exec.name === 'skill') errors.push(result.isError) })
await turn(agent)
expect(errors).toEqual([name === 'office'])
expect(await admitted(ctx, agent)).toEqual([])
}
})
it.each([false, true])('marks committed user skill injections independently of plugin order (officeFirst=%s)', async (officeFirst) => {
const { agent, adapter } = await harness([response('skill', { name: 'office' }), response()], { officeFirst })
await turn(agent, '/office-docx')
expect(names(adapter.requests[0])).toEqual([])
expect(names(adapter.requests[1])).toEqual(NAMES)
expect(agent.session.snapshotEvents().some(event => event.type === 'user/message' && event.data.source.kind === 'skill-invocation')).toBe(true)
})
it('activates on direct invocation without requiring a model skill call', async () => {
const { ctx, agent, adapter } = await harness([response(), response()])
await turn(agent, '/office')
expect(names(adapter.requests[0])).toEqual([])
expect(await admitted(ctx, agent)).toEqual(NAMES)
await turn(agent, '/other')
expect(names(adapter.requests[1])).toEqual(NAMES)
})
it('ignores a skill invocation on a Session that the registered Agent no longer owns', async () => {
const { ctx, agent } = await harness()
const other = (await ctx.agents.create({ sessionId: SessionId(`office-other-${randomUUID()}`) })).agent
const get = vi.spyOn(ctx.agents, 'get').mockReturnValue(other)
agent.session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'office instructions' }], source: { kind: 'skill-invocation', name: 'office', form: 'instructions' },
}), { surfaceOp: 'append' })
expect(get).toHaveBeenCalledWith(agent.session.id)
get.mockRestore()
expect(await admitted(ctx, agent)).toEqual([])
expect(await admitted(ctx, other)).toEqual([])
})
it('does not activate for user invocation of a non-Office skill', async () => {
const { ctx, agent } = await harness([response()])
await turn(agent, '/other')
expect(await admitted(ctx, agent)).toEqual([])
})
it('returns UNKNOWN_TOOL before activation or without a step admission set', async () => {
const { ctx, agent } = await harness()
const toolSet = await ctx.tools.resolve({ agent, modelSelection: { provider: 'fixture', model: 'fixture' }, signal })
onTestFinished(() => { toolSet.dispose() })
for (const name of NAMES) {
for (const admission of [undefined, toolSet]) {
const result = await executeToolFixture(ctx, { name, arguments: { input: 'a.xlsx', format: 'xlsx' }, agent,
callId: ToolCallId(name), signal, ...admission === undefined ? {} : { toolSet: admission } })
expect(result).toMatchObject({ isError: true, error: { info: { code: 'UNKNOWN_TOOL' } } })
}
}
})
it.each(NAMES)('retains the whole group when the request header contains only %s', async (name) => {
const { ctx, agent } = await harness()
agent.session.append('request/header', { reason: 'initial', header: {
config: { provider: 'fixture', model: 'fixture' }, tools: ctx.tools.schemas().filter(tool => tool.name === name),
} })
expect(await admitted(ctx, agent)).toEqual(NAMES)
})
it('validates the configured skill set and activates only its names', async () => {
for (const activationSkills of [[], [''], ['Office'], ['has space'], [1]]) expect(() => ToolOffice.Config({ activationSkills } as never)).toThrow()
const { ctx, agent } = await harness([response(), response()], { skills: ['custom-office'] })
await turn(agent, '/office')
expect(await admitted(ctx, agent)).toEqual([])
await turn(agent, '/custom-office')
expect(await admitted(ctx, agent)).toEqual(NAMES)
})
it.each([false, true])('uses only recorded native declarations after persisted resume and fork (PTC=%s)', async (ptc) => {
const root = await mkdtemp(join(tmpdir(), 'office-resume-'))
onTestFinished(() => rm(root, { recursive: true, force: true }))
const first = await harness([response(), response()], { root, ptc })
await turn(first.agent, '/office')
await turn(first.agent)
const sessionId = first.agent.session.id
const seed = first.agent.session.snapshotEvents()
expect(await admitted(first.ctx, first.agent)).toEqual(NAMES)
await first.ctx.fiber.dispose()
const next = await harness([response(), response()], { root, ptc })
const resumed = (await next.ctx.agents.resume({ resumeSessionId: sessionId })).agent
expect(await admitted(next.ctx, resumed)).toEqual(ptc ? [] : NAMES)
await turn(resumed)
const forked = await next.ctx.agents.create({ sessionId: SessionId('office-fork'), seed,
inheritedEventCount: SessionLogOffset(seed.length), meta: { isSeeded: true, parentSession: sessionId } })
expect(forked.agent.session.requestHeader()?.tools).toEqual(first.agent.session.requestHeader()?.tools)
expect(await admitted(next.ctx, forked.agent)).toEqual(ptc ? [] : NAMES)
await turn(forked.agent)
expect(next.adapter.requests.map(names)).toEqual(ptc ? [[], []] : [NAMES, NAMES])
})
it('keeps the header after replacing conversation history with a summary', async () => {
const { ctx, agent } = await harness([response(), response()])
await turn(agent, '/office')
await turn(agent)
const header = agent.session.requestHeader()
const users = agent.session.snapshotEvents().filter(event => event.type === 'user/message')
const start = users[0]!
agent.session.append('user/message', createUserMessage({ content: [{ type: 'text', text: 'Summary' }], source: { kind: 'user' } }), {
surfaceOp: { op: 'replace', startSeq: start.seq, endSeq: start.seq },
sourceEventSeqs: [start.seq],
})
ctx.emit('agent/disposed', { agent })
expect(agent.session.requestHeader()).toBe(header)
expect(await admitted(ctx, agent)).toEqual(NAMES)
})
it('clears transient marks on disposal and can reload after losing a pre-header mark', async () => {
const { ctx, agent, fiber } = await harness([response()])
await turn(agent, '/office')
expect(await admitted(ctx, agent)).toEqual(NAMES)
ctx.emit('agent/disposed', { agent })
expect(await admitted(ctx, agent)).toEqual([])
await executeToolFixture(ctx, { name: 'skill', arguments: { name: 'office' }, agent, callId: ToolCallId('reload'), signal })
expect(await admitted(ctx, agent)).toEqual(NAMES)
await fiber.dispose()
expect(await admitted(ctx, agent)).toEqual([])
await ctx.plugin(ToolOffice)
expect(await admitted(ctx, agent)).toEqual([])
})
})
@@ -1,5 +1,5 @@
/**
* The `office` tool over the real local filesystem, attachment store, and tool pipeline, with a
* The Office tools over the real local filesystem, attachment store, and tool pipeline, with a
* controlled Office service: model-visible content, canonical values, argument rules, output-path refusals, render
* bounds, read authority, Office service failures, cancellation, PTC dispatch, and disposal.
*/
@@ -12,11 +12,12 @@ import { access, mkdir, mkdtemp, readFile, realpath, rm, writeFile } from 'node:
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { Context } from '@deepseek-ai/cordis'
import AgentRegistry from '@deepseek-ai/dsh-agent'
import { PtcRuntime, type PtcRunRequest, type PtcRunResult, type PtcRunSpec } from '@deepseek-ai/dsh-ptc-runtime'
import { LlmAdapter, LlmRuntime, ToolCallId } from '@deepseek-ai/dsh-llm'
import type { GenerateOptions, LlmModelInfo, LlmResolvedModelInfo, StreamChunk } from '@deepseek-ai/dsh-llm'
import SystemPrompt from '@deepseek-ai/dsh-system-prompt'
import ToolRuntime, { RUN_CODE_NAME } from '@deepseek-ai/dsh-tools'
import ToolRuntime, { RUN_CODE_NAME, defineTool } from '@deepseek-ai/dsh-tools'
import LocalFileSystem from '@deepseek-ai/dsh-fs-local'
import LocalAttachmentStore from '@deepseek-ai/dsh-attachment-local'
import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
@@ -84,8 +85,12 @@ function fakeOfficeKit() {
return { images: [{ png: PNG, width: 1, height: 1, page: 2 }], pageCount: 3, dpi: request.dpi ?? 144, missingFonts: [], generation }
}),
outputDirectory: join(home, 'outputs'),
convertTo: vi.fn(async (request: { source: OfficeKitSource; output: { name: string } }) => fileResult(request)),
recalculate: vi.fn(async (request: { source: OfficeKitSource; output: { name: string } }) => fileResult(request)),
convertTo: vi.fn(async (
request: { source: OfficeKitSource; output: { name: string } }, _signal?: AbortSignal,
) => fileResult(request)),
recalculate: vi.fn(async (
request: { source: OfficeKitSource; output: { name: string } }, _signal?: AbortSignal,
) => fileResult(request)),
}
}
@@ -96,6 +101,7 @@ beforeEach(async () => {
home = await mkdtemp(join(tmpdir(), 'dsh-tool-office-home-'))
await writeFile(join(dir, 'deck.pptx'), 'pptx bytes')
await writeFile(join(dir, 'book.xlsx'), 'xlsx bytes')
await writeFile(join(dir, 'report.docx'), 'docx bytes')
})
afterEach(async () => {
await rm(dir, { recursive: true, force: true })
@@ -113,6 +119,7 @@ async function setup(options: SetupOptions = {}) {
await ctx.plugin(options.ptc === true ? PtcToolExecutor : NativeToolExecutor)
if (options.ptc === true) await ctx.plugin(FakeRuntime)
await ctx.plugin(SessionProjectionRegistry)
await ctx.plugin(AgentRegistry)
await ctx.plugin(LocalFileSystem, { cwd: dir })
if (options.attachments !== false) await ctx.plugin(LocalAttachmentStore, { dshHome: home })
if (options.llm !== false) {
@@ -126,7 +133,7 @@ async function setup(options: SetupOptions = {}) {
}
let sessions = 0
function agentOn(model: string | undefined, options: { provider?: string; model?: string } = {}): object {
function agentOn(model: string | undefined, options: { provider?: string; model?: string } = {}) {
const id = SessionId(`office-session-${++sessions}`)
const session = Session.create(id, [], { version: SESSION_FORMAT_VERSION, id, createdAt: 0, cwd: dir, isSeeded: false })
vi.spyOn(session, 'requestHeader').mockReturnValue(model === undefined ? undefined : { config: { provider: 'visual', model } })
@@ -134,11 +141,28 @@ function agentOn(model: string | undefined, options: { provider?: string; model?
}
let calls = 0
function office(ctx: Context, args: Record<string, unknown>, agent: object | null = agentOn('vision'), callSignal = signal) {
return executeToolFixture(ctx, {
signal: callSignal, callId: ToolCallId(`office-${++calls}`), name: 'office', arguments: args,
...agent === null ? {} : { agent: agent as never },
})
async function loadOffice(ctx: Context, agent: object): Promise<void> {
const dispose = ctx.tools.register(defineTool({
name: 'skill', description: 'Fixture skill', parameters: { name: { type: 'string', required: true } },
output: { schema: { type: 'string' }, render: (_args, value) => [{ type: 'text', text: value }] },
execute: async () => 'Office instructions',
}))
try {
await executeToolFixture(ctx, { signal, name: 'skill', callId: ToolCallId(`skill-${++calls}`), arguments: { name: 'office' }, agent: agent as never })
} finally { dispose() }
}
async function office(ctx: Context, args: Record<string, unknown>, agent: object | null = agentOn('vision'), callSignal = signal) {
const { operation, ...parameters } = args
if (agent !== null) await loadOffice(ctx, agent)
const toolSet = agent === null ? undefined : await ctx.tools.resolve({ agent: agent as never,
modelSelection: { provider: 'visual', model: 'vision' }, signal: callSignal })
try {
return await executeToolFixture(ctx, {
signal: callSignal, callId: ToolCallId(`office-${++calls}`), name: `office_${String(operation)}`, arguments: parameters,
...agent === null ? {} : { agent: agent as never }, ...toolSet === undefined ? {} : { toolSet },
})
} finally { toolSet?.dispose() }
}
function text(result: { content: readonly { type: string; text?: string }[] }): string {
@@ -148,31 +172,55 @@ function text(result: { content: readonly { type: string; text?: string }[] }):
describe('office schema', () => {
it('declares the model-facing description and parameters', async () => {
const { ctx } = await setup()
const schema = ctx.tools.schemas().find(tool => tool.name === 'office')
expect(schema?.description).toBe('Render document pages as images you can view, convert a document to another format, or recalculate spreadsheet formulas. '
+ 'Accepts Word (doc, docx, odt), Excel (xls, xlsx, ods), and PowerPoint (ppt, pptx, odp) files; render also accepts PDF.')
expect(Object.keys(schema?.parameters.properties ?? {})).toEqual(['operation', 'input', 'format', 'pages', 'sheet', 'range', 'dpi'])
expect(schema?.parameters.required).toEqual(['operation', 'input'])
const schemas = ctx.tools.schemas()
expect(schemas.map(schema => schema.name)).toEqual(['office_render', 'office_convert', 'office_recalculate'])
expect(schemas.map(schema => Object.keys(schema.parameters.properties ?? {}))).toEqual([
['input', 'pages', 'sheet', 'range', 'dpi'], ['input', 'format', 'sheet'], ['input', 'format'],
])
expect(schemas.map(schema => schema.parameters.required)).toEqual([['input'], ['input', 'format'], ['input', 'format']])
expect(schemas[0]?.description).toBe('Render document pages, slides, or worksheet areas as images you can view.')
expect(schemas[1]?.parameters).toMatchObject({ properties: { format: { enum: ['pdf', 'docx', 'odt', 'txt', 'xlsx', 'ods', 'csv', 'pptx', 'odp'] } } })
expect(schemas[2]?.parameters).toMatchObject({ properties: { format: { enum: ['xlsx', 'ods'] } } })
for (const definition of ctx.tools.definitions()) {
expect(definition.output.schema).toMatchObject({ type: 'object', properties: { operation: { const: definition.name.replace('office_', '') } } })
expect(definition.output.schema).not.toHaveProperty('oneOf')
}
})
it('removes the tool when its plugin fiber is disposed', async () => {
const { ctx, fiber } = await setup()
expect(ctx.tools.get('office')).toBeDefined()
expect(ctx.tools.definitions()).toHaveLength(3)
await fiber.dispose()
expect(ctx.tools.get('office')).toBeUndefined()
expect(ctx.tools.definitions()).toHaveLength(0)
})
it.each([
['office_render', { input: 'deck.pptx' }],
['office_convert', { input: 'book.xlsx', format: 'csv' }],
['office_recalculate', { input: 'book.xlsx', format: 'xlsx' }],
])('refuses a direct %s body call without an Agent', async (name, args) => {
const { ctx, kit } = await setup()
const definition = ctx.tools.get(name)!
const call = { signal, callId: ToolCallId(`agentless-${name}`), name, arguments: args, deferContext: vi.fn(), concludeTurn: vi.fn() }
await expect(definition.execute(args as never, call as never)).rejects.toThrow('Office tools run only in an Agent step')
expect(kit.renderImages).not.toHaveBeenCalled()
expect(kit.convertTo).not.toHaveBeenCalled()
expect(kit.recalculate).not.toHaveBeenCalled()
})
it('presents pending calls with their files', async () => {
const { ctx } = await setup()
const tool = ctx.tools.get('office')!
expect(tool.presentCall?.({ operation: 'render', input: 'deck.pptx' }))
const render = ctx.tools.get('office_render')!
const convert = ctx.tools.get('office_convert')!
const recalculate = ctx.tools.get('office_recalculate')!
expect(render.presentCall?.({ input: 'deck.pptx' }))
.toEqual({ card: 'generic', title: 'Render deck.pptx', kind: 'read', locations: [{ path: 'deck.pptx' }] })
expect(tool.presentCall?.({ operation: 'convert', input: 'deck.pptx', format: 'pdf' }))
expect(convert.presentCall?.({ input: 'deck.pptx', format: 'pdf' }))
.toEqual({ card: 'generic', title: 'Convert deck.pptx to pdf', kind: 'other', locations: [{ path: 'deck.pptx' }] })
expect(tool.presentCall?.({ operation: 'convert', input: 'deck.pptx' })).toMatchObject({ title: 'Convert deck.pptx' })
expect(tool.presentCall?.({ operation: 'recalculate', input: 'book.xlsx', format: 'xlsx' })).toMatchObject({ title: 'Recalculate book.xlsx' })
expect(tool.isConcurrencySafe?.({ operation: 'render', input: 'deck.pptx' })).toBe(true)
expect(tool.isConcurrencySafe?.({ operation: 'convert', input: 'deck.pptx', format: 'pdf' })).toBe(false)
expect(recalculate.presentCall?.({ input: 'book.xlsx', format: 'xlsx' })).toMatchObject({ title: 'Recalculate book.xlsx' })
expect(render.isConcurrencySafe?.({ input: 'deck.pptx' })).toBe(true)
expect(convert.isConcurrencySafe?.({ input: 'deck.pptx', format: 'pdf' })).toBe(false)
expect(recalculate.isConcurrencySafe?.({ input: 'book.xlsx', format: 'xlsx' })).toBe(false)
})
})
@@ -237,12 +285,11 @@ describe('render', () => {
})
it.each([
['no agent', null],
['an agent route without a provider', { model: 'vision' }],
['an agent route without a model', { provider: 'visual' }],
] as const)('refuses %s as an unresolved route', async (_label, route) => {
const { ctx, kit } = await setup()
const result = await office(ctx, { operation: 'render', input: 'deck.pptx' }, route === null ? null : agentOn(undefined, route))
const result = await office(ctx, { operation: 'render', input: 'deck.pptx' }, agentOn(undefined, route))
expect(text(result)).toBe(`Error: cannot render "${join(dir, 'deck.pptx')}": the current model route could not be resolved`)
expect(kit.renderImages).not.toHaveBeenCalled()
})
@@ -266,7 +313,7 @@ describe('render', () => {
it('projects written files and their presentation metadata', async () => {
const { ctx } = await setup()
const output = ctx.tools.get('office')!.output
const output = ctx.tools.get('office_recalculate')!.output
const value = { operation: 'recalculate', path: '/w/book.xlsx', file: '/h/out/book.xlsx', format: 'xlsx', bytes: 9, missingFonts: ['Aptos'] }
expect(output.render({}, value)).toEqual([{ type: 'text', text: 'Recalculated /w/book.xlsx to xlsx (9 bytes): /h/out/book.xlsx\n'
+ 'Copy this temporary file to its destination with the shell now; it is deleted when this conversation ends.\nFonts not installed and substituted: Aptos.' }])
@@ -310,7 +357,7 @@ describe('Office service failures', () => {
it('stays registered without the Office service, fails each call as unavailable, and uses the service once it is provided', async () => {
const { ctx, kit } = await setup({ kit: false })
expect(ctx.tools.schemas().map(tool => tool.name)).toContain('office')
expect(ctx.tools.schemas().map(tool => tool.name)).toEqual(['office_render', 'office_convert', 'office_recalculate'])
for (const [args, verb] of [
[{ operation: 'render', input: 'deck.pptx' }, 'render'],
[{ operation: 'convert', input: 'deck.pptx', format: 'pdf' }, 'convert'],
@@ -385,33 +432,48 @@ describe('Office service failures', () => {
expect(text(await office(ctx, { operation: 'render', input: 'deck.pptx' }))).toContain('read failure')
})
it('forwards cancellation to the Office service', async () => {
it.each([
['render', 'renderImages', 'deck.pptx'], ['convert', 'convertTo', 'deck.pptx'], ['recalculate', 'recalculate', 'book.xlsx'],
] as const)('forwards %s cancellation to the Office service', async (operation, method, input) => {
const { ctx, kit } = await setup()
const controller = new AbortController()
kit.renderImages.mockImplementationOnce(async (_request, callSignal?: AbortSignal) => {
kit[method].mockImplementationOnce(async (_request, callSignal?: AbortSignal) => {
controller.abort(new Error('caller cancelled'))
callSignal?.throwIfAborted()
throw new Error('unreachable')
})
const result = await office(ctx, { operation: 'render', input: 'deck.pptx' }, agentOn('vision'), controller.signal)
const result = await office(ctx, { operation, input, ...operation === 'render' ? {} : { format: operation === 'convert' ? 'pdf' : 'xlsx' } }, agentOn('vision'), controller.signal)
expect(result.isError).toBe(true)
expect(kit.renderImages.mock.calls[0]![1]?.aborted).toBe(true)
expect(kit[method].mock.calls[0]![1]?.aborted).toBe(true)
})
})
describe('arguments and paths', () => {
it.each([
...['pdf', 'docx', 'odt', 'txt'].map(format => ['report.docx', format]),
...['pdf', 'xlsx', 'ods', 'csv'].map(format => ['book.xlsx', format]),
...['pdf', 'pptx', 'odp'].map(format => ['deck.pptx', format]),
])('converts %s to %s', async (input, format) => {
const { ctx } = await setup()
expect(await office(ctx, { operation: 'convert', input, format })).toMatchObject({ isError: false, value: { operation: 'convert', format } })
})
it.each([
[{ operation: 'render', input: 'notes.txt' }, 'render accepts doc, docx, odt, xls, xlsx, ods, ppt, pptx, odp, or pdf files'],
[{ operation: 'convert', input: 'paper.pdf', format: 'docx' }, 'convert accepts doc, docx, odt, xls, xlsx, ods, ppt, pptx, or odp files'],
[{ operation: 'recalculate', input: 'deck.pptx', format: 'xlsx' }, 'recalculate accepts xls, xlsx, or ods workbooks'],
[{ operation: 'render', input: '.pptx' }, 'render accepts'],
[{ operation: 'render', input: 'deck.pptx', format: 'pdf' }, 'format applies only to convert and recalculate'],
[{ operation: 'convert', input: 'deck.pptx' }, 'convert requires format'],
[{ operation: 'convert', input: 'deck.pptx', format: 'pdf', pages: [1] }, 'pages applies only to render'],
[{ operation: 'convert', input: 'deck.pptx', format: 'pdf', range: 'A1' }, 'range applies only to render'],
[{ operation: 'convert', input: 'deck.pptx', format: 'pdf', dpi: 96 }, 'dpi applies only to render'],
[{ operation: 'convert', input: 'book.xlsx', format: 'pdf', sheet: 'A' }, 'sheet applies only to render and CSV conversion'],
[{ operation: 'recalculate', input: 'book.xlsx', format: 'xlsx', sheet: 'A' }, 'sheet applies only to render and CSV conversion'],
[{ operation: 'convert', input: 'deck.pptx' }, 'format'],
[{ operation: 'recalculate', input: 'book.xlsx' }, 'format'],
[{ operation: 'convert', input: 'book.xlsx', format: 'pdf', sheet: 'A' }, 'sheet applies only to CSV conversion'],
[{ operation: 'convert', input: 'book.xlsx', format: 'csv', sheet: ' ' }, 'sheet must be an exact worksheet name'],
[{ operation: 'render', input: 'deck.pptx', format: 'pdf' }, 'format applies only to office_convert or office_recalculate'],
[{ operation: 'convert', input: 'deck.pptx', format: 'pdf', pages: [1] }, 'pages applies only to office_render'],
[{ operation: 'convert', input: 'book.xlsx', format: 'pdf', range: 'A1:B2' }, 'range applies only to office_render'],
[{ operation: 'convert', input: 'deck.pptx', format: 'pdf', dpi: 96 }, 'dpi applies only to office_render'],
[{ operation: 'recalculate', input: 'book.xlsx', format: 'xlsx', sheet: 'Data' }, 'sheet applies only to office_render or office_convert'],
[{ operation: 'recalculate', input: 'book.xlsx', format: 'xlsx', pages: [1] }, 'pages applies only to office_render'],
[{ operation: 'render', input: 'deck.pptx', output: 'deck.pdf' }, 'office_render does not accept output'],
[{ operation: 'render', input: 'book.xlsx', pages: [1] }, 'pages does not apply to spreadsheets'],
[{ operation: 'render', input: 'deck.pptx', pages: [] }, 'pages must list distinct one-based page numbers'],
[{ operation: 'render', input: 'deck.pptx', pages: [0] }, 'pages must list distinct one-based page numbers'],
@@ -424,13 +486,14 @@ describe('arguments and paths', () => {
[{ operation: 'render', input: 'missing.pptx' }, 'missing.pptx": not found'],
[{ operation: 'render', input: 'folder.pptx' }, 'folder.pptx": not a regular file'],
[{ operation: 'convert', input: 'deck.pptx', format: 'xlsx' }, 'deck.pptx" to xlsx: this file converts to pdf, pptx, odp'],
[{ operation: 'recalculate', input: 'book.xlsx', format: 'pdf' }, 'book.xlsx" to pdf: this file recalculates to xlsx, ods'],
[{ operation: 'recalculate', input: 'book.xlsx', format: 'pdf' }, 'format'],
])('refuses %j', async (args, message) => {
await mkdir(join(dir, 'folder.pptx'))
const { ctx, kit } = await setup()
const result = await office(ctx, args)
expect(result.isError).toBe(true)
expect(text(result)).toContain(message)
expect(kit.renderImages).not.toHaveBeenCalled()
expect(kit.convertTo).not.toHaveBeenCalled()
expect(kit.recalculate).not.toHaveBeenCalled()
})
@@ -446,8 +509,7 @@ describe('arguments and paths', () => {
expect(converted.value).toEqual({ operation: 'convert', path: join(dir, 'book.xlsx'), file: join(home, 'outputs', 'book.csv'),
format: 'csv', bytes: 10, missingFonts: [] })
expect(converted.meta).toEqual({ path: join(dir, 'book.xlsx'), file: join(home, 'outputs', 'book.csv') })
await office(ctx, { operation: 'convert', input: 'deck.pptx', format: 'pdf' }, null)
expect(kit.convertTo.mock.calls[1]![0]).toMatchObject({ output: { owner: 'agentless', name: 'deck.pdf' } })
await office(ctx, { operation: 'convert', input: 'deck.pptx', format: 'pdf' })
expect(kit.convertTo.mock.calls[1]![0]).not.toHaveProperty('sheet')
kit.recalculate.mockResolvedValueOnce({ path: join(home, 'outputs', 'book.ods'), bytes: 3, pageCount: 1, missingFonts: [], generation })
const recalculated = await office(ctx, { operation: 'recalculate', input: 'book.xlsx', format: 'ods' })
@@ -518,25 +580,29 @@ describe('PTC dispatch', () => {
const { ctx } = await setup({ ptc: true })
const runtime = ctx.ptcRuntime as FakeRuntime
runtime.behavior = async (request) => {
const value = await request.bindings[0]!.functions.office!({ operation: 'render', input: 'deck.pptx' })
const value = await request.bindings[0]!.functions.office_render!({ input: 'deck.pptx' })
return { logs: [], value }
}
const agent = { ...agentOn('vision'), ctx }
await loadOffice(ctx, agent)
const toolSet = await ctx.tools.resolve({ agent: agent as never, modelSelection: { provider: 'visual', model: 'vision' }, signal })
onTestFinished(() => { toolSet.dispose() })
const run = (args: Record<string, unknown>) => executeModelToolFixture(ctx, {
signal, callId: ToolCallId(`run-${++calls}`), name: RUN_CODE_NAME, arguments: args, agent: agent as never,
toolSet,
})
const result = await run({ code: 'return await tools.office({ operation: "render", input: "deck.pptx" })', description: 'Render' })
const result = await run({ code: 'return await tools.office_render({ input: "deck.pptx" })', description: 'Render' })
expect(result.isError).toBe(false)
expect(result.additionalContexts?.[0]?.content.some(block => block.type === 'image')).toBe(true)
const denied: string[] = []
ctx.on('tools/pre-execute', (exec, next) => {
if (exec.name !== 'office') return next()
if (exec.name !== 'office_render') return next()
denied.push(exec.name)
return Promise.resolve({ kind: 'deny' as const, reason: 'office denied by policy' })
}, { prepend: true })
const refused = await run({ code: 'return await tools.office({ operation: "render", input: "deck.pptx" })', description: 'Render' })
expect(denied).toEqual(['office'])
const refused = await run({ code: 'return await tools.office_render({ input: "deck.pptx" })', description: 'Render' })
expect(denied).toEqual(['office_render'])
expect(text(refused)).toContain('office denied by policy')
})
})
@@ -14,6 +14,12 @@
{
"path": "../../../vendor/schemastery"
},
{
"path": "../../core/agent"
},
{
"path": "../../skill/skill"
},
{
"path": "../../attachment/attachment"
},
Loaded 100 of 153 files, more files were not shown because too many files have changed in this diff. Show more