diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md
index a1a13b2200..dbc95653e7 100644
--- a/THIRD_PARTY_NOTICES.md
+++ b/THIRD_PARTY_NOTICES.md
@@ -46,6 +46,7 @@ External packages installed for runtime use or embedded in distributed Host or b
| [`@joplin/turndown-plugin-gfm`](https://github.com/laurent22/joplin-turndown-plugin-gfm) | MIT |
| [`@jridgewell/gen-mapping`](https://github.com/jridgewell/sourcemaps) | MIT |
| [`@js-temporal/polyfill`](https://github.com/js-temporal/temporal-polyfill) | ISC |
+| [`@larksuite/cli`](https://github.com/larksuite/cli) | MIT |
| [`@lexical/history`](https://github.com/facebook/lexical) | MIT |
| [`@lexical/plain-text`](https://github.com/facebook/lexical) | MIT |
| [`@lexical/text`](https://github.com/facebook/lexical) | MIT |
diff --git a/docs/config-catalog.md b/docs/config-catalog.md
index c73d730cfb..d392711c24 100644
--- a/docs/config-catalog.md
+++ b/docs/config-catalog.md
@@ -1537,6 +1537,30 @@ export interface Config {
}
```
+
+
+
+## `@deepseek-ai/dsh-feishu`
+
+- `inject`: `skills` · `subprocess` · `shellEnv`
+- `source`: [`packages/connector/feishu/src/index.ts:21`](../packages/connector/feishu/src/index.ts)
+
+```ts config-catalog
+/** CLI location and limits for backend skill commands. */
+export interface Config extends FeishuCliLimits {
+ /** Absolute directory containing `lark-cli`; defaults to the installed `@larksuite/cli` package. */
+ binDir?: string
+}
+
+/** Deployment limits for one native command. */
+export interface FeishuCliLimits {
+ /** Deadline in milliseconds, including executable lookup. */
+ commandTimeoutMs: number
+ /** Maximum stdout bytes retained from one command. */
+ maxOutputBytes: number
+}
+```
+
diff --git a/docs/config-catalog.zh.md b/docs/config-catalog.zh.md
index 9cd00ec95a..0d1fd626c3 100644
--- a/docs/config-catalog.zh.md
+++ b/docs/config-catalog.zh.md
@@ -1539,6 +1539,30 @@ export interface Config {
}
```
+
+
+
+## `@deepseek-ai/dsh-feishu`
+
+- `inject`: `skills` · `subprocess` · `shellEnv`
+- `source`: [`packages/connector/feishu/src/index.ts:21`](../packages/connector/feishu/src/index.ts)
+
+```ts config-catalog
+/** CLI location and limits for backend skill commands. */
+export interface Config extends FeishuCliLimits {
+ /** Absolute directory containing `lark-cli`; defaults to the installed `@larksuite/cli` package. */
+ binDir?: string
+}
+
+/** Deployment limits for one native command. */
+export interface FeishuCliLimits {
+ /** Deadline in milliseconds, including executable lookup. */
+ commandTimeoutMs: number
+ /** Maximum stdout bytes retained from one command. */
+ maxOutputBytes: number
+}
+```
+
diff --git a/docs/module-graph.md b/docs/module-graph.md
index fc6b7af7ac..5c52b7c96a 100644
--- a/docs/module-graph.md
+++ b/docs/module-graph.md
@@ -232,6 +232,7 @@ flowchart TD
end
subgraph group_connector["packages/connector"]
pkg_cli_account["cli-account"]
+ pkg_feishu["feishu"]
end
subgraph group_context["packages/context"]
pkg_agent_instructions["agent-instructions"]
diff --git a/docs/module-graph.zh.md b/docs/module-graph.zh.md
index a85e9c5965..0d45730cbe 100644
--- a/docs/module-graph.zh.md
+++ b/docs/module-graph.zh.md
@@ -234,6 +234,7 @@ flowchart TD
end
subgraph group_connector["packages/connector"]
pkg_cli_account["cli-account"]
+ pkg_feishu["feishu"]
end
subgraph group_context["packages/context"]
pkg_agent_instructions["agent-instructions"]
diff --git a/packages/connector/README.md b/packages/connector/README.md
index 490e6c3378..087829c2ce 100644
--- a/packages/connector/README.md
+++ b/packages/connector/README.md
@@ -25,6 +25,7 @@ Each application plugin in this group is installed into a profile to use one thi
| Package | Role | ctx key |
|---|---|---|
| [`cli-account/`](cli-account/README.md) | Runs a vendor CLI by its absolute path, gives the model that path in runtime context, and runs one Host-owned account operation at a time for CLI app plugins | — |
+| [`feishu/`](feishu/README.md) | Installs the official Feishu `lark-cli` on the private Shell PATH and registers its embedded skills | registers on `ctx.skills` and `ctx.shellEnv` |
-----
diff --git a/packages/connector/README.zh.md b/packages/connector/README.zh.md
index 44b2a31b6e..0abb1f08d5 100644
--- a/packages/connector/README.zh.md
+++ b/packages/connector/README.zh.md
@@ -25,6 +25,7 @@ kind: "package-group"
| 包 | 职责 | ctx 键 |
|---|---|---|
| [`cli-account/`](cli-account/README.zh.md) | 为 CLI 应用插件按绝对路径运行厂商 CLI,在运行时上下文中把这个路径告诉模型,并在 Host 上一次执行一个账号操作 | — |
+| [`feishu/`](feishu/README.zh.md) | 把官方飞书 `lark-cli` 安装到私有 Shell PATH 上,并注册其内嵌 skill | 注册到 `ctx.skills` 与 `ctx.shellEnv` |
-----
diff --git a/packages/connector/feishu/README.i18n.yaml b/packages/connector/feishu/README.i18n.yaml
new file mode 100644
index 0000000000..6cb7241e0e
--- /dev/null
+++ b/packages/connector/feishu/README.i18n.yaml
@@ -0,0 +1,70 @@
+# Bilingual-pair consistency record for README.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 packages/connector/feishu/README.md
+/:
+ en: e57ca64308201282
+ zh: ea1b9be187481228
+/deepseek-ai-dsh-feishu:
+ en: 5b26d6ad2128b454
+ zh: 6d3ccfcdb716ef8d
+/deepseek-ai-dsh-feishu/summary:
+ en: 6bf72b5f8baab073
+ zh: 5fb53034f11958f4
+/deepseek-ai-dsh-feishu/table-of-contents:
+ en: d152484eb41ac6b4
+ zh: 09388d293f9be9cb
+/deepseek-ai-dsh-feishu/use-this-package:
+ en: bbff250eba0f1b89
+ zh: 0a618f05cc88ee2b
+/deepseek-ai-dsh-feishu/use-this-package/install-into-a-profile:
+ en: e48f41c5c992f4a4
+ zh: 785ddef280a12013
+/deepseek-ai-dsh-feishu/use-this-package/what-you-get:
+ en: affd3411620f486b
+ zh: a8baf9b561b8c4ac
+/deepseek-ai-dsh-feishu/use-this-package/configure:
+ en: 8d825d4a9e266ef5
+ zh: f43a252b6bb33707
+/deepseek-ai-dsh-feishu/understand-the-implementation:
+ en: 10d310e4e6ebc514
+ zh: e32b95f44b9c5d31
+/deepseek-ai-dsh-feishu/further-exploration:
+ en: 4c98d4aa2fe2d1fe
+ zh: 5ef02d71983c4b18
+/deepseek-ai-dsh-feishu/model-experience:
+ en: 215e7ba838619b7b
+ zh: a311da3843709f90
+/deepseek-ai-dsh-feishu/model-experience/skill-catalog-entries:
+ en: 7265024b55daf9ef
+ zh: 3447e587c56a25d6
+/deepseek-ai-dsh-feishu/model-experience/skill-catalog-entries/what-the-model-sees:
+ en: 0ca23a4403d704a0
+ zh: ad0ace90de824494
+/deepseek-ai-dsh-feishu/model-experience/skill-catalog-entries/token-effect:
+ en: 77d5cd81ff936d7e
+ zh: 56acd95e5caf27f5
+/deepseek-ai-dsh-feishu/model-experience/skill-catalog-entries/kv-cache-effect:
+ en: b3875910bea34217
+ zh: cb942b8bb415d7f5
+/deepseek-ai-dsh-feishu/model-experience/loaded-skill-body:
+ en: 8955ac196848e69f
+ zh: 54aa7db097eafd3c
+/deepseek-ai-dsh-feishu/model-experience/loaded-skill-body/what-the-model-sees:
+ en: 574580d8e60a9e02
+ zh: bc42783630e402eb
+/deepseek-ai-dsh-feishu/model-experience/loaded-skill-body/what-the-model-sees/dsh-guidance:
+ en: 5c7ac466d9d28f26
+ zh: 01dfd0690f58c8bc
+/deepseek-ai-dsh-feishu/model-experience/loaded-skill-body/token-effect:
+ en: 25c4bdac3cbd261c
+ zh: 67cf97623c4b6c56
+/deepseek-ai-dsh-feishu/model-experience/loaded-skill-body/kv-cache-effect:
+ en: 1f6b842a95e14ce4
+ zh: 0d57cdec5e828828
+/deepseek-ai-dsh-feishu/known-limitations-and-deferred-work:
+ en: 4a19270abcaab1d4
+ zh: 607e2ef841eaf687
+/deepseek-ai-dsh-feishu/known-limitations-and-deferred-work/dev-note:
+ en: be15f75bf32de641
+ zh: 85de42dc5e1d934b
diff --git a/packages/connector/feishu/README.md b/packages/connector/feishu/README.md
new file mode 100644
index 0000000000..c361d3a548
--- /dev/null
+++ b/packages/connector/feishu/README.md
@@ -0,0 +1,144 @@
+---
+description: "Install the official Feishu lark-cli with a profile, run it by name from the backend and the Shell, and load its embedded skills."
+kind: "package-bundle"
+---
+
+# @deepseek-ai/dsh-feishu
+
+English | [中文](README.zh.md)
+
+## Summary
+
+The Feishu plugin installs a pinned `@larksuite/cli` with the profile, puts its `lark-cli` executable on the private Shell PATH, and registers the skills embedded in that CLI. The agent runs `lark-cli` by name through the ordinary Shell tools; the backend reads the skills with the same executable. App setup and sign-in happen in the conversation through the CLI's own flow, and the CLI keeps credentials in its default configuration, which the user's own terminal shares. Only macOS is supported.
+
+## Table of Contents
+
+- [Use this package](#use-this-package)
+- [Understand the implementation](#understand-the-implementation)
+- [Further Exploration](#further-exploration)
+- [Model Experience](#model-experience)
+- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
+- [Dev Note](#dev-note)
+
+-----
+
+
+## Use this package
+
+### Install into a profile
+
+Install the package as a bundle, for example from the Web sidebar's **Plugins** page or with the CLI:
+
+```sh
+dsh plugin --profile web add @deepseek-ai/dsh-feishu
+```
+
+The bundle patch inserts the `feishu` row after the profile's other layers. pnpm blocks the `@larksuite/cli` install script, which downloads the official native binary from GitHub Releases or npmmirror and verifies its checksum; approve it through the Plugins page's **Allow these scripts and retry** or the other paths that [Plugin Manager](../../boot/plugin-manager/README.md) documents. Until the executable exists, the plugin fails to load with an error that names the missing path.
+
+### What you get
+
+After the plugin loads, the CLI's embedded skills, such as `lark-doc` and `lark-shared`, join the skill catalog. The agent loads one with the `skill` tool and runs `lark-cli` commands through the ordinary Shell tools under the current sandbox and approval policy. When a command reports a missing app configuration or sign-in, the agent follows the CLI's flow: it gives the user a verification URL and QR code, then completes sign-in after the user confirms. Commands that save sign-in state ask for single-command approval because they write outside the workspace.
+
+Turning the row off in Plugin Manager withdraws the skills and the private PATH entry for later Shell calls. The CLI configuration and sign-in stay in place.
+
+### Configure
+
+| Field | Default | Meaning |
+|---|---|---|
+| `binDir` | the installed `@larksuite/cli` package's `bin` | Absolute directory containing an executable `lark-cli` |
+| `commandTimeoutMs` | `30000` | Deadline for one backend skill command, including executable lookup |
+| `maxOutputBytes` | `1048576` | Maximum stdout bytes retained from one backend skill command |
+
+The generated [config catalog](../../../docs/config-catalog.md#deepseek-aidsh-feishu) is the exhaustive source of supported fields.
+
+-----
+
+
+## Understand the implementation
+
+
+Implementation internals — click to expand
+
+[`src/index.ts`](src/index.ts) requires a Host subprocess runtime, checks that `binDir/lark-cli` is executable, registers `binDir` with [Shell environment](../../shell/shell-env/README.md) as the `feishu` PATH contribution, and registers the skill provider. [`src/cli.ts`](src/cli.ts) prepares the private PATH environment for the subprocess runtime, resolves `lark-cli` in it, and spawns the result with that environment, so the backend and the Shell use the same executable. Each command collects bounded stdout and a stderr tail, rejects a nonzero exit or truncated stdout, and waits for its managed process range to exit. Disposal aborts running commands and settles after their processes exit.
+
+[`src/skills.ts`](src/skills.ts) runs `lark-cli skills list --json` once per registration. A failed catalog is logged once and stays empty until the plugin reloads. Each load runs `skills read --json`, removes the frontmatter, and places the DSH guidance before the vendor body and the CLI's reference-reading guidance after it. References are embedded in the binary, so the skill's resource base is opaque.
+
+
+
+-----
+
+
+## Further Exploration
+
+- [Connector packages](../README.md) — the group this application plugin belongs to.
+- [Shell environment](../../shell/shell-env/README.md) — private PATH contributions shared by backend subprocesses and Shell tools.
+- [Skills](../../../docs/subsystems/skills.md) — catalog publication, loading, and precedence.
+- [Plugin Manager](../../boot/plugin-manager/README.md) — installation, build-script approval, and enablement.
+
+-----
+
+
+## Model Experience
+
+### Skill catalog entries
+
+#### What the model sees
+
+Each skill that `lark-cli skills list --json` reports appears in the skill catalog with its vendor name and description; the catalog owner shortens long descriptions. `lark-cli` 1.0.97 reports 28 skills.
+
+#### Token effect
+
+The entries stay in context while the plugin is loaded. For `lark-cli` 1.0.97 they total about 6,000 characters.
+
+#### KV Cache effect
+
+The catalog is fixed for one CLI version. Loading or unloading the plugin changes the catalog, which is republished as a new message and leaves earlier context in place.
+
+### Loaded skill body
+
+#### What the model sees
+
+A `skill` tool result contains the DSH guidance below, the vendor `SKILL.md` body without frontmatter, and the CLI's guidance for reading referenced files with `lark-cli skills read `. Its resource description reads `Embedded lark-cli references; use the skills read command given in the loaded skill.`
+
+##### DSH guidance
+
+```markdown
+# Feishu in DSH
+
+Call this integration the Feishu plugin (飞书插件 in Chinese) in user-facing replies. Run `lark-cli` by name in the Host Shell; DSH installs and updates it. It uses the default lark-cli configuration and sign-in shared with the user's own terminal, so do not remove, switch, or sign out of apps or profiles unless the user asks.
+
+When a command reports a missing app configuration or sign-in, load the lark-shared skill and follow its setup and auth flow. Never ask for or print app secrets or tokens.
+
+Commands that save sign-in state, such as `auth login --device-code` and `config init`, write outside the workspace and use up their one-time authorization even when the save is denied: run them with the Shell tool's single-command approval from the start. Run other commands in the existing sandbox and request that approval only when a credential, lock, log, or cache write is denied.
+
+Do not install another lark-cli or run `lark-cli update`.
+```
+
+#### Token effect
+
+Each load adds the fixed guidance and one vendor body to the retained tool history. Reference files read through `lark-cli` arrive as ordinary Shell output.
+
+#### KV Cache effect
+
+Loading appends a tool result and does not rewrite earlier context.
+
+## Known Limitations and Deferred Work
+
+
+
+- Only macOS is supported. Other platforms are unverified, and the Windows executable name `lark-cli.exe` is not located.
+- The plugin requires a subprocess runtime on this Host and fails to load when the composition's subprocess runtime runs elsewhere, such as over SSH.
+- The plugin uses the CLI's default configuration. Signing in or out from DSH affects the user's own terminal, and there is no DSH-private account or account picker. The plugin offers no unbind operation; turning it off keeps the configuration and sign-in.
+- There is no Host-side account status or operation; setup and sign-in happen in the conversation.
+- Under a file sandbox, a token refresh during an ordinary command can be denied and then needs single-command approval.
+- A failed skill catalog stays empty until the plugin reloads.
+
+
+### Dev Note
+
+
+Working context for maintainers — click to expand
+
+Repository installs deny the `@larksuite/cli` install script in the root `pnpm-workspace.yaml`, so a checkout has no native binary. To run the plugin from source against the real CLI, run `node packages/connector/feishu/node_modules/@larksuite/cli/scripts/install.js` once. Specs and the `feishu-skills` session snapshot use stand-in executables through `binDir`.
+
+
diff --git a/packages/connector/feishu/README.zh.md b/packages/connector/feishu/README.zh.md
new file mode 100644
index 0000000000..16be351b1f
--- /dev/null
+++ b/packages/connector/feishu/README.zh.md
@@ -0,0 +1,144 @@
+---
+description: "随 profile 安装官方飞书 lark-cli,让后端与 Shell 按名称调用它,并加载其内嵌 skill。"
+kind: "package-bundle"
+---
+
+# @deepseek-ai/dsh-feishu
+
+[English](README.md) | 中文
+
+## 概述
+
+飞书插件随 profile 安装固定版本的 `@larksuite/cli`,把其 `lark-cli` 可执行文件放到私有 Shell PATH 上,并注册该 CLI(命令行界面)内嵌的 skill(技能)。agent(智能体)通过普通 Shell 工具按名称运行 `lark-cli`;后端用同一个可执行文件读取 skill。应用配置与登录在对话中通过 CLI 自带的流程完成,CLI 把凭据保存在默认配置中,用户自己的终端也共用这份配置。仅支持 macOS。
+
+## 目录
+
+- [使用本包](#use-this-package)
+- [理解实现](#understand-the-implementation)
+- [进一步探索](#further-exploration)
+- [模型体验](#model-experience)
+- [已知限制与延期工作](#known-limitations-and-deferred-work)
+- [开发备注](#dev-note)
+
+-----
+
+
+## 使用本包
+
+### 安装到 profile
+
+将本包作为 bundle 安装,例如在 Web 侧栏的**插件**页面安装,或使用 CLI:
+
+```sh
+dsh plugin --profile web add @deepseek-ai/dsh-feishu
+```
+
+bundle patch 在 profile 其他层之后插入 `feishu` 行。pnpm 会拦截 `@larksuite/cli` 的安装脚本,该脚本从 GitHub Releases 或 npmmirror 下载官方原生二进制并校验 checksum;请在插件页面通过**允许这些脚本并重试**批准,或使用 [Plugin Manager](../../boot/plugin-manager/README.zh.md) 记载的其他途径。在可执行文件就绪之前,插件加载会失败,错误信息会给出缺失的路径。
+
+### 获得的能力
+
+插件加载后,CLI 内嵌的 skill(例如 `lark-doc` 与 `lark-shared`)进入 skill 目录。agent 用 `skill` 工具加载其中一个,并在当前沙箱与审批策略下通过普通 Shell 工具运行 `lark-cli` 命令。命令报告缺少应用配置或登录时,agent 按 CLI 的流程操作:向用户提供验证链接和二维码,用户确认后完成登录。保存登录状态的命令会在工作区之外写入,因此会申请单条命令审批。
+
+在 Plugin Manager 中关闭该行会为后续 Shell 调用撤下 skill 与私有 PATH 条目,CLI 配置与登录保持不变。
+
+### 配置
+
+| 字段 | 默认值 | 含义 |
+|---|---|---|
+| `binDir` | 已安装 `@larksuite/cli` 包的 `bin` | 包含可执行 `lark-cli` 的绝对目录 |
+| `commandTimeoutMs` | `30000` | 单条后端 skill 命令的期限,包含可执行文件查找 |
+| `maxOutputBytes` | `1048576` | 单条后端 skill 命令保留的 stdout 字节上限 |
+
+生成的[配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-feishu)是受支持字段的完整来源。
+
+-----
+
+
+## 理解实现
+
+
+实现内部机制——点击展开
+
+[`src/index.ts`](src/index.ts) 要求 subprocess 运行时位于本 Host,检查 `binDir/lark-cli` 是否可执行,把 `binDir` 作为 `feishu` PATH 贡献注册到 [Shell 环境](../../shell/shell-env/README.zh.md),并注册 skill 提供方。[`src/cli.ts`](src/cli.ts) 为 subprocess 运行时准备私有 PATH 环境,在其中解析 `lark-cli`,并用同一环境启动解析结果,使后端与 Shell 使用同一个可执行文件。每条命令收集有上限的 stdout 和 stderr 尾部,拒绝非零退出码或被截断的 stdout,并等待其受管进程范围退出。释放时中止正在运行的命令,并在这些进程退出后完成。
+
+[`src/skills.ts`](src/skills.ts) 每次注册只运行一次 `lark-cli skills list --json`。目录读取失败时记录一次日志,并在插件重新加载前保持为空。每次加载运行 `skills read --json`,去掉 frontmatter,把 DSH 指引放在厂商正文之前,把 CLI 的引用文件读取指引放在之后。引用文件内嵌在二进制中,因此 skill 的资源基址是 opaque 类型。
+
+
+
+-----
+
+
+## 进一步探索
+
+- [Connector 包](../README.zh.md)——这个应用插件所属的分组。
+- [Shell 环境](../../shell/shell-env/README.zh.md)——后端 subprocess 与 Shell 工具共用的私有 PATH 贡献。
+- [Skills](../../../docs/subsystems/skills.zh.md)——目录发布、加载与优先级。
+- [Plugin Manager](../../boot/plugin-manager/README.zh.md)——安装、构建脚本审批与启用。
+
+-----
+
+
+## 模型体验
+
+### Skill 目录条目
+
+#### 模型看到什么
+
+`lark-cli skills list --json` 报告的每个 skill 都以厂商名称和描述出现在 skill 目录中;过长的描述由目录所有者缩短。`lark-cli` 1.0.97 报告 28 个 skill。
+
+#### Token 影响
+
+插件加载期间这些条目一直留在上下文中。对 `lark-cli` 1.0.97 而言,合计约 6,000 个字符。
+
+#### KV Cache 影响
+
+同一 CLI 版本的目录固定不变。加载或卸载插件会改变目录,目录作为新消息重新发布,不改动更早的上下文。
+
+### 已加载的 skill 正文
+
+#### 模型看到什么
+
+`skill` 工具结果依次包含下方 DSH 指引、去掉 frontmatter 的厂商 `SKILL.md` 正文,以及 CLI 关于用 `lark-cli skills read ` 读取引用文件的指引。其资源描述为 `Embedded lark-cli references; use the skills read command given in the loaded skill.`
+
+##### DSH 指引
+
+```markdown
+# Feishu in DSH
+
+Call this integration the Feishu plugin (飞书插件 in Chinese) in user-facing replies. Run `lark-cli` by name in the Host Shell; DSH installs and updates it. It uses the default lark-cli configuration and sign-in shared with the user's own terminal, so do not remove, switch, or sign out of apps or profiles unless the user asks.
+
+When a command reports a missing app configuration or sign-in, load the lark-shared skill and follow its setup and auth flow. Never ask for or print app secrets or tokens.
+
+Commands that save sign-in state, such as `auth login --device-code` and `config init`, write outside the workspace and use up their one-time authorization even when the save is denied: run them with the Shell tool's single-command approval from the start. Run other commands in the existing sandbox and request that approval only when a credential, lock, log, or cache write is denied.
+
+Do not install another lark-cli or run `lark-cli update`.
+```
+
+#### Token 影响
+
+每次加载把固定指引与一份厂商正文加入保留的工具历史。通过 `lark-cli` 读取的引用文件作为普通 Shell 输出返回。
+
+#### KV Cache 影响
+
+加载会追加一条工具结果,不改写更早的上下文。
+
+## 已知限制与延期工作
+
+
+
+- 仅支持 macOS。其他平台未经验证,且不会定位 Windows 可执行文件名 `lark-cli.exe`。
+- 插件要求 subprocess 运行时位于本 Host;组合中的 subprocess 运行时在别处运行(例如通过 SSH)时,插件加载失败。
+- 插件使用 CLI 的默认配置。在 DSH 中登录或退出会影响用户自己的终端,没有 DSH 私有账号或账号选择器。插件不提供解绑操作;关闭插件会保留配置与登录。
+- Host 端没有账号状态或账号操作;配置与登录在对话中完成。
+- 在文件沙箱下,普通命令中的 token 刷新可能被拒绝,此时需要单条命令审批。
+- skill 目录读取失败后,在插件重新加载前保持为空。
+
+
+### 开发备注
+
+
+维护者工作上下文——点击展开
+
+仓库安装在根目录 `pnpm-workspace.yaml` 中拒绝 `@larksuite/cli` 的安装脚本,因此检出的仓库没有原生二进制。要在源码中用真实 CLI 运行插件,请执行一次 `node packages/connector/feishu/node_modules/@larksuite/cli/scripts/install.js`。单测与 `feishu-skills` 会话快照通过 `binDir` 使用替身可执行文件。
+
+
diff --git a/packages/connector/feishu/cordis.patch.yml b/packages/connector/feishu/cordis.patch.yml
new file mode 100644
index 0000000000..8edafe5d19
--- /dev/null
+++ b/packages/connector/feishu/cordis.patch.yml
@@ -0,0 +1,3 @@
+- insert:
+ - id: feishu
+ name: '@deepseek-ai/dsh-feishu'
diff --git a/packages/connector/feishu/locale/en.json b/packages/connector/feishu/locale/en.json
new file mode 100644
index 0000000000..e300afd5b6
--- /dev/null
+++ b/packages/connector/feishu/locale/en.json
@@ -0,0 +1,6 @@
+{
+ "meta": {
+ "title": "Feishu Plugin",
+ "description": "Use Feishu documents, messages, and other authorized features in conversations"
+ }
+}
diff --git a/packages/connector/feishu/locale/zh.json b/packages/connector/feishu/locale/zh.json
new file mode 100644
index 0000000000..04505fdf5b
--- /dev/null
+++ b/packages/connector/feishu/locale/zh.json
@@ -0,0 +1,6 @@
+{
+ "meta": {
+ "title": "飞书插件",
+ "description": "在对话中使用飞书文档、消息及其他已授权的功能"
+ }
+}
diff --git a/packages/connector/feishu/package.json b/packages/connector/feishu/package.json
new file mode 100644
index 0000000000..6a98793517
--- /dev/null
+++ b/packages/connector/feishu/package.json
@@ -0,0 +1,56 @@
+{
+ "name": "@deepseek-ai/dsh-feishu",
+ "description": "Feishu plugin: the official lark-cli on the Shell PATH and its embedded skills",
+ "version": "0.2.1-alpha.1",
+ "publishConfig": {
+ "access": "public"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
+ "directory": "packages/connector/feishu"
+ },
+ "type": "module",
+ "main": "lib/index.js",
+ "types": "lib/types/index.d.ts",
+ "exports": {
+ ".": {
+ "types": "./lib/types/index.d.ts",
+ "default": "./lib/index.js"
+ },
+ "./locale/*.json": "./locale/*.json",
+ "./src/*": "./src/*",
+ "./package.json": "./package.json",
+ "./cordis.patch.yml": "./cordis.patch.yml"
+ },
+ "files": [
+ "locale/*.json",
+ "lib/index.js",
+ "cordis.patch.yml",
+ "lib/types/**/*.d.ts"
+ ],
+ "license": "MIT",
+ "dsh": {
+ "bundle": {
+ "patch": "./cordis.patch.yml"
+ }
+ },
+ "dependencies": {
+ "@deepseek-ai/dsh-timeout": "workspace:*",
+ "@deepseek-ai/schemastery": "workspace:~",
+ "@larksuite/cli": "1.0.97",
+ "zod": "^4.4.3"
+ },
+ "peerDependencies": {
+ "@deepseek-ai/cordis": "workspace:~",
+ "@deepseek-ai/dsh-shell-env": "workspace:*",
+ "@deepseek-ai/dsh-skill": "workspace:*",
+ "@deepseek-ai/dsh-subprocess": "workspace:*"
+ },
+ "devDependencies": {
+ "@deepseek-ai/cordis": "workspace:~",
+ "@deepseek-ai/dsh-shell-env": "workspace:*",
+ "@deepseek-ai/dsh-skill": "workspace:*",
+ "@deepseek-ai/dsh-subprocess": "workspace:*"
+ }
+}
diff --git a/packages/connector/feishu/src/cli.ts b/packages/connector/feishu/src/cli.ts
new file mode 100644
index 0000000000..27aeff2e57
--- /dev/null
+++ b/packages/connector/feishu/src/cli.ts
@@ -0,0 +1,128 @@
+/** Managed lark-cli location and bounded execution with subprocess lifetime ownership. */
+
+import { accessSync, constants } from 'node:fs'
+import { homedir } from 'node:os'
+import { dirname, join } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import type { ShellEnvRegistry } from '@deepseek-ai/dsh-shell-env'
+import type { SubprocessOutcome, SubprocessRuntime } from '@deepseek-ai/dsh-subprocess'
+import { deadline, timeoutOf } from '@deepseek-ai/dsh-timeout'
+
+const PROGRAM = 'lark-cli'
+const STDERR_TAIL_BYTES = 4096
+const TERMINATE_GRACE_MS = 2_000
+const TIMEOUT_CODE = 'FEISHU_CLI_TIMEOUT'
+
+/** Deployment limits for one native command. */
+export interface FeishuCliLimits {
+ /** Deadline in milliseconds, including executable lookup. */
+ commandTimeoutMs: number
+ /** Maximum stdout bytes retained from one command. */
+ maxOutputBytes: number
+}
+
+/**
+ * Locate the directory holding the managed executable.
+ * @param binDir - absolute override; defaults to the installed `@larksuite/cli` package.
+ * @returns the bin directory containing an executable `lark-cli`.
+ * @throws when the executable is missing.
+ */
+export function resolveCliDirectory(binDir: string | undefined): string {
+ const directory = binDir ?? join(dirname(fileURLToPath(import.meta.resolve('@larksuite/cli/package.json'))), 'bin')
+ const program = join(directory, PROGRAM)
+ try {
+ accessSync(program, constants.X_OK)
+ } catch (error) {
+ throw new Error(`feishu: ${program} is not executable; approve the @larksuite/cli install script or set binDir`, { cause: error })
+ }
+ return directory
+}
+
+function commandLine(args: readonly string[]): string {
+ return [PROGRAM, ...args].join(' ')
+}
+
+/** Runs lark-cli through the private Shell PATH and owns each command until its process exits. */
+export class FeishuCli {
+ private readonly lifetime = new AbortController()
+ private readonly running = new Set>()
+
+ constructor(
+ private readonly subprocess: SubprocessRuntime,
+ private readonly shellEnv: ShellEnvRegistry,
+ private readonly limits: FeishuCliLimits,
+ ) {}
+
+ /**
+ * Run one command to process exit, require exit code zero, and parse its JSON stdout.
+ * @param args - native arguments without the executable.
+ * @param signal - caller cancellation; an abort rejects with its reason after the process exits.
+ * @returns unvalidated JSON for the caller to check.
+ * @throws after disposal; otherwise, with a message naming the command, when the deadline
+ * (which includes executable lookup) elapses, the exit is nonzero (with the stderr tail),
+ * stdout exceeds `maxOutputBytes`, or stdout is not JSON.
+ */
+ async json(args: readonly string[], signal: AbortSignal): Promise {
+ this.lifetime.signal.throwIfAborted()
+ const task = this.execute(args, signal)
+ this.running.add(task)
+ let stdout: string
+ try {
+ stdout = await task
+ } finally {
+ this.running.delete(task)
+ }
+ try {
+ return JSON.parse(stdout)
+ } catch (error) {
+ throw new Error(`${commandLine(args)} returned invalid JSON`, { cause: error })
+ }
+ }
+
+ /**
+ * Abort owned commands and wait for their processes to exit.
+ * @returns settles once every owned command has settled.
+ */
+ async dispose(): Promise {
+ this.lifetime.abort(new Error('feishu: plugin disposed'))
+ await Promise.allSettled([...this.running])
+ }
+
+ private async execute(args: readonly string[], upstream: AbortSignal): Promise {
+ using limit = deadline(AbortSignal.any([upstream, this.lifetime.signal]), this.limits.commandTimeoutMs, TIMEOUT_CODE)
+ try {
+ return await this.collect(args, limit.signal)
+ } catch (error) {
+ if (timeoutOf(limit.signal, TIMEOUT_CODE) === undefined) throw error
+ throw new Error(`${commandLine(args)} timed out after ${String(this.limits.commandTimeoutMs)}ms`, { cause: error })
+ }
+ }
+
+ private async collect(args: readonly string[], signal: AbortSignal): Promise {
+ const env = this.shellEnv.prepareEnvironment(this.subprocess)
+ const program = await this.subprocess.resolveExecutable(PROGRAM, env, signal)
+ signal.throwIfAborted()
+ const handle = this.subprocess.spawn({
+ argv: [program, ...args], cwd: homedir(), env,
+ stdio: { stdin: 'ignore', stdout: { maxBytes: this.limits.maxOutputBytes }, stderr: { maxBytes: STDERR_TAIL_BYTES } },
+ graceMs: TERMINATE_GRACE_MS, signal,
+ })
+ let outcome: SubprocessOutcome
+ try {
+ outcome = await handle.done
+ } finally {
+ handle.terminate()
+ await handle.waitForExit()
+ }
+ signal.throwIfAborted()
+ /* v8 ignore start -- collect-mode stdio always yields both readers. */
+ const stdout = handle.collected.stdout?.readFrom(0) ?? { text: '', lossy: false }
+ const stderr = handle.collected.stderr?.readFrom(0).text ?? ''
+ /* v8 ignore stop */
+ if (outcome.exitCode !== 0) {
+ throw new Error(`${commandLine(args)} exited with ${outcome.signal ?? String(outcome.exitCode)}${stderr.trim() === '' ? '' : `: ${stderr.trim()}`}`)
+ }
+ if (stdout.lossy) throw new Error(`${commandLine(args)} output exceeded ${String(this.limits.maxOutputBytes)} bytes`)
+ return stdout.text
+ }
+}
diff --git a/packages/connector/feishu/src/index.ts b/packages/connector/feishu/src/index.ts
new file mode 100644
index 0000000000..ac810b263e
--- /dev/null
+++ b/packages/connector/feishu/src/index.ts
@@ -0,0 +1,48 @@
+/**
+ * Feishu plugin: puts the managed lark-cli on the private Shell PATH and
+ * registers its embedded skills. Setup and sign-in use the CLI's default
+ * account through ordinary Shell commands.
+ * @module @deepseek-ai/dsh-feishu
+ */
+
+import type { Context } from '@deepseek-ai/cordis'
+import z from '@deepseek-ai/schemastery'
+import { MAX_TIMER_DELAY_MS } from '@deepseek-ai/dsh-timeout'
+import type {} from '@deepseek-ai/dsh-shell-env'
+import type {} from '@deepseek-ai/dsh-skill'
+import type {} from '@deepseek-ai/dsh-subprocess'
+import { FeishuCli, resolveCliDirectory, type FeishuCliLimits } from './cli.ts'
+import { FeishuSkillProvider } from './skills.ts'
+
+export const name = 'feishu'
+export const inject = ['skills', 'subprocess', 'shellEnv']
+
+/** CLI location and limits for backend skill commands. */
+export interface Config extends FeishuCliLimits {
+ /** Absolute directory containing `lark-cli`; defaults to the installed `@larksuite/cli` package. */
+ binDir?: string
+}
+
+/** Runtime configuration schema for the Feishu plugin. */
+export const Config: z = z.object({
+ binDir: z.string().min(1),
+ commandTimeoutMs: z.number().min(1).max(MAX_TIMER_DELAY_MS).default(30_000),
+ maxOutputBytes: z.number().min(1).step(1).default(1_048_576),
+})
+
+/**
+ * Register the private CLI directory and embedded skills; disposal waits for owned CLI processes.
+ * @param ctx - Context carrying the skill registry, subprocess runtime, and Shell environment.
+ * @param config - CLI location and command limits.
+ * @throws when the subprocess runtime does not run on this Host or `lark-cli` is not executable.
+ */
+export function apply(ctx: Context, config: Config): void {
+ if (!ctx.subprocess.runsOnHost) {
+ throw new Error('feishu: lark-cli and its default account are local to this Host; mount a Host subprocess runtime')
+ }
+ const directory = resolveCliDirectory(config.binDir)
+ ctx.shellEnv.registerPath({ name: 'feishu', directories: [directory] })
+ const cli = new FeishuCli(ctx.subprocess, ctx.shellEnv, config)
+ ctx.effect(() => () => cli.dispose())
+ ctx.skills.registerProvider(control => new FeishuSkillProvider(cli, control, ctx.logger))
+}
diff --git a/packages/connector/feishu/src/skills.ts b/packages/connector/feishu/src/skills.ts
new file mode 100644
index 0000000000..aecc2b8fea
--- /dev/null
+++ b/packages/connector/feishu/src/skills.ts
@@ -0,0 +1,69 @@
+/** Embedded lark-cli skills adapted to the DSH Shell and the shared default account. */
+
+import type { Context } from '@deepseek-ai/cordis'
+import z from 'zod'
+import { BUNDLED_SKILL_RANK, isSkillName } from '@deepseek-ai/dsh-skill'
+import type { SkillCandidate, SkillDefinition, SkillLookupOptions, SkillProvider, SkillProviderControl } from '@deepseek-ai/dsh-skill'
+import type { FeishuCli } from './cli.ts'
+
+const Catalog = z.object({
+ ok: z.literal(true),
+ skills: z.array(z.object({ name: z.string().refine(isSkillName), description: z.string().min(1) })),
+})
+const Skill = z.object({ skill: z.string(), path: z.string(), content: z.string(), guidance: z.string() })
+const FRONTMATTER = /^---\r?\n[\s\S]*?\r?\n---(?:\r?\n|$)/u
+
+const GUIDANCE = [
+ '# Feishu in DSH',
+ 'Call this integration the Feishu plugin (飞书插件 in Chinese) in user-facing replies. Run `lark-cli` by name in the Host Shell; DSH installs and updates it. It uses the default lark-cli configuration and sign-in shared with the user\'s own terminal, so do not remove, switch, or sign out of apps or profiles unless the user asks.',
+ 'When a command reports a missing app configuration or sign-in, load the lark-shared skill and follow its setup and auth flow. Never ask for or print app secrets or tokens.',
+ 'Commands that save sign-in state, such as `auth login --device-code` and `config init`, write outside the workspace and use up their one-time authorization even when the save is denied: run them with the Shell tool\'s single-command approval from the start. Run other commands in the existing sandbox and request that approval only when a credential, lock, log, or cache write is denied.',
+ 'Do not install another lark-cli or run `lark-cli update`.',
+].join('\n\n')
+
+/** Lists native embedded skills once per registration; provider disposal cancels outstanding CLI reads. */
+export class FeishuSkillProvider implements SkillProvider {
+ readonly name = 'feishu'
+ private catalog: Promise | undefined
+
+ constructor(
+ private readonly cli: FeishuCli,
+ private readonly control: SkillProviderControl,
+ private readonly logger: Context['logger'],
+ ) {}
+
+ list(): Promise {
+ this.catalog ??= this.load().catch((error: unknown) => {
+ if (!this.control.signal.aborted) this.logger.warn(`feishu: skills unavailable until the plugin reloads: ${String(error)}`)
+ return []
+ })
+ return this.catalog
+ }
+
+ async get(candidate: SkillCandidate, options: SkillLookupOptions): Promise {
+ const signal = options.signal === undefined ? this.control.signal : AbortSignal.any([options.signal, this.control.signal])
+ const parsed = Skill.safeParse(await this.cli.json(['skills', 'read', candidate.name, '--json'], signal))
+ const skill = parsed.data
+ const frontmatter = skill === undefined ? null : FRONTMATTER.exec(skill.content)
+ if (skill === undefined || skill.skill !== candidate.name || skill.path !== 'SKILL.md' || frontmatter === null) {
+ throw new Error(`lark-cli skills read ${candidate.name} --json returned an unexpected skill document`, { cause: parsed.error })
+ }
+ const content = [GUIDANCE, skill.content.slice(frontmatter[0].length).trim(), skill.guidance.trim()].join('\n\n')
+ const { rank: _rank, locator: _locator, ...summary } = candidate
+ return { ...summary, content }
+ }
+
+ private async load(): Promise {
+ const catalog = Catalog.safeParse(await this.cli.json(['skills', 'list', '--json'], this.control.signal))
+ if (!catalog.success) throw new Error('lark-cli skills list --json returned an unexpected catalog', { cause: catalog.error })
+ return catalog.data.skills.map(skill => ({
+ ...skill,
+ invocation: { modelInvocable: true, userInvocable: true },
+ provider: this.name,
+ source: 'bundled',
+ rank: BUNDLED_SKILL_RANK,
+ locator: skill.name,
+ resourceBase: { kind: 'opaque', description: 'Embedded lark-cli references; use the skills read command given in the loaded skill.' },
+ }))
+ }
+}
diff --git a/packages/connector/feishu/tests/cli.spec.ts b/packages/connector/feishu/tests/cli.spec.ts
new file mode 100644
index 0000000000..284502cd51
--- /dev/null
+++ b/packages/connector/feishu/tests/cli.spec.ts
@@ -0,0 +1,109 @@
+import { rm } from 'node:fs/promises'
+import { homedir } from 'node:os'
+import { delimiter } from 'node:path'
+import { Context } from '@deepseek-ai/cordis'
+import * as ShellEnv from '@deepseek-ai/dsh-shell-env'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { FeishuCli } from '../src/cli.ts'
+import { createBinDir, ScriptedSubprocess } from './harness.ts'
+
+const LIMITS = { commandTimeoutMs: 5_000, maxOutputBytes: 1024 }
+
+describe('FeishuCli', () => {
+ let ctx: Context
+ let subprocess: ScriptedSubprocess
+ let binDir: string
+
+ beforeEach(async () => {
+ ctx = new Context()
+ await ctx.plugin(ScriptedSubprocess)
+ await ctx.plugin(ShellEnv)
+ subprocess = ctx.subprocess as ScriptedSubprocess
+ binDir = await createBinDir()
+ ctx.shellEnv.registerPath({ name: 'feishu', directories: [binDir] })
+ })
+
+ afterEach(async () => {
+ await ctx.fiber.dispose()
+ await rm(binDir, { recursive: true, force: true })
+ })
+
+ const cli = (limits = LIMITS) => new FeishuCli(ctx.subprocess, ctx.shellEnv, limits)
+
+ it('finds lark-cli on the prepared private PATH, spawns it with that environment, and parses stdout', async () => {
+ subprocess.respond = (process) => { process.reply({ stdout: '{"ok":true}' }) }
+
+ await expect(cli().json(['skills', 'list', '--json'], AbortSignal.timeout(5_000))).resolves.toEqual({ ok: true })
+
+ const [lookup] = subprocess.lookups
+ expect(lookup?.command).toBe('lark-cli')
+ expect(lookup?.env?.PATH?.split(delimiter)[0]).toBe(binDir)
+ const [process] = subprocess.processes
+ expect(process?.spec).toMatchObject({
+ argv: ['/fixture/bin/lark-cli', 'skills', 'list', '--json'],
+ cwd: homedir(),
+ stdio: { stdin: 'ignore', stdout: { maxBytes: 1024 } },
+ })
+ expect(process?.spec.env).toBe(lookup?.env)
+ expect(process?.terminated).toBe(true)
+ })
+
+ it.each([
+ [{ exitCode: 2, stderr: ' {"ok":false} \n' }, 'lark-cli skills list exited with 2: {"ok":false}'],
+ [{ exitCode: 1 }, /^lark-cli skills list exited with 1$/u],
+ [{ exitCode: null, signal: 'SIGKILL' as const }, 'lark-cli skills list exited with SIGKILL'],
+ [{ stdout: '{"ok":', lossy: true }, 'lark-cli skills list output exceeded 1024 bytes'],
+ [{ stdout: 'not json' }, 'lark-cli skills list returned invalid JSON'],
+ ])('rejects a failed command %#', async (reply, message) => {
+ subprocess.respond = (process) => { process.reply(reply) }
+
+ await expect(cli().json(['skills', 'list'], AbortSignal.timeout(5_000))).rejects.toThrow(message)
+ })
+
+ it.each(['lookup', 'process'] as const)('applies the command deadline during %s', async (phase) => {
+ if (phase === 'lookup') {
+ subprocess.lookup = signal => new Promise((_resolve, reject) => {
+ signal?.addEventListener('abort', () => { reject(signal.reason instanceof Error ? signal.reason : new Error('lookup aborted')) }, { once: true })
+ })
+ } else {
+ subprocess.respond = () => {}
+ }
+
+ await expect(cli({ ...LIMITS, commandTimeoutMs: 20 }).json(['skills', 'list'], new AbortController().signal))
+ .rejects.toThrow('lark-cli skills list timed out after 20ms')
+ expect(subprocess.processes.map(process => process.terminated)).toEqual(phase === 'lookup' ? [] : [true])
+ })
+
+ it('keeps a caller deadline reason instead of reporting the command deadline', async () => {
+ subprocess.respond = () => {}
+
+ await expect(cli().json(['skills', 'list'], AbortSignal.timeout(20))).rejects.toThrow(expect.objectContaining({ name: 'TimeoutError' }))
+ })
+
+ it('terminates the process and rejects with the caller reason on cancellation', async () => {
+ const caller = new AbortController()
+ subprocess.respond = () => { caller.abort(new Error('caller left')) }
+
+ await expect(cli().json(['skills', 'read', 'lark-doc'], caller.signal)).rejects.toThrow('caller left')
+ expect(subprocess.processes[0]?.terminated).toBe(true)
+ })
+
+ it('settles disposal only after owned processes exit and refuses later commands', async () => {
+ subprocess.respond = (process) => { process.holdExit = true }
+ const owner = cli()
+ const pending = owner.json(['skills', 'list'], new AbortController().signal)
+ const rejected = expect(pending).rejects.toThrow('plugin disposed')
+ await vi.waitFor(() => { expect(subprocess.processes).toHaveLength(1) })
+
+ let disposed = false
+ const disposal = owner.dispose().then(() => { disposed = true })
+ await vi.waitFor(() => { expect(subprocess.processes[0]?.terminated).toBe(true) })
+ expect(disposed).toBe(false)
+
+ subprocess.processes[0]?.release()
+ await disposal
+ await rejected
+ await expect(owner.json(['skills', 'list'], new AbortController().signal)).rejects.toThrow('plugin disposed')
+ expect(subprocess.processes).toHaveLength(1)
+ })
+})
diff --git a/packages/connector/feishu/tests/harness.ts b/packages/connector/feishu/tests/harness.ts
new file mode 100644
index 0000000000..015e80c966
--- /dev/null
+++ b/packages/connector/feishu/tests/harness.ts
@@ -0,0 +1,145 @@
+/** Scripted lark-cli processes and a temporary bin directory for Feishu plugin specs. */
+
+import { chmod, mkdtemp, writeFile } from 'node:fs/promises'
+import { tmpdir } from 'node:os'
+import { join } from 'node:path'
+import { SubprocessRuntime } from '@deepseek-ai/dsh-subprocess'
+import type {
+ SubprocessCollectedOutputs,
+ SubprocessHandle,
+ SubprocessOutcome,
+ SubprocessSpawnSpec,
+ SubprocessTerminalEnvironment,
+} from '@deepseek-ai/dsh-subprocess'
+
+/** Output and exit facts one scripted command reports. */
+export interface CliReply {
+ stdout?: string
+ stderr?: string
+ exitCode?: number | null
+ signal?: NodeJS.Signals | null
+ lossy?: boolean
+}
+
+/** A collect-mode process whose managed range exits on termination unless held. */
+export class ScriptedProcess implements SubprocessHandle {
+ readonly stdin = undefined
+ readonly stdout = undefined
+ readonly stderr = undefined
+ readonly control = undefined
+ readonly collected: SubprocessCollectedOutputs
+ readonly done: Promise
+ terminated = false
+ holdExit = false
+ private readonly outcome = Promise.withResolvers()
+ private readonly exit = Promise.withResolvers()
+ private output: Required> = { stdout: '', stderr: '', lossy: false }
+
+ constructor(readonly spec: SubprocessSpawnSpec) {
+ this.done = this.outcome.promise
+ const reader = (stream: 'stdout' | 'stderr') => ({
+ readFrom: () => ({
+ text: this.output[stream],
+ nextOffset: Buffer.byteLength(this.output[stream]),
+ lossy: stream === 'stdout' && this.output.lossy,
+ }),
+ })
+ this.collected = { stdout: reader('stdout'), stderr: reader('stderr') }
+ spec.signal?.addEventListener('abort', () => { this.terminate() }, { once: true })
+ }
+
+ /** Finish the command with the given output; the managed range stays alive until termination. */
+ reply(reply: CliReply): void {
+ this.output = { stdout: reply.stdout ?? '', stderr: reply.stderr ?? '', lossy: reply.lossy ?? false }
+ this.outcome.resolve({ exitCode: reply.exitCode === undefined ? 0 : reply.exitCode, signal: reply.signal ?? null })
+ }
+
+ terminate(): void {
+ this.terminated = true
+ this.outcome.resolve({ exitCode: null, signal: 'SIGTERM' })
+ if (!this.holdExit) this.exit.resolve(true)
+ }
+
+ /** Empty a held managed range. */
+ release(): void {
+ this.exit.resolve(true)
+ }
+
+ waitForExit(): Promise {
+ return this.exit.promise
+ }
+}
+
+/** Host subprocess runtime whose lookups and spawns are recorded and answered by `respond`. */
+export class ScriptedSubprocess extends SubprocessRuntime {
+ readonly lookups: Array<{ command: string; env: Readonly> | undefined }> = []
+ readonly processes: ScriptedProcess[] = []
+ host = true
+ lookup: (signal?: AbortSignal) => Promise = () => Promise.resolve('/fixture/bin/lark-cli')
+ respond: (process: ScriptedProcess) => void = (process) => { process.reply({ stdout: '{}' }) }
+
+ override get runsOnHost(): boolean {
+ return this.host
+ }
+
+ override resolveExecutable(command: string, env?: Readonly>, signal?: AbortSignal): Promise {
+ this.lookups.push({ command, env })
+ return this.lookup(signal)
+ }
+
+ override terminalEnvironment(): Promise {
+ return Promise.resolve({ platform: 'posix' })
+ }
+
+ override spawn(spec: SubprocessSpawnSpec): ScriptedProcess {
+ spec.signal?.throwIfAborted()
+ const process = new ScriptedProcess(spec)
+ this.processes.push(process)
+ queueMicrotask(() => { this.respond(process) })
+ return process
+ }
+
+ override spawnTerminal(): Promise {
+ throw new Error('lark-cli commands never allocate a terminal')
+ }
+}
+
+/**
+ * Answer each command by its arguments after the executable.
+ * @param replies - reply per space-joined argument list.
+ * @returns a `respond` function that fails unknown commands.
+ */
+export function byArguments(replies: Record): (process: ScriptedProcess) => void {
+ return (process) => {
+ const reply = replies[process.spec.argv.slice(1).join(' ')]
+ process.reply(reply ?? { exitCode: 1, stderr: `unexpected command: ${process.spec.argv.join(' ')}` })
+ }
+}
+
+/**
+ * Create a temporary directory holding an executable `lark-cli` placeholder.
+ * @returns the absolute bin directory.
+ */
+export async function createBinDir(): Promise {
+ const directory = await mkdtemp(join(tmpdir(), 'dsh-feishu-bin-'))
+ await writeFile(join(directory, 'lark-cli'), '')
+ await chmod(join(directory, 'lark-cli'), 0o755)
+ return directory
+}
+
+/** Two-skill catalog in the `skills list --json` format. */
+export const CATALOG = {
+ ok: true,
+ skills: [
+ { name: 'lark-doc', description: 'Feishu documents', version: '1.0.0' },
+ { name: 'lark-shared', description: 'Setup and sign-in', version: '1.1.0' },
+ ],
+}
+
+/** `skills read lark-doc --json` output with frontmatter, body, and vendor guidance. */
+export const DOC_SKILL = {
+ skill: 'lark-doc',
+ path: 'SKILL.md',
+ content: '---\nname: lark-doc\ndescription: Feishu documents\n---\n\n# docs\n\nRead documents.\n',
+ guidance: '> Tip: read this skill\'s own files with `lark-cli skills read lark-doc `.',
+}
diff --git a/packages/connector/feishu/tests/installation.spec.ts b/packages/connector/feishu/tests/installation.spec.ts
new file mode 100644
index 0000000000..4d1a9c09ea
--- /dev/null
+++ b/packages/connector/feishu/tests/installation.spec.ts
@@ -0,0 +1,26 @@
+import { constants } from 'node:fs'
+import { dirname, join } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import { beforeEach, expect, it, vi } from 'vitest'
+import { resolveCliDirectory } from '../src/cli.ts'
+
+const fs = vi.hoisted(() => ({ accessSync: vi.fn() }))
+vi.mock('node:fs', async importOriginal => ({ ...await importOriginal(), accessSync: fs.accessSync }))
+
+const PACKAGE_BIN = join(dirname(fileURLToPath(import.meta.resolve('@larksuite/cli/package.json'))), 'bin')
+
+beforeEach(() => {
+ fs.accessSync.mockReset()
+})
+
+it('defaults to the installed @larksuite/cli bin directory', () => {
+ expect(resolveCliDirectory(undefined)).toBe(PACKAGE_BIN)
+ expect(fs.accessSync).toHaveBeenCalledWith(join(PACKAGE_BIN, 'lark-cli'), constants.X_OK)
+})
+
+it('accepts a configured directory and names the missing executable with the install remedy', () => {
+ expect(resolveCliDirectory('/opt/lark/bin')).toBe('/opt/lark/bin')
+ fs.accessSync.mockImplementation(() => { throw new Error('EACCES') })
+ expect(() => resolveCliDirectory(PACKAGE_BIN))
+ .toThrow(`feishu: ${join(PACKAGE_BIN, 'lark-cli')} is not executable; approve the @larksuite/cli install script or set binDir`)
+})
diff --git a/packages/connector/feishu/tests/plugin.spec.ts b/packages/connector/feishu/tests/plugin.spec.ts
new file mode 100644
index 0000000000..53a1297c0f
--- /dev/null
+++ b/packages/connector/feishu/tests/plugin.spec.ts
@@ -0,0 +1,122 @@
+import { rm } from 'node:fs/promises'
+import { Context } from '@deepseek-ai/cordis'
+import SkillRegistry from '@deepseek-ai/dsh-skill'
+import * as ShellEnv from '@deepseek-ai/dsh-shell-env'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import * as Feishu from '../src/index.ts'
+import { byArguments, CATALOG, createBinDir, DOC_SKILL, ScriptedSubprocess } from './harness.ts'
+
+const CONFIG = { commandTimeoutMs: 5_000, maxOutputBytes: 1_048_576 }
+const LIST = 'skills list --json'
+const READ = 'skills read lark-doc --json'
+
+describe('Feishu plugin', () => {
+ let ctx: Context
+ let subprocess: ScriptedSubprocess
+ let binDir: string
+ let warnings: string[]
+
+ beforeEach(async () => {
+ ctx = new Context()
+ await ctx.plugin(SkillRegistry)
+ await ctx.plugin(ScriptedSubprocess)
+ await ctx.plugin(ShellEnv)
+ subprocess = ctx.subprocess as ScriptedSubprocess
+ binDir = await createBinDir()
+ warnings = []
+ ctx.logger.warn = ((message: unknown) => { warnings.push(String(message)) }) as typeof ctx.logger.warn
+ })
+
+ afterEach(async () => {
+ await ctx.fiber.dispose()
+ await rm(binDir, { recursive: true, force: true })
+ })
+
+ it('publishes embedded skills and loads each body after the DSH guidance', async () => {
+ subprocess.respond = byArguments({ [LIST]: { stdout: JSON.stringify(CATALOG) }, [READ]: { stdout: JSON.stringify(DOC_SKILL) } })
+ await ctx.plugin(Feishu, { ...CONFIG, binDir })
+
+ const catalog = await ctx.skills.list()
+ expect(catalog).toEqual(CATALOG.skills.map(({ name, description }) => ({
+ name, description,
+ invocation: { modelInvocable: true, userInvocable: true },
+ provider: 'feishu',
+ source: 'bundled',
+ resourceBase: { kind: 'opaque', description: 'Embedded lark-cli references; use the skills read command given in the loaded skill.' },
+ })))
+
+ const loaded = await ctx.skills.get('lark-doc')
+ const sections = loaded?.content.split('\n\n') ?? []
+ expect(sections[0]).toBe('# Feishu in DSH')
+ expect(sections.slice(-3)).toEqual(['# docs', 'Read documents.', DOC_SKILL.guidance])
+ expect(loaded?.content).not.toContain('description: Feishu documents')
+ })
+
+ it('reads the catalog once per registration and keeps a failed catalog empty with one warning', async () => {
+ subprocess.respond = byArguments({ [LIST]: { exitCode: 1, stderr: 'broken install' } })
+ await ctx.plugin(Feishu, { ...CONFIG, binDir })
+
+ expect(await ctx.skills.list()).toEqual([])
+ expect(await ctx.skills.list({ cwd: '/elsewhere' })).toEqual([])
+ expect(subprocess.processes).toHaveLength(1)
+ expect(warnings).toEqual(['feishu: skills unavailable until the plugin reloads: Error: lark-cli skills list --json exited with 1: broken install'])
+ })
+
+ it('names the catalog command when its JSON does not match the catalog format', async () => {
+ subprocess.respond = byArguments({ [LIST]: { stdout: JSON.stringify({ ok: true, skills: [{ name: 'Not A Skill', description: 'x' }] }) } })
+ await ctx.plugin(Feishu, { ...CONFIG, binDir })
+
+ expect(await ctx.skills.list()).toEqual([])
+ expect(warnings).toEqual(['feishu: skills unavailable until the plugin reloads: Error: lark-cli skills list --json returned an unexpected catalog'])
+ })
+
+ it('refuses to load without a Host subprocess runtime', () => {
+ subprocess.host = false
+
+ expect(() => { Feishu.apply(ctx, { ...CONFIG, binDir }) }).toThrow('feishu: lark-cli and its default account are local to this Host')
+ expect(ctx.shellEnv.getPathPrefix(ctx.subprocess)).toBeUndefined()
+ })
+
+ it.each([
+ [{ ...DOC_SKILL, skill: 'lark-im' }],
+ [{ ...DOC_SKILL, path: 'references/a.md' }],
+ [{ ...DOC_SKILL, content: '# no frontmatter' }],
+ [{ skill: 'lark-doc', path: 'SKILL.md', content: DOC_SKILL.content }],
+ ])('rejects an unexpected skill document %#', async (document) => {
+ subprocess.respond = byArguments({ [LIST]: { stdout: JSON.stringify(CATALOG) }, [READ]: { stdout: JSON.stringify(document) } })
+ await ctx.plugin(Feishu, { ...CONFIG, binDir })
+
+ await expect(ctx.skills.get('lark-doc')).rejects.toThrow('lark-cli skills read lark-doc --json returned an unexpected skill document')
+ })
+
+ it('terminates a skill read when the lookup is cancelled', async () => {
+ const lookup = new AbortController()
+ subprocess.respond = (process) => {
+ if (process.spec.argv.includes('list')) process.reply({ stdout: JSON.stringify(CATALOG) })
+ else lookup.abort(new Error('lookup cancelled'))
+ }
+ await ctx.plugin(Feishu, { ...CONFIG, binDir })
+
+ await expect(ctx.skills.get('lark-doc', { signal: lookup.signal })).rejects.toThrow('lookup cancelled')
+ await vi.waitFor(() => { expect(subprocess.processes[1]?.terminated).toBe(true) })
+ })
+
+ it('withdraws the private PATH and skills on disposal after owned processes exit, without a warning', async () => {
+ subprocess.respond = (process) => { process.holdExit = true }
+ const fiber = await ctx.plugin(Feishu, { ...CONFIG, binDir })
+ expect(ctx.shellEnv.getPathPrefix(ctx.subprocess)).toBe(binDir)
+ void ctx.skills.list()
+ await vi.waitFor(() => { expect(subprocess.processes).toHaveLength(1) })
+
+ let disposed = false
+ const disposal = fiber.dispose().then(() => { disposed = true })
+ await vi.waitFor(() => { expect(subprocess.processes[0]?.terminated).toBe(true) })
+ expect(disposed).toBe(false)
+ subprocess.processes[0]?.release()
+ await disposal
+
+ expect(ctx.shellEnv.getPathPrefix(ctx.subprocess)).toBeUndefined()
+ expect(await ctx.skills.list()).toEqual([])
+ expect(warnings).toEqual([])
+ })
+})
diff --git a/packages/connector/feishu/tsconfig.json b/packages/connector/feishu/tsconfig.json
new file mode 100644
index 0000000000..133dd4574e
--- /dev/null
+++ b/packages/connector/feishu/tsconfig.json
@@ -0,0 +1,30 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "rootDir": "src",
+ "outDir": "lib/types"
+ },
+ "include": [
+ "src"
+ ],
+ "references": [
+ {
+ "path": "../../../vendor/cordis"
+ },
+ {
+ "path": "../../../vendor/schemastery"
+ },
+ {
+ "path": "../../util/timeout"
+ },
+ {
+ "path": "../../shell/shell-env"
+ },
+ {
+ "path": "../../skill/skill"
+ },
+ {
+ "path": "../../subprocess/subprocess"
+ }
+ ]
+}
diff --git a/packages/preset/agent-preset/skills/cordis-composition-reference/references/packages.md b/packages/preset/agent-preset/skills/cordis-composition-reference/references/packages.md
index 5f711a8c0d..6dc2bc63f9 100644
--- a/packages/preset/agent-preset/skills/cordis-composition-reference/references/packages.md
+++ b/packages/preset/agent-preset/skills/cordis-composition-reference/references/packages.md
@@ -138,6 +138,12 @@ Every package below exports a Cordis plugin that a bundle patch can name in a Lo
|---|---|---|
| `@deepseek-ai/dsh-computer-use` | no | Exclusive named computer-use provider registration |
+## connector
+
+| Package | Config | Description |
+|---|---|---|
+| `@deepseek-ai/dsh-feishu` | yes | Feishu plugin: the official lark-cli on the Shell PATH and its embedded skills |
+
## context
| Package | Config | Description |
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 52b443264c..c30fbecec5 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -7282,6 +7282,34 @@ importers:
specifier: workspace:*
version: link:../../core/system-prompt
+ packages/connector/feishu:
+ dependencies:
+ '@deepseek-ai/dsh-timeout':
+ specifier: workspace:*
+ version: link:../../util/timeout
+ '@deepseek-ai/schemastery':
+ specifier: link:../../../vendor/schemastery
+ version: link:../../../vendor/schemastery
+ '@larksuite/cli':
+ specifier: 1.0.97
+ version: 1.0.97
+ zod:
+ specifier: ^4.4.3
+ version: 4.4.3
+ devDependencies:
+ '@deepseek-ai/cordis':
+ specifier: workspace:~
+ version: link:../../../vendor/cordis
+ '@deepseek-ai/dsh-shell-env':
+ specifier: workspace:*
+ version: link:../../shell/shell-env
+ '@deepseek-ai/dsh-skill':
+ specifier: workspace:*
+ version: link:../../skill/skill
+ '@deepseek-ai/dsh-subprocess':
+ specifier: workspace:*
+ version: link:../../subprocess/subprocess
+
packages/context/agent-instructions:
dependencies:
'@deepseek-ai/dsh-util-values':
@@ -18571,6 +18599,14 @@ packages:
'@chevrotain/types@11.1.2':
resolution: {integrity: sha512-U+HFai5+zmJCkK86QsaJtoITlboZHBqrVketcO2ROv865xfCMSFpELQoz1GkX5GzME8pTa+3kbKrZHQtI0gdbw==}
+ '@clack/core@1.5.1':
+ resolution: {integrity: sha512-iHTrHA8MtVuLl2TfZySmcKv1qO2PoyC9Z7pfSDozEuV5vtY3/wcOPKJXlqJ5Oq2Cx5DDGQGAMVx6HZfRRoVEbQ==}
+ engines: {node: '>= 20.12.0'}
+
+ '@clack/prompts@1.8.1':
+ resolution: {integrity: sha512-dlT1m5e/0yUL0kRNcQn7yGLVThkgbB0Ga/1AmfDDC/8ik6AIiSf2QLQO2zPYvefsHP0aFgxO93cVLCCfDp7kzQ==}
+ engines: {node: '>= 20.12.0'}
+
'@csstools/color-helpers@6.1.0':
resolution: {integrity: sha512-064IFJdjTfUqnjpCVpMOdbr8FLQBhinbZj6yRv2An2E41O/pLEXqfFRWqGq/SxlE5PEUYTlvWsG2r8MswAVvkg==}
engines: {node: '>=20.19.0'}
@@ -19737,6 +19773,13 @@ packages:
cpu: [x64]
os: [win32]
+ '@larksuite/cli@1.0.97':
+ resolution: {integrity: sha512-u6cAXLuxgfYHVAThoFA00G6lTLFPyTBxWW7KH7mP7u3cwQgLPHGjvDbU4xNm3tzoVT0jlk3Rshvxl+PAbnnFew==}
+ engines: {node: '>=16'}
+ cpu: [x64, arm64, riscv64]
+ os: [darwin, linux, win32]
+ hasBin: true
+
'@lexical/clipboard@0.49.0':
resolution: {integrity: sha512-AVKj21xH1qU7JAFA/v0hCoafa+Yti1I7cHG+JQIgc/EqCtP8ePeJyIfTPNN/tXskoCdq++HewQoiSXRwwlocVg==}
peerDependencies:
@@ -22775,9 +22818,18 @@ packages:
fast-sha256@1.3.0:
resolution: {integrity: sha512-n11RGP/lrWEFI/bWdygLxhI+pVeo1ZYIVwvvPkW7azl/rOy+F3HYRZ2K5zeE9mmkhQppyv9sQFx0JM9UabnpPQ==}
+ fast-string-truncated-width@3.0.3:
+ resolution: {integrity: sha512-0jjjIEL6+0jag3l2XWWizO64/aZVtpiGE3t0Zgqxv0DPuxiMjvB3M24fCyhZUO4KomJQPj3LTSUnDP3GpdwC0g==}
+
+ fast-string-width@3.0.2:
+ resolution: {integrity: sha512-gX8LrtNEI5hq8DVUfRQMbr5lpaS4nMIWV+7XEbXk2b8kiQIizgnlr12B4dA3ZEx3308ze0O4Q1R+cHts8kyUJg==}
+
fast-uri@3.1.8:
resolution: {integrity: sha512-GZMtZUTNRpOVIECoXwLNZS5xUGE+mVNbTB8h/7Rwh2TFWcBQiPzTgyZi05BF9UMZKkLJv8XBRJTlU7zg8+ZfMg==}
+ fast-wrap-ansi@0.2.2:
+ resolution: {integrity: sha512-7F2Fl+TjRSenLqlU3UjSH0iyqopqoZIu7eZVpEirP2g1GtWa2G/ecEmBdgz31+Mxr+ELclgg6sokpSFIQiZ02Q==}
+
fast-xml-builder@1.2.0:
resolution: {integrity: sha512-00aAWieqff+ZJhsXA4g1g7M8k+7AYoMUUHF+/zFb5U6Uv/P0Vl4QZo84/IcufzYalLuEj9928bXN9PbbFzMF0Q==}
@@ -24964,6 +25016,9 @@ packages:
resolution: {integrity: sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==}
engines: {node: '>=10'}
+ sisteransi@1.0.5:
+ resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==}
+
smol-toml@1.9.0:
resolution: {integrity: sha512-hpd+HLON7HdZXqYchMM/+LaTTbdK0AU3NngIJ4KVyWbY9bfQqdL9cD+4yf6dUoU2Ap4VsU0JkQi6FxAI1B2mXQ==}
engines: {node: '>= 18'}
@@ -26466,6 +26521,18 @@ snapshots:
'@chevrotain/types@11.1.2': {}
+ '@clack/core@1.5.1':
+ dependencies:
+ fast-wrap-ansi: 0.2.2
+ sisteransi: 1.0.5
+
+ '@clack/prompts@1.8.1':
+ dependencies:
+ '@clack/core': 1.5.1
+ fast-string-width: 3.0.2
+ fast-wrap-ansi: 0.2.2
+ sisteransi: 1.0.5
+
'@csstools/color-helpers@6.1.0': {}
'@csstools/css-calc@3.2.1(@csstools/css-parser-algorithms@4.0.0(@csstools/css-tokenizer@4.0.0))(@csstools/css-tokenizer@4.0.0)':
@@ -27407,6 +27474,10 @@ snapshots:
'@koromix/koffi-win32-x64@3.1.1':
optional: true
+ '@larksuite/cli@1.0.97':
+ dependencies:
+ '@clack/prompts': 1.8.1
+
'@lexical/clipboard@0.49.0(typescript@6.0.3)':
dependencies:
'@lexical/extension': 0.49.0(typescript@6.0.3)
@@ -30526,8 +30597,18 @@ snapshots:
fast-sha256@1.3.0: {}
+ fast-string-truncated-width@3.0.3: {}
+
+ fast-string-width@3.0.2:
+ dependencies:
+ fast-string-truncated-width: 3.0.3
+
fast-uri@3.1.8: {}
+ fast-wrap-ansi@0.2.2:
+ dependencies:
+ fast-string-width: 3.0.2
+
fast-xml-builder@1.2.0:
dependencies:
path-expression-matcher: 1.5.0
@@ -32992,6 +33073,8 @@ snapshots:
dependencies:
semver: 7.8.5
+ sisteransi@1.0.5: {}
+
smol-toml@1.9.0: {}
source-map-js@1.2.2: {}
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 59b31eb46b..1837349a84 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -53,6 +53,9 @@ allowBuilds:
electron-winstaller: false
# Store-index rewriting only needs msgpackr's portable JavaScript codec.
msgpackr-extract: false
+ # The Feishu plugin's CLI downloads its native binary from GitHub Releases or npmmirror.
+ # Repository installs skip it; profiles that install the plugin approve it separately.
+ '@larksuite/cli@1.0.97': false
minimumReleaseAgeExclude:
# Native Codex and Claude tests qualify this exact release with its local patches.
diff --git a/tsconfig.base.json b/tsconfig.base.json
index d9323fbec4..8c873fd0ef 100644
--- a/tsconfig.base.json
+++ b/tsconfig.base.json
@@ -445,6 +445,7 @@
"@deepseek-ai/dsh-deepseek-llm-api-extensions": ["./packages/llm/deepseek-llm-api-extensions/src"],
"@deepseek-ai/dsh-deliverable-file-references": ["./packages/deliverables/deliverable-file-references/src"],
"@deepseek-ai/dsh-deque": ["./packages/util/deque/src"],
+ "@deepseek-ai/dsh-feishu": ["./packages/connector/feishu/src"],
"@deepseek-ai/dsh-file-reference": ["./packages/context/file-reference/src"],
"@deepseek-ai/dsh-file-reference-local": ["./packages/context/file-reference-local/src"],
"@deepseek-ai/dsh-fs": ["./packages/fs/fs/src"],
diff --git a/tsconfig.host.json b/tsconfig.host.json
index 2cb3a290a8..113418b751 100644
--- a/tsconfig.host.json
+++ b/tsconfig.host.json
@@ -294,6 +294,7 @@
{ "path": "./packages/boot/config-editor" },
{ "path": "./packages/client/connection/tsconfig.host.json" },
{ "path": "./packages/skill/skill-office" },
+ { "path": "./packages/connector/feishu" },
{ "path": "./packages/skill/tool-workspace-dependencies" },
{ "path": "./packages/browser-use/browser-use" },
{ "path": "./packages/experimental/browser-use-runtime" },