From 31bc3febc25f9acbebd519ba1d7c35bc93049178 Mon Sep 17 00:00:00 2001 From: gengruilin Date: Sun, 1 Nov 2026 01:35:40 +0800 Subject: [PATCH] refactor(wecom): show the authorization through the Host account registry The wecom row registers its account with ctx.cliAccounts instead of serving its own Remote to a browser package: - src/presentation.ts maps each authorization view to the section, tag, buttons, guide row, and failure, with the text of src/locales.ts in every shipped language; the activation prompt connects through display.connect. - The row becomes a function plugin and registers only while the registry runs, so headless profiles load it without the page. - The ui-wecom browser package, the wecom Remote, and its generated artifacts are removed; the Web E2E reads the untranslated exit code. --- apps/web/tests/wecom-connection.e2e.ts | 2 +- docs/capability-seams.i18n.yaml | 4 +- docs/capability-seams.md | 6 - docs/capability-seams.zh.md | 6 - docs/config-catalog.md | 3 +- docs/config-catalog.zh.md | 3 +- docs/module-graph.md | 5 +- docs/module-graph.zh.md | 5 +- docs/subsystems/credentials.md | 38 ------- docs/subsystems/credentials.zh.md | 38 ------- packages/client/README.i18n.yaml | 4 +- packages/client/README.md | 1 - packages/client/README.zh.md | 1 - packages/client/ui-wecom/README.i18n.yaml | 37 ------ packages/client/ui-wecom/README.md | 94 ---------------- packages/client/ui-wecom/README.zh.md | 94 ---------------- packages/client/ui-wecom/locale/de.json | 6 - packages/client/ui-wecom/locale/en.json | 6 - packages/client/ui-wecom/locale/es.json | 6 - packages/client/ui-wecom/locale/fr.json | 6 - packages/client/ui-wecom/locale/ja.json | 6 - packages/client/ui-wecom/locale/pt.json | 6 - packages/client/ui-wecom/locale/ru.json | 6 - packages/client/ui-wecom/locale/zh.json | 6 - packages/client/ui-wecom/package.json | 66 ----------- .../client/ui-wecom/src/client/account.ts | 65 ----------- .../client/ui-wecom/src/client/connection.ts | 43 ------- packages/client/ui-wecom/src/client/index.ts | 52 --------- packages/client/ui-wecom/src/index.ts | 4 - .../ui-wecom/tests/account.client.spec.ts | 97 ---------------- .../ui-wecom/tests/connection.client.spec.ts | 34 ------ .../ui-wecom/tests/mount.client.spec.ts | 87 --------------- packages/client/ui-wecom/tsconfig.json | 42 ------- packages/client/ui-wecom/tsdown.config.ts | 3 - packages/connector/README.i18n.yaml | 4 +- packages/connector/README.md | 2 +- packages/connector/README.zh.md | 2 +- packages/connector/wecom-cli/README.i18n.yaml | 16 +-- packages/connector/wecom-cli/README.md | 19 ++-- packages/connector/wecom-cli/README.zh.md | 19 ++-- packages/connector/wecom-cli/package.json | 24 +--- packages/connector/wecom-cli/src/index.ts | 105 ++++++------------ .../wecom-cli/src}/locales.ts | 96 +++------------- .../connector/wecom-cli/src/presentation.ts | 92 +++++++++++++++ packages/connector/wecom-cli/src/types.ts | 4 +- .../connector/wecom-cli/tests/account.spec.ts | 60 +++++----- .../connector/wecom-cli/tests/plugin.spec.ts | 42 +++++-- .../wecom-cli/tests/presentation.spec.ts | 91 +++++++++++++++ packages/connector/wecom-cli/tsconfig.json | 6 +- packages/connector/wecom/README.i18n.yaml | 20 ++-- packages/connector/wecom/README.md | 11 +- packages/connector/wecom/README.zh.md | 11 +- packages/connector/wecom/cordis.patch.yml | 2 - packages/connector/wecom/package.json | 3 +- .../extensions/tool-cordis/src/api-catalog.ts | 57 ---------- .../references/packages.md | 1 - pnpm-lock.yaml | 45 +------- scripts/gen-cordis-catalog.ts | 2 - scripts/gen-doc-graphs.ts | 8 -- scripts/product-package-policy.ts | 1 - .../verify-package-readme-model-experience.ts | 1 - tsconfig.client.json | 1 - 62 files changed, 364 insertions(+), 1263 deletions(-) delete mode 100644 packages/client/ui-wecom/README.i18n.yaml delete mode 100644 packages/client/ui-wecom/README.md delete mode 100644 packages/client/ui-wecom/README.zh.md delete mode 100644 packages/client/ui-wecom/locale/de.json delete mode 100644 packages/client/ui-wecom/locale/en.json delete mode 100644 packages/client/ui-wecom/locale/es.json delete mode 100644 packages/client/ui-wecom/locale/fr.json delete mode 100644 packages/client/ui-wecom/locale/ja.json delete mode 100644 packages/client/ui-wecom/locale/pt.json delete mode 100644 packages/client/ui-wecom/locale/ru.json delete mode 100644 packages/client/ui-wecom/locale/zh.json delete mode 100644 packages/client/ui-wecom/package.json delete mode 100644 packages/client/ui-wecom/src/client/account.ts delete mode 100644 packages/client/ui-wecom/src/client/connection.ts delete mode 100644 packages/client/ui-wecom/src/client/index.ts delete mode 100644 packages/client/ui-wecom/src/index.ts delete mode 100644 packages/client/ui-wecom/tests/account.client.spec.ts delete mode 100644 packages/client/ui-wecom/tests/connection.client.spec.ts delete mode 100644 packages/client/ui-wecom/tests/mount.client.spec.ts delete mode 100644 packages/client/ui-wecom/tsconfig.json delete mode 100644 packages/client/ui-wecom/tsdown.config.ts rename packages/{client/ui-wecom/src/client => connector/wecom-cli/src}/locales.ts (78%) create mode 100644 packages/connector/wecom-cli/src/presentation.ts create mode 100644 packages/connector/wecom-cli/tests/presentation.spec.ts diff --git a/apps/web/tests/wecom-connection.e2e.ts b/apps/web/tests/wecom-connection.e2e.ts index f148befdf7..2dec5094bb 100644 --- a/apps/web/tests/wecom-connection.e2e.ts +++ b/apps/web/tests/wecom-connection.e2e.ts @@ -99,7 +99,7 @@ describe.skipIf(process.platform === 'win32')('web e2e: WeCom plugin authorizati await section.getByRole('button', { name: '连接企业微信', exact: true }).click() await section.getByRole('alert').waitFor({ timeout: 20_000 }) expect(await section.getAttribute('data-cli-account')).toBe('disconnected') - expect(await section.getByRole('alert').innerText()).toContain('auth-init · 退出码 4') + expect(await section.getByRole('alert').innerText()).toContain('auth-init · exit 4') expect(await section.innerText()).not.toContain('fixture-scode') await rm(join(binDir, 'init-fails')) diff --git a/docs/capability-seams.i18n.yaml b/docs/capability-seams.i18n.yaml index 9c97730489..adbf96a165 100644 --- a/docs/capability-seams.i18n.yaml +++ b/docs/capability-seams.i18n.yaml @@ -6,5 +6,5 @@ en: 41d772192075e133 zh: 5ef3da69b4de1d8a /capability-seams-and-core-services: - en: 652269c367ba90cc - zh: 654435e2e2abf10f + en: 142c63f63023927e + zh: 09ee50ea89ea3e1c diff --git a/docs/capability-seams.md b/docs/capability-seams.md index b3f4bec060..bc36b3c751 100644 --- a/docs/capability-seams.md +++ b/docs/capability-seams.md @@ -112,9 +112,6 @@ flowchart LR pkg_api_settings_controller["api-settings-controller"] svc_credentialsController["ctx.credentialsController
Host credential-surface Remote controller"] svc_settingsController["ctx.settingsController
Host settings-surface Remote controller"] - pkg_wecom_cli["wecom-cli"] - svc_wecom["ctx.wecom
WeCom wecom-cli authorization Remote"] - pkg_client_ui_wecom["client-ui-wecom"] pkg_api_workspace_files["api-workspace-files"] svc_workspaceFiles["ctx.workspaceFiles
Host workspace file Remote service"] pkg_workspace_changes["workspace-changes"] @@ -483,7 +480,6 @@ flowchart LR pkg_web_search_exa --> svc_web pkg_web_search_perplexity --> svc_web pkg_webhook --> svc_webhookRuntime - pkg_wecom_cli --> svc_wecom pkg_workflow --> svc_workflowEngine pkg_workflow_ptc --> svc_workflowEngine pkg_working_directory --> svc_workingDirectory @@ -641,7 +637,6 @@ flowchart LR svc_webServer --> pkg_client_hmr svc_webServer --> pkg_client_modules svc_webhookRuntime --> pkg_webhook_github - svc_wecom --> pkg_client_ui_wecom svc_workflowEngine --> pkg_tool_ralph svc_workflowEngine --> pkg_tool_workflow svc_workingDirectory --> pkg_sdk_jsonrpc_server @@ -695,7 +690,6 @@ flowchart LR | `ctx.jobController` | `core` | [`api-job-controller`](../packages/api/job-controller) | - | - | - | Streams one background job's observation record over the generated Remote namespace; the roster stays on the session control stream. | | `ctx.credentialsController` | `core` | [`api-settings-controller`](../packages/api/settings-controller) | - | - | - | Projects the credential-reference seam onto the generated Remote namespace: batch fan-out, view projection, and refusal mapping live here, not on the seam Definition. | | `ctx.settingsController` | `core` | [`api-settings-controller`](../packages/api/settings-controller) | - | - | - | Projects the user-settings seam onto the generated Remote namespace: the read is always redacted and every refusal is classified here, not on the seam Definition. | -| `ctx.wecom` | `service` | [`wecom-cli`](../packages/connector/wecom-cli) | - | [`client-ui-wecom`](../packages/client/ui-wecom) | - | Runs one Host-owned wecom-cli authorization check or QR-code connection at a time and streams the authorization view to the Plugins page. | | `ctx.workspaceFiles` | `core` | [`api-workspace-files`](../packages/api/workspace-files) | - | - | - | Serves stat, paged text, byte windows, directory listings, and the change feed for files inside a Session's workspace root, confined by lstat, containment, and a stat re-check. | | `ctx.workspaceChanges` | `core` | [`workspace-changes`](../packages/deliverables/workspace-changes) | - | - | - | Serves the summary each workspace/changes event announced and each listed file's turn-start and turn-end comparison, by Session and event sequence, until that Session is disposed; the log carries only the turn. | | `ctx.terminalController` | `core` | [`api-terminal-controller`](../packages/api/terminal-controller) | - | - | - | Owns user terminal processes, default shell resolution and bounded screen recovery through the subprocess provider and typed Remote transport. | diff --git a/docs/capability-seams.zh.md b/docs/capability-seams.zh.md index 9217579248..ed60ca7f45 100644 --- a/docs/capability-seams.zh.md +++ b/docs/capability-seams.zh.md @@ -114,9 +114,6 @@ flowchart LR pkg_api_settings_controller["api-settings-controller"] svc_credentialsController["ctx.credentialsController
Host credential-surface Remote controller"] svc_settingsController["ctx.settingsController
Host settings-surface Remote controller"] - pkg_wecom_cli["wecom-cli"] - svc_wecom["ctx.wecom
WeCom wecom-cli authorization Remote"] - pkg_client_ui_wecom["client-ui-wecom"] pkg_api_workspace_files["api-workspace-files"] svc_workspaceFiles["ctx.workspaceFiles
Host workspace file Remote service"] pkg_workspace_changes["workspace-changes"] @@ -485,7 +482,6 @@ flowchart LR pkg_web_search_exa --> svc_web pkg_web_search_perplexity --> svc_web pkg_webhook --> svc_webhookRuntime - pkg_wecom_cli --> svc_wecom pkg_workflow --> svc_workflowEngine pkg_workflow_ptc --> svc_workflowEngine pkg_working_directory --> svc_workingDirectory @@ -643,7 +639,6 @@ flowchart LR svc_webServer --> pkg_client_hmr svc_webServer --> pkg_client_modules svc_webhookRuntime --> pkg_webhook_github - svc_wecom --> pkg_client_ui_wecom svc_workflowEngine --> pkg_tool_ralph svc_workflowEngine --> pkg_tool_workflow svc_workingDirectory --> pkg_sdk_jsonrpc_server @@ -697,7 +692,6 @@ flowchart LR | `ctx.jobController` | `core` | [`api-job-controller`](../packages/api/job-controller) | - | - | - | 经生成的 Remote namespace 流式发送一个后台任务的观测 record;名册仍在会话控制流上。 | | `ctx.credentialsController` | `core` | [`api-settings-controller`](../packages/api/settings-controller) | - | - | - | 把凭据引用 seam 投影到生成的 Remote namespace:批量扇出、视图投影与拒绝映射都在这里,而不在 seam Definition 上。 | | `ctx.settingsController` | `core` | [`api-settings-controller`](../packages/api/settings-controller) | - | - | - | 把用户设置 seam 投影到生成的 Remote namespace:读取一律脱敏,所有拒绝在这里分类,而不在 seam Definition 上。 | -| `ctx.wecom` | `service` | [`wecom-cli`](../packages/connector/wecom-cli) | - | [`client-ui-wecom`](../packages/client/ui-wecom) | - | 同一时间在 Host 上运行一个 wecom-cli 授权检查或扫码连接,并把授权视图推送给插件页。 | | `ctx.workspaceFiles` | `core` | [`api-workspace-files`](../packages/api/workspace-files) | - | - | - | 为会话工作区根内的文件提供 stat、分页文本、字节窗口、目录列举与变更流,经 lstat、包含关系与 stat 重检限定。 | | `ctx.workspaceChanges` | `core` | [`workspace-changes`](../packages/deliverables/workspace-changes) | - | - | - | Serves the summary each workspace/changes event announced and each listed file's turn-start and turn-end comparison, by Session and event sequence, until that Session is disposed; the log carries only the turn. | | `ctx.terminalController` | `core` | [`api-terminal-controller`](../packages/api/terminal-controller) | - | - | - | 通过子进程提供方与类型化 Remote 传输管理用户终端进程、解析默认 shell,并恢复有界终端屏幕。 | diff --git a/docs/config-catalog.md b/docs/config-catalog.md index 13cded478b..1857483ee2 100644 --- a/docs/config-catalog.md +++ b/docs/config-catalog.md @@ -4770,7 +4770,7 @@ export interface Config { - `inject`: `skills` · `subprocess` · `systemPrompt` - `refs`: [`CliAccountConfig`](../packages/connector/cli-account/src/index.ts) · [`UpstreamSkillsConfig`](../packages/connector/upstream-skills/src/index.ts) -- `source`: [`packages/connector/wecom-cli/src/index.ts:32`](../packages/connector/wecom-cli/src/index.ts) +- `source`: [`packages/connector/wecom-cli/src/index.ts:31`](../packages/connector/wecom-cli/src/index.ts) ```ts config-catalog /** Where wecom-cli and the upstream guides come from, a command's deadline, and a download's time limit. */ @@ -4920,7 +4920,6 @@ These load from a `cordis.yml` entry with no `config:` block; they declare no co | `@deepseek-ai/dsh-client-ui-subagent` | — | [`packages/client/ui-subagent/src/index.ts`](../packages/client/ui-subagent/src/index.ts) | | `@deepseek-ai/dsh-client-ui-tool` | — | [`packages/client/ui-tool/src/index.ts`](../packages/client/ui-tool/src/index.ts) | | `@deepseek-ai/dsh-client-ui-user-questions` | — | [`packages/client/ui-user-questions/src/index.ts`](../packages/client/ui-user-questions/src/index.ts) | -| `@deepseek-ai/dsh-client-ui-wecom` | — | [`packages/client/ui-wecom/src/index.ts`](../packages/client/ui-wecom/src/index.ts) | | `@deepseek-ai/dsh-client-ui-workflow-run` | — | [`packages/client/ui-workflow-run/src/index.ts`](../packages/client/ui-workflow-run/src/index.ts) | | `@deepseek-ai/dsh-client-ui-workspace` | — | [`packages/client/ui-workspace/src/index.ts`](../packages/client/ui-workspace/src/index.ts) | | `@deepseek-ai/dsh-command-compact` | `commands` · `compaction` | [`packages/compaction/command-compact/src/index.ts`](../packages/compaction/command-compact/src/index.ts) | diff --git a/docs/config-catalog.zh.md b/docs/config-catalog.zh.md index 062a807cb8..33295558c3 100644 --- a/docs/config-catalog.zh.md +++ b/docs/config-catalog.zh.md @@ -4772,7 +4772,7 @@ export interface Config { - `inject`: `skills` · `subprocess` · `systemPrompt` - `refs`: [`CliAccountConfig`](../packages/connector/cli-account/src/index.ts) · [`UpstreamSkillsConfig`](../packages/connector/upstream-skills/src/index.ts) -- `source`: [`packages/connector/wecom-cli/src/index.ts:32`](../packages/connector/wecom-cli/src/index.ts) +- `source`: [`packages/connector/wecom-cli/src/index.ts:31`](../packages/connector/wecom-cli/src/index.ts) ```ts config-catalog /** Where wecom-cli and the upstream guides come from, a command's deadline, and a download's time limit. */ @@ -4922,7 +4922,6 @@ export interface Config { | `@deepseek-ai/dsh-client-ui-subagent` | — | [`packages/client/ui-subagent/src/index.ts`](../packages/client/ui-subagent/src/index.ts) | | `@deepseek-ai/dsh-client-ui-tool` | — | [`packages/client/ui-tool/src/index.ts`](../packages/client/ui-tool/src/index.ts) | | `@deepseek-ai/dsh-client-ui-user-questions` | — | [`packages/client/ui-user-questions/src/index.ts`](../packages/client/ui-user-questions/src/index.ts) | -| `@deepseek-ai/dsh-client-ui-wecom` | — | [`packages/client/ui-wecom/src/index.ts`](../packages/client/ui-wecom/src/index.ts) | | `@deepseek-ai/dsh-client-ui-workflow-run` | — | [`packages/client/ui-workflow-run/src/index.ts`](../packages/client/ui-workflow-run/src/index.ts) | | `@deepseek-ai/dsh-client-ui-workspace` | — | [`packages/client/ui-workspace/src/index.ts`](../packages/client/ui-workspace/src/index.ts) | | `@deepseek-ai/dsh-command-compact` | `commands` · `compaction` | [`packages/compaction/command-compact/src/index.ts`](../packages/compaction/command-compact/src/index.ts) | diff --git a/docs/module-graph.md b/docs/module-graph.md index f9e7a131d7..2b9d59d6b0 100644 --- a/docs/module-graph.md +++ b/docs/module-graph.md @@ -219,7 +219,6 @@ flowchart TD pkg_client_ui_tool["client-ui-tool"] pkg_client_ui_trajectory["client-ui-trajectory"] pkg_client_ui_user_questions["client-ui-user-questions"] - pkg_client_ui_wecom["client-ui-wecom"] pkg_client_ui_workflow_run["client-ui-workflow-run"] pkg_client_ui_workspace["client-ui-workspace"] pkg_client_web["client-web"] @@ -543,7 +542,6 @@ flowchart TD pkg_wecom_cli --> pkg_skill pkg_wecom_cli --> pkg_subprocess pkg_wecom_cli --> pkg_system_prompt - pkg_wecom_cli --> pkg_typert_protocol pkg_deliverable_file_references --> pkg_system_prompt pkg_experimental_computer_use_cua_driver_mcp --> pkg_computer_use pkg_experimental_forge_github --> pkg_experimental_forge @@ -1626,7 +1624,6 @@ flowchart TD | [`client-ui-tool`](../packages/client/ui-tool) | `client` | — | | [`client-ui-trajectory`](../packages/client/ui-trajectory) | `client` | — | | [`client-ui-user-questions`](../packages/client/ui-user-questions) | `client` | — | -| [`client-ui-wecom`](../packages/client/ui-wecom) | `client` | — | | [`client-ui-workflow-run`](../packages/client/ui-workflow-run) | `client` | — | | [`client-ui-workspace`](../packages/client/ui-workspace) | `client` | — | | [`client-web`](../packages/client/web) | `client` | — | @@ -1707,7 +1704,7 @@ flowchart TD | [`hmr`](../packages/boot/hmr) | `boot` | [`app-boot`](../packages/boot/app-boot), [`cmdline`](../packages/boot/cmdline) | | [`cli-account`](../packages/connector/cli-account) | `connector` | [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt) | | [`upstream-skills`](../packages/connector/upstream-skills) | `connector` | [`skill`](../packages/skill/skill) | -| [`wecom-cli`](../packages/connector/wecom-cli) | `connector` | [`skill`](../packages/skill/skill), [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt), [`typert-protocol`](../packages/typert/protocol) | +| [`wecom-cli`](../packages/connector/wecom-cli) | `connector` | [`skill`](../packages/skill/skill), [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt) | | [`deliverable-file-references`](../packages/deliverables/deliverable-file-references) | `deliverables` | [`system-prompt`](../packages/core/system-prompt) | | [`experimental-computer-use-cua-driver-mcp`](../packages/experimental/computer-use-cua-driver-mcp) | `experimental` | [`computer-use`](../packages/computer-use/computer-use) | | [`experimental-forge-github`](../packages/experimental/forge-github) | `experimental` | [`experimental-forge`](../packages/experimental/forge), [`subprocess`](../packages/subprocess/subprocess) | diff --git a/docs/module-graph.zh.md b/docs/module-graph.zh.md index 9b38bc391b..e115eae7be 100644 --- a/docs/module-graph.zh.md +++ b/docs/module-graph.zh.md @@ -221,7 +221,6 @@ flowchart TD pkg_client_ui_tool["client-ui-tool"] pkg_client_ui_trajectory["client-ui-trajectory"] pkg_client_ui_user_questions["client-ui-user-questions"] - pkg_client_ui_wecom["client-ui-wecom"] pkg_client_ui_workflow_run["client-ui-workflow-run"] pkg_client_ui_workspace["client-ui-workspace"] pkg_client_web["client-web"] @@ -545,7 +544,6 @@ flowchart TD pkg_wecom_cli --> pkg_skill pkg_wecom_cli --> pkg_subprocess pkg_wecom_cli --> pkg_system_prompt - pkg_wecom_cli --> pkg_typert_protocol pkg_deliverable_file_references --> pkg_system_prompt pkg_experimental_computer_use_cua_driver_mcp --> pkg_computer_use pkg_experimental_forge_github --> pkg_experimental_forge @@ -1628,7 +1626,6 @@ flowchart TD | [`client-ui-tool`](../packages/client/ui-tool) | `client` | — | | [`client-ui-trajectory`](../packages/client/ui-trajectory) | `client` | — | | [`client-ui-user-questions`](../packages/client/ui-user-questions) | `client` | — | -| [`client-ui-wecom`](../packages/client/ui-wecom) | `client` | — | | [`client-ui-workflow-run`](../packages/client/ui-workflow-run) | `client` | — | | [`client-ui-workspace`](../packages/client/ui-workspace) | `client` | — | | [`client-web`](../packages/client/web) | `client` | — | @@ -1709,7 +1706,7 @@ flowchart TD | [`hmr`](../packages/boot/hmr) | `boot` | [`app-boot`](../packages/boot/app-boot), [`cmdline`](../packages/boot/cmdline) | | [`cli-account`](../packages/connector/cli-account) | `connector` | [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt) | | [`upstream-skills`](../packages/connector/upstream-skills) | `connector` | [`skill`](../packages/skill/skill) | -| [`wecom-cli`](../packages/connector/wecom-cli) | `connector` | [`skill`](../packages/skill/skill), [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt), [`typert-protocol`](../packages/typert/protocol) | +| [`wecom-cli`](../packages/connector/wecom-cli) | `connector` | [`skill`](../packages/skill/skill), [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt) | | [`deliverable-file-references`](../packages/deliverables/deliverable-file-references) | `deliverables` | [`system-prompt`](../packages/core/system-prompt) | | [`experimental-computer-use-cua-driver-mcp`](../packages/experimental/computer-use-cua-driver-mcp) | `experimental` | [`computer-use`](../packages/computer-use/computer-use) | | [`experimental-forge-github`](../packages/experimental/forge-github) | `experimental` | [`experimental-forge`](../packages/experimental/forge), [`subprocess`](../packages/subprocess/subprocess) | diff --git a/docs/subsystems/credentials.md b/docs/subsystems/credentials.md index 1415658aab..2a084fb29f 100644 --- a/docs/subsystems/credentials.md +++ b/docs/subsystems/credentials.md @@ -367,44 +367,6 @@ abstract getDeviceIdentity(): Promise<{ deviceId?: string; userId?: AccountUserI Source: [`packages/credentials/deepseek-account/src/index.ts`](../../packages/credentials/deepseek-account/src/index.ts) - - -### `ctx.wecom` — `Wecom` - -Registers the CLI and skills, and owns the authorization operations the Plugins page drives. - -```ts cordis-catalog -/** - * Check the authorization again without changing it. - * @returns the operation identity. - * @throws while another operation runs. - */ -@Remote check(): CliOperationId - -/** - * Bind a bot through the CLI's QR-code page. - * @returns the operation identity. - * @throws while another operation runs. - */ -@Remote connect(): CliOperationId - -/** - * Cancel one operation while it waits for the QR-code scan, and wait for its command to exit. - * @param id - the operation to cancel; a finished one or another step is ignored. - * @returns after the operation settles, or at once when nothing is cancelled. - */ -@Remote cancel(id: CliOperationId): Promise - -/** - * Follow the authorization and its operations independently of any page; each new subscriber starts a check when none runs. - * @param signal - the Client's observation lifetime. - * @returns the current view, then each changed view. - */ -@Remote({ mode: 'stream' }) async *follow(signal: AbortSignal): AsyncIterable -``` - -Source: [`packages/connector/wecom-cli/src/index.ts`](../../packages/connector/wecom-cli/src/index.ts) - ### `authorization/*` events diff --git a/docs/subsystems/credentials.zh.md b/docs/subsystems/credentials.zh.md index c5c220f4a8..1e9221699a 100644 --- a/docs/subsystems/credentials.zh.md +++ b/docs/subsystems/credentials.zh.md @@ -367,44 +367,6 @@ abstract getDeviceIdentity(): Promise<{ deviceId?: string; userId?: AccountUserI Source: [`packages/credentials/deepseek-account/src/index.ts`](../../packages/credentials/deepseek-account/src/index.ts) - - -### `ctx.wecom` — `Wecom` - -Registers the CLI and skills, and owns the authorization operations the Plugins page drives. - -```ts cordis-catalog -/** - * Check the authorization again without changing it. - * @returns the operation identity. - * @throws while another operation runs. - */ -@Remote check(): CliOperationId - -/** - * Bind a bot through the CLI's QR-code page. - * @returns the operation identity. - * @throws while another operation runs. - */ -@Remote connect(): CliOperationId - -/** - * Cancel one operation while it waits for the QR-code scan, and wait for its command to exit. - * @param id - the operation to cancel; a finished one or another step is ignored. - * @returns after the operation settles, or at once when nothing is cancelled. - */ -@Remote cancel(id: CliOperationId): Promise - -/** - * Follow the authorization and its operations independently of any page; each new subscriber starts a check when none runs. - * @param signal - the Client's observation lifetime. - * @returns the current view, then each changed view. - */ -@Remote({ mode: 'stream' }) async *follow(signal: AbortSignal): AsyncIterable -``` - -Source: [`packages/connector/wecom-cli/src/index.ts`](../../packages/connector/wecom-cli/src/index.ts) - ### `authorization/*` events diff --git a/packages/client/README.i18n.yaml b/packages/client/README.i18n.yaml index f55129856c..78f41c59f6 100644 --- a/packages/client/README.i18n.yaml +++ b/packages/client/README.i18n.yaml @@ -15,8 +15,8 @@ en: 1eb35b015a6c423f zh: a8a3dceee2c9e943 /client-web-gui-browser-half/packages: - en: 7b52890c57cff148 - zh: 3415f2f43dbefab5 + en: 2ede6dd3fcdc7e1a + zh: 4fdec54af5566468 /client-web-gui-browser-half/related-documentation: en: d1d506e68fab7333 zh: 1a90fe6f3f8f24a9 diff --git a/packages/client/README.md b/packages/client/README.md index 739d7746ef..417c8e88bc 100644 --- a/packages/client/README.md +++ b/packages/client/README.md @@ -87,7 +87,6 @@ The kernel packages boot and serve the page; the UI feature packages present it. | [`ui-entry-customization/`](ui-entry-customization/README.md) | Adds region-local More menus that pin or unpin plugin launchers and start a plugin draft | — | | [`ui-plugin-market/`](ui-plugin-market/README.md) | Contributes the Discover tab to the Plugins page: browse market indexes and install their bundles | — | | [`ui-settings-plugin-inventory/`](ui-settings-plugin-inventory/README.md) | Contributes the read-only Host Loader inventory tab to Plugins settings | — | -| [`ui-wecom/`](ui-wecom/README.md) | Shows the WeCom plugin's authorization section, tag, activation guidance, and notices on the Plugins page | — | | [`ui-deliverables/`](ui-deliverables/README.md) | Produces the changed-files card with its comparison tabs, delivery cards, and clickable final-response file references | — | | [`ui-message-feedback/`](ui-message-feedback/README.md) | Provides message ratings and feedback dialogs opened from ratings, `/feedback`, or the Session Header menu | `ctx.feedbackUi` | | [`ui-directory-picker-browse/`](ui-directory-picker-browse/README.md) | In-app directory browsing surface for the workspace directory flow | — | diff --git a/packages/client/README.zh.md b/packages/client/README.zh.md index 4475f066a0..d0a9b4411a 100644 --- a/packages/client/README.zh.md +++ b/packages/client/README.zh.md @@ -87,7 +87,6 @@ kind: "package-group" | [`ui-entry-customization/`](ui-entry-customization/README.zh.md) | 添加分区域的“更多”菜单,固定或收起插件入口,并开始创建插件的草稿 | — | | [`ui-plugin-market/`](ui-plugin-market/README.zh.md) | 为“插件”页面贡献“发现”标签页:浏览市场索引并安装其中的组合包 | — | | [`ui-settings-plugin-inventory/`](ui-settings-plugin-inventory/README.zh.md) | 向「插件」设置贡献只读的 Host Loader 清单标签页 | — | -| [`ui-wecom/`](ui-wecom/README.zh.md) | 在插件页显示企业微信插件的授权区块、授权标签、开启引导和提示 | — | | [`ui-deliverables/`](ui-deliverables/README.zh.md) | 生成改动文件卡片及其对比 tab、交付文件卡片与可点击的最终响应文件引用 | — | | [`ui-message-feedback/`](ui-message-feedback/README.zh.md) | 提供消息赞踩,以及从赞踩、`/feedback` 或会话标题栏菜单打开的反馈弹窗 | `ctx.feedbackUi` | | [`ui-directory-picker-browse/`](ui-directory-picker-browse/README.zh.md) | 面向工作区目录流程的应用内目录浏览界面 | — | diff --git a/packages/client/ui-wecom/README.i18n.yaml b/packages/client/ui-wecom/README.i18n.yaml deleted file mode 100644 index 26a9ba4ee4..0000000000 --- a/packages/client/ui-wecom/README.i18n.yaml +++ /dev/null @@ -1,37 +0,0 @@ -# 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/client/ui-wecom/README.md -/: - en: d2d4dc03f7c17585 - zh: f37d2971f00a3f11 -/deepseek-ai-dsh-client-ui-wecom: - en: 5b48f91db583208c - zh: efb012d3e582f731 -/deepseek-ai-dsh-client-ui-wecom/summary: - en: 0c98e112d468008b - zh: 24b117f59bba6b59 -/deepseek-ai-dsh-client-ui-wecom/table-of-contents: - en: d152484eb41ac6b4 - zh: 09388d293f9be9cb -/deepseek-ai-dsh-client-ui-wecom/use-this-package: - en: 608dd75141235c10 - zh: 276b7f0a316bd9e4 -/deepseek-ai-dsh-client-ui-wecom/understand-the-implementation: - en: 4d1ca1f20067c805 - zh: 48c35875d453da56 -/deepseek-ai-dsh-client-ui-wecom/further-exploration: - en: 9e58fac71cb0cd05 - zh: 88bb4f524270a58b -/deepseek-ai-dsh-client-ui-wecom/model-experience: - en: 012af7ceabf177e8 - zh: 29099b3fb5fdbc0e -/deepseek-ai-dsh-client-ui-wecom/model-experience/kv-cache-effect: - en: ca75c51c89c2c9b0 - zh: 2064958b0754647e -/deepseek-ai-dsh-client-ui-wecom/known-limitations-and-deferred-work: - en: 648cb5a5d7607a2a - zh: 2bee0cfdb68760c1 -/deepseek-ai-dsh-client-ui-wecom/known-limitations-and-deferred-work/dev-note: - en: e67f633dc6fe7773 - zh: e88aeb617ffb74ea diff --git a/packages/client/ui-wecom/README.md b/packages/client/ui-wecom/README.md deleted file mode 100644 index 51033bc62f..0000000000 --- a/packages/client/ui-wecom/README.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -description: "The WeCom plugin's page on the Plugins page: authorize and check WeCom without starting a conversation." -kind: "package-reference" ---- - -# @deepseek-ai/dsh-client-ui-wecom - -English | [中文](README.zh.md) - -## Summary - -This package is the browser row of the [WeCom plugin](../../connector/wecom/README.md). While the plugin is on, its page on the **Plugins** page shows a **WeCom authorization** section where the user binds a bot by scanning a QR code without starting a conversation. Every operation runs on the Host through the [`wecom` Remote](../../connector/wecom-cli/README.md#account-operations); the page shows its progress and result. - -## 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 the [WeCom plugin bundle](../../connector/wecom/README.md), which inserts this package as the `ui-wecom` row. Opening the plugin's page checks the authorization, and a tag beside the title reads Not authorized, Authorizing, Authorized, Unconfirmed, or Not running. Switching the plugin on from the list while it is not authorized offers **Connect WeCom**, which opens the plugin's page and starts the connection. - -| Section state | Action | -|---|---| -| Checking authorization | None | -| Not authorized | **Connect WeCom** opens the WeCom QR-code page | -| Waiting for the QR code scan | The browser that clicked opens the QR-code page once; **Open QR code page** opens it again, and **Cancel** ends the connection | -| Confirming authorization | None; the Host checks the result of the scan | -| Authorized | None; WeCom is ready to use in conversations | -| Cannot read authorization right now | **Retry** checks the authorization again | -| WeCom component not running | The Host's `wecom` row did not load; the section points to the component list for the reason, and **Retry** subscribes to the Host again | - -Below the status, a row reports the WeCom skills while their guides are not in place: one row while the Host downloads them from GitHub, and after a failed download, one row with **Retry**, which checks the authorization and restarts the download without waiting for it. Neither row appears once the guides are in place. - -Leaving the page does not cancel a connection, which the Host owns. The QR-code page opens from the user's own click, because browsers block a window that opens long after it. A failed connection or check shows the general failure notice with the command and exit code; a failed page action shows a toast, and so does a finished connection. The section notes that the authorization is shared with `wecom-cli` in the computer's terminal and that turning the plugin off does not revoke it. - ------ - - -## Understand the implementation - -
-Implementation internals — click to expand - -The Host half, [`src/index.ts`](src/index.ts), is an empty `apply`, present only so the package holds the Loader row the client module system serves the browser half for. The browser half, [`src/client/index.ts`](src/client/index.ts), mounts the `wecom` Remote itself with `ctx.remote.$mount`, because the shipped Remote assembly does not include on-demand packages, and withdraws its authorization registration before unmounting it. - -The browser half registers the WeCom authorization with the [CLI account surfaces](../ui-cli-account/README.md) through `ctx.cliAccounts`, which follow the `wecom` Remote and render the section, tag, activation prompt, and toast for `@deepseek-ai/dsh-wecom`. A link opens only for the operation this browser started, only once, and only over HTTPS. [`src/client/connection.ts`](src/client/connection.ts) derives the authorization state from the Host's view alone, and [`src/client/account.ts`](src/client/account.ts) maps it to the section's buttons, guide download row, and failure guidance. The page's copy, including the keys the shared surfaces read, lives in this package's `wecom` dictionary. - -
- ------ - - -## Further Exploration - -- [WeCom plugin](../../connector/wecom/README.md) — the bundle that inserts this row and the Host row. -- [WeCom CLI and skills](../../connector/wecom-cli/README.md) — the Host row and the authorization operations this page drives. -- [CLI account surfaces](../ui-cli-account/README.md) — the registry that follows the Remote and renders this page's authorization. -- [ui-plugin-manager](../ui-plugin-manager/README.md) — the Plugins page and the bundle slots the account surfaces fill. - ------ - - -## Model Experience - -None, as the package is a browser-side page that registers no model surface. - -#### KV Cache effect - -None; this package neither assembles nor sends a provider request. - -## Known Limitations and Deferred Work - - - -- The page checks the authorization each time it subscribes and has no periodic check, so an authorization in the user's terminal appears after the page reopens. -- The page offers no disconnect, because `wecom-cli` cannot revoke the authorization. - - -### Dev Note - -
-Working context for maintainers — click to expand - -None. - -
diff --git a/packages/client/ui-wecom/README.zh.md b/packages/client/ui-wecom/README.zh.md deleted file mode 100644 index 022743e7d2..0000000000 --- a/packages/client/ui-wecom/README.zh.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -description: "企业微信插件在插件页上的页面:无需开始对话即可授权和检查企业微信。" -kind: "package-reference" ---- - -# @deepseek-ai/dsh-client-ui-wecom - -[English](README.md) | 中文 - -## 概述 - -本包是[企业微信插件](../../connector/wecom/README.zh.md)的浏览器行。插件开启时,它在**插件**页上的页面显示**企业微信授权**区块,用户无需开始对话即可在这里扫码绑定机器人。所有操作都通过 [`wecom` Remote](../../connector/wecom-cli/README.zh.md#account-operations) 在 Host 上运行;页面显示其进度和结果。 - -## 目录 - -- [使用本包](#use-this-package) -- [理解实现](#understand-the-implementation) -- [进一步探索](#further-exploration) -- [模型体验](#model-experience) -- [已知限制与延期工作](#known-limitations-and-deferred-work) -- [开发备注](#dev-note) - ------ - - -## 使用本包 - -安装[企业微信插件 bundle](../../connector/wecom/README.zh.md),它会把本包作为 `ui-wecom` 行插入。打开插件页面会检查授权,标题旁的标签显示未授权、授权中、已授权、待确认或未运行。在列表中开启插件且尚未授权时,会提示**连接企业微信**,点击后打开插件页面并开始连接。 - -| 区块状态 | 操作 | -|---|---| -| 正在检查授权 | 无 | -| 未授权 | **连接企业微信**打开企业微信扫码页面 | -| 等待扫码授权 | 点击的浏览器会把扫码页面打开一次;**打开扫码页面**再次打开,**取消**结束连接 | -| 正在确认授权 | 无;Host 检查扫码结果 | -| 已授权 | 无;可以在对话中使用企业微信 | -| 暂时无法读取授权状态 | **重试**重新检查授权 | -| 企业微信组件未运行 | Host 的 `wecom` 行没有加载;区块提示到组件列表查看原因,**重试**重新订阅 Host | - -状态下方有一行在子指南尚未就位时报告企业微信技能:Host 从 GitHub 下载时显示一行;下载失败后显示带 **重试** 的一行,它会检查授权,并在不等待的情况下重新开始下载。子指南就位后两行都不出现。 - -离开页面不会取消连接,连接由 Host 持有。扫码页面由用户自己的点击打开,因为浏览器会拦截点击很久之后才打开的窗口。连接或检查失败时显示通用失败提示,并附上命令和退出码;页面操作失败时显示提示,连接完成时也会显示提示。区块会说明该授权与这台电脑终端里的 `wecom-cli` 共用,关闭插件不会解除授权。 - ------ - - -## 理解实现 - -
-实现内部机制——点击展开 - -Host 半部 [`src/index.ts`](src/index.ts) 是空的 `apply`,只为让本包持有一行 Loader 条目,客户端模块系统据此提供浏览器半部。浏览器半部 [`src/client/index.ts`](src/client/index.ts) 用 `ctx.remote.$mount` 自行挂载 `wecom` Remote,因为随产品发布的 Remote 集合不包含按需安装的包;卸载 Remote 之前会先撤下授权注册。 - -浏览器半部通过 `ctx.cliAccounts` 把企业微信授权注册到 [CLI 账号界面](../ui-cli-account/README.zh.md),由它跟随 `wecom` Remote,并为 `@deepseek-ai/dsh-wecom` 渲染区块、标签、开启引导和提示。链接只为本浏览器发起的操作打开,每个链接只打开一次,且只打开 HTTPS 链接。[`src/client/connection.ts`](src/client/connection.ts) 只根据 Host 的视图推导授权状态,[`src/client/account.ts`](src/client/account.ts) 再把它映射为区块的按钮、技能下载行和失败建议。页面文案,包括共用界面读取的键,位于本包的 `wecom` 词典。 - -
- ------ - - -## 进一步探索 - -- [企业微信插件](../../connector/wecom/README.zh.md)——插入本行与 Host 行的 bundle。 -- [企业微信 CLI 与技能](../../connector/wecom-cli/README.zh.md)——Host 行,以及本页面发起的授权操作。 -- [CLI 账号界面](../ui-cli-account/README.zh.md)——跟随 Remote 并渲染本页面授权的注册表。 -- [ui-plugin-manager](../ui-plugin-manager/README.zh.md)——插件页,以及账号界面填入的 bundle slot。 - ------ - - -## 模型体验 - -无,因为本包是浏览器侧页面,不注册任何模型可见内容。 - -#### KV Cache 影响 - -无;本包既不组装也不发送 provider 请求。 - -## 已知限制与延期工作 - - - -- 页面每次订阅时检查授权,没有定期检查,因此在用户终端里完成的授权要在重新打开页面后才显示。 -- 页面不提供断开连接,因为 `wecom-cli` 无法撤销授权。 - - -### 开发备注 - -
-维护者工作上下文——点击展开 - -无。 - -
diff --git a/packages/client/ui-wecom/locale/de.json b/packages/client/ui-wecom/locale/de.json deleted file mode 100644 index 307cc5523b..0000000000 --- a/packages/client/ui-wecom/locale/de.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "meta": { - "title": "Seite des WeCom-Plugins", - "description": "Autorisieren und prüfen Sie WeCom auf der Seite „Plugins“." - } -} diff --git a/packages/client/ui-wecom/locale/en.json b/packages/client/ui-wecom/locale/en.json deleted file mode 100644 index 243226420e..0000000000 --- a/packages/client/ui-wecom/locale/en.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "meta": { - "title": "WeCom plugin page", - "description": "Authorize and check WeCom from the Plugins page." - } -} diff --git a/packages/client/ui-wecom/locale/es.json b/packages/client/ui-wecom/locale/es.json deleted file mode 100644 index edd18371b5..0000000000 --- a/packages/client/ui-wecom/locale/es.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "meta": { - "title": "Página del complemento de WeCom", - "description": "Autorice y compruebe WeCom desde la página Complementos." - } -} diff --git a/packages/client/ui-wecom/locale/fr.json b/packages/client/ui-wecom/locale/fr.json deleted file mode 100644 index 0077d9f8ea..0000000000 --- a/packages/client/ui-wecom/locale/fr.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "meta": { - "title": "Page du plugin WeCom", - "description": "Autorisez et vérifiez WeCom depuis la page Plugins." - } -} diff --git a/packages/client/ui-wecom/locale/ja.json b/packages/client/ui-wecom/locale/ja.json deleted file mode 100644 index f25091d3bc..0000000000 --- a/packages/client/ui-wecom/locale/ja.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "meta": { - "title": "WeCom プラグインページ", - "description": "「プラグイン」ページで WeCom の認可と確認を行います。" - } -} diff --git a/packages/client/ui-wecom/locale/pt.json b/packages/client/ui-wecom/locale/pt.json deleted file mode 100644 index bdeb59646c..0000000000 --- a/packages/client/ui-wecom/locale/pt.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "meta": { - "title": "Página do plugin do WeCom", - "description": "Autorize e verifique o WeCom na página Plug-ins." - } -} diff --git a/packages/client/ui-wecom/locale/ru.json b/packages/client/ui-wecom/locale/ru.json deleted file mode 100644 index 1a0742c95b..0000000000 --- a/packages/client/ui-wecom/locale/ru.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "meta": { - "title": "Страница плагина WeCom", - "description": "Авторизуйте и проверяйте WeCom на странице «Плагины»." - } -} diff --git a/packages/client/ui-wecom/locale/zh.json b/packages/client/ui-wecom/locale/zh.json deleted file mode 100644 index 38dce1a72c..0000000000 --- a/packages/client/ui-wecom/locale/zh.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "meta": { - "title": "企业微信插件页面", - "description": "在插件页授权和检查企业微信。" - } -} diff --git a/packages/client/ui-wecom/package.json b/packages/client/ui-wecom/package.json deleted file mode 100644 index a65a923e86..0000000000 --- a/packages/client/ui-wecom/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@deepseek-ai/dsh-client-ui-wecom", - "description": "WeCom plugin page: authorize and check WeCom from the Plugins page", - "version": "0.2.2-alpha.2", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/deepseek-ai/deepseek-harness.git", - "directory": "packages/client/ui-wecom" - }, - "type": "module", - "main": "lib/index.js", - "types": "lib/types/index.d.ts", - "exports": { - ".": { - "types": "./lib/types/index.d.ts", - "default": "./lib/index.js" - }, - "./src/*": "./src/*", - "./package.json": "./package.json", - "./locale/*.json": "./locale/*.json", - "./client": { - "types": "./lib/types/client/index.d.ts", - "default": "./lib/client.js" - } - }, - "files": [ - "locale/*.json", - "lib/index.js", - "lib/client.js", - "lib/types/**/*.d.ts" - ], - "license": "MIT", - "dsh": { - "client": { - "inject": [ - "@deepseek-ai/dsh-api-remotes", - "@deepseek-ai/dsh-client-locale", - "@deepseek-ai/dsh-client-ui-cli-account" - ], - "platform": "web" - } - }, - "scripts": { - "bundle": "tsdown", - "watch": "tsdown --watch" - }, - "peerDependencies": { - "@deepseek-ai/cordis": "workspace:~" - }, - "devDependencies": { - "@deepseek-ai/cordis": "workspace:~", - "@deepseek-ai/dsh-api-remotes": "workspace:*", - "@deepseek-ai/dsh-cli-account": "workspace:*", - "@deepseek-ai/dsh-client-locale": "workspace:*", - "@deepseek-ai/dsh-client-test-runtime": "workspace:*", - "@deepseek-ai/dsh-client-ui-cli-account": "workspace:*", - "@deepseek-ai/dsh-client-ui-slots": "workspace:*", - "@deepseek-ai/dsh-typert-protocol": "workspace:*", - "@deepseek-ai/dsh-upstream-skills": "workspace:*", - "@deepseek-ai/dsh-util-values": "workspace:*", - "@deepseek-ai/dsh-wecom-cli": "workspace:*" - } -} diff --git a/packages/client/ui-wecom/src/client/account.ts b/packages/client/ui-wecom/src/client/account.ts deleted file mode 100644 index 2080135b04..0000000000 --- a/packages/client/ui-wecom/src/client/account.ts +++ /dev/null @@ -1,65 +0,0 @@ -/** The WeCom authorization section: the buttons, guide download rows, and failure the Plugins page shows for each state. */ -import type { CliAccountAction, CliAccountDisplay, CliAccountNote, CliAccountPage } from '@deepseek-ai/dsh-client-ui-cli-account/client' -import type { TranslateNS } from '@deepseek-ai/dsh-client-ui-slots' -import type { UpstreamSkillsState } from '@deepseek-ai/dsh-upstream-skills/types' -import { assertNever } from '@deepseek-ai/dsh-util-values' -import { presentConnection, type ConnectionSnapshot } from './connection.ts' -import type { NS } from './locales.ts' - -type Translate = TranslateNS - -/** The page actions and the WeCom Remote operations the section's buttons call. */ -export interface WecomActions extends CliAccountPage { - /** Read the authorization again. */ - readonly check: () => void - /** Bind a bot through the QR-code page. */ - readonly connect: () => void -} - -/* jscpd:ignore-start -- CLI app plugins whose guides download report the same states, each from its own dictionary. */ -/** The row that reports guides that are not in place yet; a failed download offers a check, which restarts it. */ -function skillsNotes(skills: UpstreamSkillsState | undefined, t: Translate, check: () => void): CliAccountNote[] { - switch (skills) { - case undefined: - case 'installed': return [] - case 'downloading': return [{ text: t('skills.downloading') }] - case 'failed': return [{ text: t('skills.failed'), action: { label: t('action.retry'), onClick: check } }] - /* v8 ignore next -- closed skills state union */ - default: return assertNever(skills) - } -} -/* jscpd:ignore-end */ - -/** - * The authorization section for one page snapshot. - * @param snapshot - the Host's view and the page state. - * @param t - the WeCom dictionary. - * @param actions - what the section's buttons call. - * @returns the phase, step, buttons, detail, guide download row, and failure. - */ -export function presentAccount(snapshot: ConnectionSnapshot, t: Translate, actions: WecomActions): CliAccountDisplay { - const shown = presentConnection(snapshot) - const buttons: CliAccountAction[] = [] - let status: string | undefined - let detail: string | undefined - switch (shown.phase) { - case 'disconnected': buttons.push({ label: t('action.connect'), onClick: actions.connect, variant: 'primary' }); detail = t('detail.disconnected'); break - case 'unavailable': buttons.push({ label: t('action.retry'), onClick: actions.check }); detail = t('detail.unavailable'); break - case 'stopped': buttons.push({ label: t('action.retry'), onClick: actions.retry }); detail = t('detail.stopped'); break - case 'connected': detail = t('detail.connected'); break - case 'connecting': - status = t(`step.${shown.step}`) - if (shown.url !== undefined) { - buttons.push({ label: t('action.open'), onClick: actions.openAuthorization, variant: 'primary' }) - detail = t('detail.authorizing') - } - if (shown.cancellable) buttons.push({ label: t('action.cancel'), onClick: actions.cancel, variant: 'ghost' }) - break - case 'checking': break - } - return { - phase: shown.phase, status, actions: buttons, detail, - notes: skillsNotes(snapshot.view?.account.skills, t, actions.check), - failure: 'failed' in shown && shown.failed !== undefined ? { text: t('failed'), command: shown.failed.failure } : undefined, - } -} diff --git a/packages/client/ui-wecom/src/client/connection.ts b/packages/client/ui-wecom/src/client/connection.ts deleted file mode 100644 index efb9c68340..0000000000 --- a/packages/client/ui-wecom/src/client/connection.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** The WeCom authorization the Plugins page shows, derived from the Host's authorization view. */ -import type { CliAccountPhase, CliAccountSnapshot } from '@deepseek-ai/dsh-client-ui-cli-account/client' -import type { WecomState } from '@deepseek-ai/dsh-wecom-cli/types' -import { assertNever } from '@deepseek-ai/dsh-util-values' - -/** The npm package whose bundle page carries the authorization section. */ -export const WECOM_PACKAGE = '@deepseek-ai/dsh-wecom' - -/** The page's whole view: the Host's authorization view plus this browser's stream, pending action, and notice. */ -export type ConnectionSnapshot = CliAccountSnapshot - -/** What the user sees about the authorization, derived from the Host's view alone. */ -export type ConnectionPresentation = - | { readonly phase: Exclude; readonly failed: WecomState['result'] } - | { readonly phase: 'connecting'; readonly step: 'authorizing' | 'connecting'; readonly url: string | undefined; readonly cancellable: boolean } - -/** - * Derive the authorization the page shows from the Host's view. - * @param snapshot - the view as the Host last reported it, and whether the Host stream stopped. - * @returns the phase, with the operation in progress or the last failed result. - */ -export function presentConnection(snapshot: Pick): ConnectionPresentation { - const { view, stopped } = snapshot - if (stopped) return { phase: 'stopped', failed: undefined } - const operation = view?.operation - if (view === undefined || operation?.kind === 'check') return { phase: 'checking', failed: undefined } - if (operation !== undefined) { - return { - phase: 'connecting', - step: operation.phase === 'authorizing' ? 'authorizing' : 'connecting', - url: operation.authorizationUrl, - cancellable: operation.cancellable, - } - } - const failed = view.result?.outcome === 'failed' ? view.result : undefined - switch (view.account.state) { - case 'unchecked': return { phase: failed === undefined ? 'checking' : 'unavailable', failed } - case 'unauthorized': return { phase: 'disconnected', failed } - case 'authorized': return { phase: 'connected', failed } - /* v8 ignore next -- closed account state union */ - default: return assertNever(view.account.state) - } -} diff --git a/packages/client/ui-wecom/src/client/index.ts b/packages/client/ui-wecom/src/client/index.ts deleted file mode 100644 index f2f9b3704a..0000000000 --- a/packages/client/ui-wecom/src/client/index.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * WeCom plugin, browser half: registers the WeCom authorization with the - * Plugins page's CLI account surfaces. The Host's `wecom` Remote owns the - * operations; this half mounts that Remote itself because the on-demand - * package stays out of the shipped Remote assembly. - */ -import type { Context } from '@deepseek-ai/cordis' -import type {} from '@deepseek-ai/dsh-api-remotes/client' -import type {} from '@deepseek-ai/dsh-client-locale/client' -import type {} from '@deepseek-ai/dsh-client-ui-cli-account/client' -import wecomRemote from '@deepseek-ai/dsh-wecom-cli/remote' -import type { WecomState } from '@deepseek-ai/dsh-wecom-cli/types' -import { presentAccount } from './account.ts' -import { WECOM_PACKAGE } from './connection.ts' -import { de, en, es, fr, ja, NS, pt, ru, zh } from './locales.ts' - -/** Services the Remote mount and the account registration need. */ -export const inject = ['remote', 'locale', 'cliAccounts'] - -function registerUi(ctx: Context): void { - ctx.effect(() => ctx.locale.register(NS, { zh, en, ja, es, fr, de, ru, pt }), 'wecom: dictionaries') - const t = ctx.locale.bind(NS) - ctx.effect(() => ctx.cliAccounts.register({ - packageName: WECOM_PACKAGE, locale: NS, - follow: signal => ctx.remote.wecom.follow(signal), - cancel: id => ctx.remote.wecom.cancel(id), - notices: { connect: () => t('notice.connected') }, - present: (snapshot, page) => presentAccount(snapshot, t, { - ...page, - check: () => { page.start(() => ctx.remote.wecom.check()) }, - connect: () => { page.start(() => ctx.remote.wecom.connect()) }, - }), - }), 'wecom: account') -} - -/** - * Mount the WeCom Remote, then register the authorization for as long as the WeCom row is on. - * @param ctx - the browser plugin context. - * @returns a disposer that withdraws the authorization, then the Remote. - */ -export async function apply(ctx: Context): Promise<() => Promise> { - const disposeRemote = await ctx.remote.$mount(wecomRemote) - const ui = ctx.inject(['remote.wecom', 'locale', 'cliAccounts'], registerUi) - try { - await ui - } catch (error) { - await ui.dispose() - await disposeRemote() - throw error - } - return async () => { await ui.dispose(); await disposeRemote() } -} diff --git a/packages/client/ui-wecom/src/index.ts b/packages/client/ui-wecom/src/index.ts deleted file mode 100644 index 25e1f59143..0000000000 --- a/packages/client/ui-wecom/src/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -/** Host marker for the WeCom plugin page; the browser behavior is the client export. */ - -/** The page has no Host behavior; the `wecom-cli` row owns the authorization operations. */ -export function apply(): void {} diff --git a/packages/client/ui-wecom/tests/account.client.spec.ts b/packages/client/ui-wecom/tests/account.client.spec.ts deleted file mode 100644 index effee50477..0000000000 --- a/packages/client/ui-wecom/tests/account.client.spec.ts +++ /dev/null @@ -1,97 +0,0 @@ -/** The WeCom section offers each state's next step, the guide download rows, and failure guidance. */ -import { makeTranslate } from '@deepseek-ai/dsh-client-test-runtime' -import type { CliOperationId } from '@deepseek-ai/dsh-cli-account/types' -import type { CliAccountAction, CliAccountDisplay } from '@deepseek-ai/dsh-client-ui-cli-account/client' -import type { WecomState } from '@deepseek-ai/dsh-wecom-cli/types' -import { expect, it, vi } from 'vitest' -import { presentAccount, type WecomActions } from '../src/client/account.ts' -import type { ConnectionSnapshot } from '../src/client/connection.ts' -import { en, zh } from '../src/client/locales.ts' - -const OP = 'op' as CliOperationId -const QR = 'https://work.weixin.qq.com/qr' - -function fixture(copy: typeof zh = zh) { - const actions: WecomActions = { - start: vi.fn(), cancel: vi.fn(), openAuthorization: vi.fn(), retry: vi.fn(), check: vi.fn(), connect: vi.fn(), - } - const show = (view: WecomState | undefined, page: Partial = {}): CliAccountDisplay => - presentAccount({ view, linked: true, stopped: false, busy: false, notice: undefined, ...page }, makeTranslate(copy), actions) - return { actions, show } -} - -const labels = (display: CliAccountDisplay): string[] => (display.actions ?? []).map(action => action.label) -const action = (display: CliAccountDisplay, label: string): CliAccountAction => { - const found = [...display.actions ?? [], ...(display.notes ?? []).flatMap(note => note.action ?? [])].find(item => item.label === label) - if (found === undefined) throw new Error(`no ${label} action`) - return found -} - -it('offers the next step for each state', () => { - const b = fixture() - let shown = b.show({ account: { state: 'unauthorized', skills: 'installed' } }) - expect(shown).toMatchObject({ phase: 'disconnected', detail: zh['detail.disconnected'], notes: [] }) - action(shown, zh['action.connect']).onClick() - expect(b.actions.connect).toHaveBeenCalledOnce() - - shown = b.show({ account: { state: 'unauthorized', skills: 'installed' }, operation: { id: OP, kind: 'connect', phase: 'authorizing', cancellable: true } }) - expect(shown.status).toBe(zh['step.authorizing']) - expect(labels(shown)).toEqual([zh['action.cancel']]) - shown = b.show({ account: { state: 'unauthorized', skills: 'installed' }, operation: { id: OP, kind: 'connect', phase: 'authorizing', cancellable: true, authorizationUrl: QR } }) - expect(shown.detail).toBe(zh['detail.authorizing']) - action(shown, zh['action.open']).onClick() - action(shown, zh['action.cancel']).onClick() - expect(b.actions.openAuthorization).toHaveBeenCalledOnce() - expect(b.actions.cancel).toHaveBeenCalledOnce() - - shown = b.show({ account: { state: 'unauthorized', skills: 'installed' }, operation: { id: OP, kind: 'connect', phase: 'checking', cancellable: false } }) - expect(shown).toMatchObject({ status: zh['step.connecting'], actions: [] }) - - shown = b.show({ account: { state: 'authorized', skills: 'installed' } }) - expect(shown).toMatchObject({ phase: 'connected', detail: zh['detail.connected'], actions: [] }) - - shown = b.show(undefined) - expect(shown).toMatchObject({ phase: 'checking', actions: [], notes: [] }) -}) - -it.each([['zh', zh], ['en', en]] as const)('reports a failed connection with its command in %s', (_locale, copy) => { - const b = fixture(copy) - let shown = b.show({ account: { state: 'unauthorized', skills: 'installed' }, result: { id: OP, kind: 'connect', outcome: 'failed', failure: { command: 'auth-init', exitCode: 2 } } }) - expect(shown.failure).toEqual({ text: copy.failed, command: { command: 'auth-init', exitCode: 2 } }) - expect(labels(shown)).toEqual([copy['action.connect']]) - - shown = b.show({ account: { state: 'unauthorized', skills: 'installed' }, result: { id: OP, kind: 'connect', outcome: 'cancelled' } }) - expect(shown.failure).toBeUndefined() -}) - -it('retries an unreadable authorization by checking again', () => { - const b = fixture() - const shown = b.show({ account: { state: 'unchecked', skills: 'installed' }, result: { id: OP, kind: 'check', outcome: 'failed', failure: { command: 'auth-status', exitCode: 1 } } }) - expect(shown.detail).toBe(zh['detail.unavailable']) - action(shown, zh['action.retry']).onClick() - expect(b.actions.check).toHaveBeenCalledOnce() -}) - -it('reports guides that are downloading, and retries a failed download by checking again', () => { - const b = fixture() - expect(b.show({ account: { state: 'authorized', skills: 'downloading' } }).notes).toEqual([{ text: zh['skills.downloading'] }]) - const shown = b.show({ account: { state: 'authorized', skills: 'failed' } }) - expect(shown.notes?.map(note => note.text)).toEqual([zh['skills.failed']]) - action(shown, zh['action.retry']).onClick() - expect(b.actions.check).toHaveBeenCalledOnce() - expect(b.show({ account: { state: 'authorized', skills: 'installed' } }).notes).toEqual([]) -}) - -it('explains a stopped Host component and reopens the stream', () => { - const b = fixture() - const shown = b.show(undefined, { linked: false, stopped: true }) - expect(shown).toMatchObject({ phase: 'stopped', detail: zh['detail.stopped'] }) - action(shown, zh['action.retry']).onClick() - expect(b.actions.retry).toHaveBeenCalledOnce() -}) - -it('answers the activation prompt by connecting', () => { - const b = fixture() - const primary = b.show({ account: { state: 'unauthorized', skills: 'installed' } }).actions?.filter(item => item.variant === 'primary' && item.confirm === undefined) - expect(primary?.map(item => item.onClick)).toEqual([b.actions.connect]) -}) diff --git a/packages/client/ui-wecom/tests/connection.client.spec.ts b/packages/client/ui-wecom/tests/connection.client.spec.ts deleted file mode 100644 index fecbd9e345..0000000000 --- a/packages/client/ui-wecom/tests/connection.client.spec.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** The page derives the WeCom authorization from the Host's view. */ -import type { CliOperationId } from '@deepseek-ai/dsh-cli-account/types' -import type { WecomState } from '@deepseek-ai/dsh-wecom-cli/types' -import { expect, it } from 'vitest' -import { presentConnection, type ConnectionPresentation } from '../src/client/connection.ts' - -type Operation = NonNullable - -const OP = 'op-1' as CliOperationId -const UNAUTHORIZED: WecomState = { account: { state: 'unauthorized', skills: 'installed' } } -const FAILED_CONNECT: NonNullable = { id: OP, kind: 'connect', outcome: 'failed', failure: { command: 'auth-init', exitCode: 2 } } -const FAILED_CHECK: NonNullable = { id: OP, kind: 'check', outcome: 'failed', failure: { command: 'auth-status', exitCode: 1 } } - -function operation(kind: Operation['kind'], phase: Operation['phase'], cancellable = false, authorizationUrl?: string): Operation { - return { id: OP, kind, phase, cancellable, ...authorizationUrl === undefined ? {} : { authorizationUrl } } -} - -it.each<[string, WecomState | undefined, ConnectionPresentation]>([ - ['a stopped stream', UNAUTHORIZED, { phase: 'stopped', failed: undefined }], - ['no view yet', undefined, { phase: 'checking', failed: undefined }], - ['an unchecked authorization', { account: { state: 'unchecked', skills: 'installed' } }, { phase: 'checking', failed: undefined }], - ['a check', { ...UNAUTHORIZED, operation: operation('check', 'checking') }, { phase: 'checking', failed: undefined }], - ['a first check that failed', { account: { state: 'unchecked', skills: 'installed' }, result: FAILED_CHECK }, { phase: 'unavailable', failed: FAILED_CHECK }], - ['no authorization', UNAUTHORIZED, { phase: 'disconnected', failed: undefined }], - ['a failed connection', { ...UNAUTHORIZED, result: FAILED_CONNECT }, { phase: 'disconnected', failed: FAILED_CONNECT }], - ['a cancelled connection', { ...UNAUTHORIZED, result: { id: OP, kind: 'connect', outcome: 'cancelled' } }, { phase: 'disconnected', failed: undefined }], - ['an authorized bot', { account: { state: 'authorized', skills: 'installed' } }, { phase: 'connected', failed: undefined }], - ['a QR-code scan', { ...UNAUTHORIZED, operation: operation('connect', 'authorizing', true, 'https://work.weixin.qq.com/qr') }, - { phase: 'connecting', step: 'authorizing', url: 'https://work.weixin.qq.com/qr', cancellable: true }], - ['a confirmation', { ...UNAUTHORIZED, operation: operation('connect', 'checking') }, { phase: 'connecting', step: 'connecting', url: undefined, cancellable: false }], - ['cancellation', { ...UNAUTHORIZED, operation: operation('connect', 'cancelling') }, { phase: 'connecting', step: 'connecting', url: undefined, cancellable: false }], -])('presents %s', (name, view, expected) => { - expect(presentConnection({ view, stopped: name === 'a stopped stream' })).toEqual(expected) -}) diff --git a/packages/client/ui-wecom/tests/mount.client.spec.ts b/packages/client/ui-wecom/tests/mount.client.spec.ts deleted file mode 100644 index d4dfe2b7d4..0000000000 --- a/packages/client/ui-wecom/tests/mount.client.spec.ts +++ /dev/null @@ -1,87 +0,0 @@ -/** The browser half mounts the WeCom Remote, registers its authorization, and withdraws both on disposal or failure. */ -import { Context, Service } from '@deepseek-ai/cordis' -import type { CliOperationId } from '@deepseek-ai/dsh-cli-account/types' -import { LocaleRuntime } from '@deepseek-ai/dsh-client-locale/client' -import type { CliAccountPage, CliAccountRegistration } from '@deepseek-ai/dsh-client-ui-cli-account/client' -import type { TypertRemoteContribution } from '@deepseek-ai/dsh-typert-protocol' -import type { WecomState } from '@deepseek-ai/dsh-wecom-cli/types' -import { expect, it, vi } from 'vitest' -import { apply as hostApply } from '../src/index.ts' -import { en } from '../src/client/locales.ts' - -const REMOTE: TypertRemoteContribution = { package: '@deepseek-ai/dsh-wecom-cli', descriptors: [] } -const OP = 'op' as CliOperationId - -async function fixture() { - const ctx = new Context() - const unmount = vi.fn(async () => {}) - const remote = { follow: vi.fn(), cancel: vi.fn(), check: vi.fn(), connect: vi.fn() } - class Remote extends Service { - constructor() { super(ctx, 'remote') } - async $mount(contribution: TypertRemoteContribution) { - expect(contribution).toBe(REMOTE) - ctx.provide('remote.wecom', remote) - return unmount - } - } - new Remote() - const locale = new LocaleRuntime(ctx) - ctx.provide('locale', locale) - const unregister = vi.fn() - const register = vi.fn((_account: CliAccountRegistration) => unregister) - ctx.provide('cliAccounts', { register }) - vi.doMock('@deepseek-ai/dsh-wecom-cli/remote', () => ({ default: REMOTE })) - const browser = await import('../src/client/index.ts') - return { ctx, locale, unmount, remote, register, unregister, browser } -} - -it('registers the WeCom authorization over its Remote, then withdraws it and the Remote', async () => { - hostApply() - const b = await fixture() - try { - const fiber = b.ctx.plugin({ inject: [...b.browser.inject], apply: b.browser.apply }) - await fiber - b.locale.setLocale('en') - expect(b.register).toHaveBeenCalledOnce() - const account = b.register.mock.calls[0]![0] - expect(account).toMatchObject({ packageName: '@deepseek-ai/dsh-wecom', locale: 'wecom' }) - const signal = new AbortController().signal - void account.follow(signal) - void account.cancel(OP) - expect(b.remote.follow).toHaveBeenCalledWith(signal) - expect(b.remote.cancel).toHaveBeenCalledWith(OP) - expect(account.notices.connect?.()).toBe(en['notice.connected']) - expect(account.notices.check).toBeUndefined() - - const page: CliAccountPage = { start: vi.fn((call) => { void call() }), cancel: vi.fn(), openAuthorization: vi.fn(), retry: vi.fn() } - const snapshot = { linked: true, stopped: false, busy: false, notice: undefined } - const press = (view: WecomState, label: string) => { - const found = account.present({ ...snapshot, view }, page).actions?.find(item => item.label === label) - expect(found).toBeDefined() - found!.onClick() - } - press({ account: { state: 'unauthorized', skills: 'installed' } }, en['action.connect']) - press({ account: { state: 'unchecked', skills: 'installed' }, result: { id: OP, kind: 'check', outcome: 'failed' } }, en['action.retry']) - expect(b.remote.connect).toHaveBeenCalledOnce() - expect(b.remote.check).toHaveBeenCalledOnce() - - await fiber.dispose() - expect(b.unregister).toHaveBeenCalledOnce() - expect(b.unmount).toHaveBeenCalledOnce() - } finally { - await b.ctx.fiber.dispose() - vi.doUnmock('@deepseek-ai/dsh-wecom-cli/remote') - } -}) - -it('withdraws the Remote when the authorization fails to register', async () => { - const b = await fixture() - b.register.mockImplementationOnce(() => { throw new Error('register failed') }) - try { - await expect(b.browser.apply(b.ctx)).rejects.toThrow('register failed') - expect(b.unmount).toHaveBeenCalledOnce() - } finally { - await b.ctx.fiber.dispose() - vi.doUnmock('@deepseek-ai/dsh-wecom-cli/remote') - } -}) diff --git a/packages/client/ui-wecom/tsconfig.json b/packages/client/ui-wecom/tsconfig.json deleted file mode 100644 index fcf418f1e5..0000000000 --- a/packages/client/ui-wecom/tsconfig.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "extends": "../../../tsconfig.base.client.json", - "compilerOptions": { - "rootDir": "src", - "outDir": "lib/types" - }, - "include": [ - "src" - ], - "references": [ - { - "path": "../../../vendor/cordis" - }, - { - "path": "../../api/remotes/tsconfig.client.json" - }, - { - "path": "../locale/tsconfig.client.json" - }, - { - "path": "../ui-slots" - }, - { - "path": "../../connector/wecom-cli" - }, - { - "path": "../../typert/protocol" - }, - { - "path": "../../util/values" - }, - { - "path": "../ui-cli-account" - }, - { - "path": "../../connector/cli-account" - }, - { - "path": "../../connector/upstream-skills" - } - ] -} diff --git a/packages/client/ui-wecom/tsdown.config.ts b/packages/client/ui-wecom/tsdown.config.ts deleted file mode 100644 index 7aa03cebc1..0000000000 --- a/packages/client/ui-wecom/tsdown.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { clientBundle } from '../tsdown.client.ts' - -export default clientBundle(import.meta.dirname, ['lib/types/index.js']) diff --git a/packages/connector/README.i18n.yaml b/packages/connector/README.i18n.yaml index d398d8a16b..ee9d8b7f5b 100644 --- a/packages/connector/README.i18n.yaml +++ b/packages/connector/README.i18n.yaml @@ -15,8 +15,8 @@ en: 1eb35b015a6c423f zh: a8a3dceee2c9e943 /connector-application-plugins/packages: - en: e86da284cedd3a85 - zh: 197baaabb93cb573 + en: 9a65ef212b3e3735 + zh: eca66740d95e7dd3 /connector-application-plugins/related-documentation: en: 300b6c13c036c818 zh: fc6307f506d922dc diff --git a/packages/connector/README.md b/packages/connector/README.md index 63a2aa49ed..385c85b93d 100644 --- a/packages/connector/README.md +++ b/packages/connector/README.md @@ -27,7 +27,7 @@ Each application plugin in this group is installed into a profile to use one thi | [`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 | — | | [`upstream-skills/`](upstream-skills/README.md) | Downloads the upstream files that a CLI app plugin's entry skill indexes from a pinned commit of the vendor's GitHub repository, verifies and caches them, and lists the entry skill over them | — | | [`wecom/`](wecom/README.md) | Bundles the WeCom plugin: the `wecom-cli` Host row and its Plugins page row | — | -| [`wecom-cli/`](wecom-cli/README.md) | Installs the official `wecom-cli`, gives the model its absolute path, registers its skills, and runs the authorization operations the Plugins page drives | `ctx.wecom`; registers on `ctx.skills` and `ctx.systemPrompt` | +| [`wecom-cli/`](wecom-cli/README.md) | Installs the official `wecom-cli`, gives the model its absolute path, registers its skills, and runs the authorization operations the Plugins page drives | registers on `ctx.skills`, `ctx.systemPrompt`, and `ctx.cliAccounts` | ----- diff --git a/packages/connector/README.zh.md b/packages/connector/README.zh.md index d6730952e7..6840d6cc82 100644 --- a/packages/connector/README.zh.md +++ b/packages/connector/README.zh.md @@ -27,7 +27,7 @@ kind: "package-group" | [`cli-account/`](cli-account/README.zh.md) | 为 CLI 应用插件按绝对路径运行厂商 CLI,在运行时上下文中把这个路径告诉模型,并在 Host 上一次执行一个账号操作 | — | | [`upstream-skills/`](upstream-skills/README.zh.md) | 从厂商 GitHub 仓库的固定提交下载 CLI 应用插件入口技能索引的上游文件,校验并缓存,再在这些文件之上列出入口技能 | — | | [`wecom/`](wecom/README.zh.md) | 打包企业微信插件:`wecom-cli` Host 行及其插件页行 | — | -| [`wecom-cli/`](wecom-cli/README.zh.md) | 安装官方 `wecom-cli`,把它的绝对路径告诉模型,注册其 skill,并执行插件页发起的授权操作 | `ctx.wecom`;注册到 `ctx.skills` 与 `ctx.systemPrompt` | +| [`wecom-cli/`](wecom-cli/README.zh.md) | 安装官方 `wecom-cli`,把它的绝对路径告诉模型,注册其 skill,并执行插件页发起的授权操作 | 注册到 `ctx.skills`、`ctx.systemPrompt` 与 `ctx.cliAccounts` | ----- diff --git a/packages/connector/wecom-cli/README.i18n.yaml b/packages/connector/wecom-cli/README.i18n.yaml index 65f7ee983e..d2a7780afc 100644 --- a/packages/connector/wecom-cli/README.i18n.yaml +++ b/packages/connector/wecom-cli/README.i18n.yaml @@ -9,8 +9,8 @@ en: 64ada5d1b3aac000 zh: b18083c73eabe29a /deepseek-ai-dsh-wecom-cli/summary: - en: 0e209023d909e010 - zh: d29d697cff7f2bca + en: 30c9fd82d59ef2aa + zh: 959664c2d39a39ec /deepseek-ai-dsh-wecom-cli/table-of-contents: en: d152484eb41ac6b4 zh: 09388d293f9be9cb @@ -24,17 +24,17 @@ en: 6077d45144049e83 zh: 019d2529b8ea58eb /deepseek-ai-dsh-wecom-cli/use-this-package/authorization-operations: - en: 7d0ec689a89b609e - zh: 86ce0058d42f38b1 + en: 84d9c2d3d37f4ca1 + zh: 83b68b126b9a3312 /deepseek-ai-dsh-wecom-cli/use-this-package/configure: en: 1cd879ed3382e9a3 zh: 7ffab4fbfe74ac73 /deepseek-ai-dsh-wecom-cli/understand-the-implementation: - en: 1e91ac6e55d2aa1e - zh: 7c66c6858edd9048 + en: c432c01045d5123e + zh: 94d4ec3bfffe9dda /deepseek-ai-dsh-wecom-cli/further-exploration: - en: 981114250537a07b - zh: 03dbf4b65446bd89 + en: b7d4cf32c0f80b44 + zh: 0cb25e93120a593e /deepseek-ai-dsh-wecom-cli/model-experience: en: 215e7ba838619b7b zh: a311da3843709f90 diff --git a/packages/connector/wecom-cli/README.md b/packages/connector/wecom-cli/README.md index 2a7cd52004..ab964a87b6 100644 --- a/packages/connector/wecom-cli/README.md +++ b/packages/connector/wecom-cli/README.md @@ -9,7 +9,7 @@ English | [中文](README.zh.md) ## Summary -This package is the Host row of the [WeCom plugin](../wecom/README.md). It installs a pinned `@wecom/cli`, gives the model the absolute path of its `wecom-cli` executable in runtime context, and registers one `wecom` skill whose guides are the official WeCom skills, which it downloads from the WeCom CLI repository on GitHub. Its `wecom` Remote checks the CLI's authorization, binds a bot through the CLI's QR-code page, and cancels, for the [WeCom plugin page](../../client/ui-wecom/README.md). The CLI keeps the bot credentials in its default configuration, which the user's own terminal shares. Only macOS is supported. +This package is the Host row of the [WeCom plugin](../wecom/README.md). It installs a pinned `@wecom/cli`, gives the model the absolute path of its `wecom-cli` executable in runtime context, and registers one `wecom` skill whose guides are the official WeCom skills, which it downloads from the WeCom CLI repository on GitHub. It registers the authorization with the [CLI account registry](../../client/ui-cli-account/README.md), so the Plugins page shows it and can check it, bind a bot through the CLI's QR-code page, or cancel. The CLI keeps the bot credentials in its default configuration, which the user's own terminal shares. Only macOS is supported. ## Table of Contents @@ -40,16 +40,15 @@ Turning the row off in Plugin Manager withdraws the skills and the path from run ### Authorization operations -The `wecom` Remote serves the Plugins page. It runs at most one operation at a time, owned by the Host, so leaving the page does not cancel it. +The Plugins page drives these operations through the CLI account registry, which the Web app loads; a headless profile loads the plugin without it. The Host runs at most one operation at a time and owns it, so leaving the page does not cancel it. -| Method | Effect | +| Operation | Effect | |---|---| -| `follow(signal)` | Streams the authorization, the operation in progress, and the last result; each new follower starts a check when no operation runs | -| `check()` | Checks the authorization again; returns the operation id | -| `connect()` | Runs `auth init --noninteractive --no-browser`, waits for the user to scan the QR code, then checks that the CLI reports the bot authorized | -| `cancel(id)` | Cancels that operation while it waits for the scan and waits for its command to exit; other steps and a finished id are ignored | +| `check` | Checks the authorization again; each browser that opens the Web app starts one when no operation runs | +| `connect` | Runs `auth init --noninteractive --no-browser`, waits for the user to scan the QR code, then checks that the CLI reports the bot authorized | +| Cancel | Cancels the connection while it waits for the scan and waits for its command to exit; other steps are ignored | -A check runs `auth show --status`. The authorization reads `authorized` or `unauthorized` exactly as the CLI prints it; any other output or a nonzero exit fails the check and keeps the previous state. Each link that `auth init` prints alone on a stdout line is offered only when it is an HTTPS address on `work.weixin.qq.com`. Results report succeeded, cancelled, or failed. Failures include the command and the observed exit code in the Remote result and Host log; the CLI's output, which can carry the QR-code session, is omitted. `wecom-cli` has no command that revokes the authorization, so the plugin offers no disconnect. The process running DSH needs access to the CLI configuration; `DSH_HOME` does not relocate it. +A check runs `auth show --status`. The authorization reads `authorized` or `unauthorized` exactly as the CLI prints it; any other output or a nonzero exit fails the check and keeps the previous state. Each link that `auth init` prints alone on a stdout line is offered only when it is an HTTPS address on `work.weixin.qq.com`. Results report succeeded, cancelled, or failed. Failures show the command and the observed exit code on the page and in the Host log; the CLI's output, which can carry the QR-code session, is omitted. `wecom-cli` has no command that revokes the authorization, so the plugin offers no disconnect. The process running DSH needs access to the CLI configuration; `DSH_HOME` does not relocate it. ### Configure @@ -73,7 +72,7 @@ The generated [config catalog](../../../docs/config-catalog.md#deepseek-aidsh-we
Implementation internals — click to expand -[`src/index.ts`](src/index.ts) is a Remote service registered as `ctx.wecom`. It checks that `binDir/wecom-cli` (`wecom-cli.exe` on Windows) is executable, gives that path to the model in runtime context, and registers the `wecom` skill through the [upstream skills library](../upstream-skills/README.md) with the pin in [`src/skills.ts`](src/skills.ts). The account view carries the download state, and each check restarts a failed download without waiting for it. [`src/directory.ts`](src/directory.ts) resolves the platform package that `@wecom/cli` installs as an optional dependency. The [CLI account library](../cli-account/README.md) registers that runtime context, runs each command by the same path, and runs one operation at a time. [`src/account.ts`](src/account.ts) extends that runtime with the WeCom commands and reads the QR-code link from the output lines of `auth init`. Disposal cancels the active operation, aborts running commands, and settles after their processes exit. +[`src/index.ts`](src/index.ts) is a function plugin. It checks that `binDir/wecom-cli` (`wecom-cli.exe` on Windows) is executable, gives that path to the model in runtime context, and registers the `wecom` skill through the [upstream skills library](../upstream-skills/README.md) with the pin in [`src/skills.ts`](src/skills.ts). The account view carries the download state, and each check restarts a failed download without waiting for it. [`src/directory.ts`](src/directory.ts) resolves the platform package that `@wecom/cli` installs as an optional dependency. The [CLI account library](../cli-account/README.md) registers that runtime context, runs each command by the same path, and runs one operation at a time. [`src/account.ts`](src/account.ts) extends that runtime with the WeCom commands and reads the QR-code link from the output lines of `auth init`. [`src/presentation.ts`](src/presentation.ts) maps each view to the section the registry serves, in the text of [`src/locales.ts`](src/locales.ts). Disposal cancels the active operation, aborts running commands, and settles after their processes exit. [`skills/wecom/SKILL.md`](skills/wecom/SKILL.md) is the only skill this package carries: the DSH guidance, an index of the guides, and how to open them. Upstream publishes the guides only in its repository and not in the npm package, so the library downloads them; they are files under the skill's base directory, not separate skills. Where the DSH guidance and `wecomcli-shared` disagree, the entry tells the agent to follow the DSH guidance: it uses the plugin's `wecom-cli` instead of installing one, and sends authorization to the plugin page. References are ordinary files in each guide's directory. @@ -88,7 +87,7 @@ The generated [config catalog](../../../docs/config-catalog.md#deepseek-aidsh-we - [CLI account library](../cli-account/README.md) — command execution and account operations shared by CLI app plugins. - [Skills](../../../docs/subsystems/skills.md) — catalog publication, loading, and precedence. - [WeCom plugin](../wecom/README.md) — the bundle that inserts this row and the page row. -- [WeCom plugin page](../../client/ui-wecom/README.md) — the Plugins page that drives the authorization operations. +- [CLI account surfaces](../../client/ui-cli-account/README.md) — the registry and the Plugins page section that drive the authorization operations. ----- diff --git a/packages/connector/wecom-cli/README.zh.md b/packages/connector/wecom-cli/README.zh.md index 7caeb114a0..34f2c63318 100644 --- a/packages/connector/wecom-cli/README.zh.md +++ b/packages/connector/wecom-cli/README.zh.md @@ -9,7 +9,7 @@ kind: "package-reference" ## 概述 -本包是[企业微信插件](../wecom/README.zh.md)的 Host 行。它安装固定版本的 `@wecom/cli`,在运行时上下文中把其 `wecom-cli` 可执行文件的绝对路径告诉模型,并注册一个 `wecom` skill,其子指南是官方企业微信技能,从 GitHub 上的企业微信 CLI 仓库下载。它的 `wecom` Remote 为[企业微信插件页面](../../client/ui-wecom/README.zh.md)检查 CLI 的授权、通过 CLI 的扫码页面绑定机器人,以及取消操作。CLI 把机器人凭据保存在默认配置中,与用户自己的终端共用。仅支持 macOS。 +本包是[企业微信插件](../wecom/README.zh.md)的 Host 行。它安装固定版本的 `@wecom/cli`,在运行时上下文中把其 `wecom-cli` 可执行文件的绝对路径告诉模型,并注册一个 `wecom` skill,其子指南是官方企业微信技能,从 GitHub 上的企业微信 CLI 仓库下载。它把授权注册到 [CLI 账号注册表](../../client/ui-cli-account/README.zh.md),插件页因此能显示授权,并检查授权、通过 CLI 的扫码页面绑定机器人,或取消操作。CLI 把机器人凭据保存在默认配置中,与用户自己的终端共用。仅支持 macOS。 ## 目录 @@ -40,16 +40,15 @@ kind: "package-reference" ### 授权操作 -`wecom` Remote 为插件页服务。它同一时间最多运行一个由 Host 持有的操作,因此离开页面不会取消操作。 +插件页通过 CLI 账号注册表发起这些操作,注册表由 Web 应用加载;headless profile 加载插件时没有它。Host 同一时间最多运行一个操作并持有它,因此离开页面不会取消操作。 -| 方法 | 作用 | +| 操作 | 作用 | |---|---| -| `follow(signal)` | 推送授权状态、进行中的操作和最近一次结果;没有操作运行时,每个新订阅者会触发一次检查 | -| `check()` | 重新检查授权;返回操作 id | -| `connect()` | 运行 `auth init --noninteractive --no-browser`,等待用户扫码,然后确认 CLI 报告机器人已授权 | -| `cancel(id)` | 在等待扫码期间取消该操作并等待其命令退出;其他步骤和已结束的 id 会被忽略 | +| `check` | 重新检查授权;没有操作运行时,每个打开 Web 应用的浏览器会触发一次 | +| `connect` | 运行 `auth init --noninteractive --no-browser`,等待用户扫码,然后确认 CLI 报告机器人已授权 | +| 取消 | 在等待扫码期间取消连接并等待其命令退出;其他步骤会被忽略 | -检查运行 `auth show --status`。授权状态按 CLI 的输出原样读作 `authorized` 或 `unauthorized`;其他输出或非零退出码会使检查失败,并保留之前的状态。`auth init` 在 stdout 中单独一行打印的链接,只有是 `work.weixin.qq.com` 上的 HTTPS 地址时才会提供。结果分为成功、已取消和失败。失败时,Remote 结果和 Host 日志包含命令和观察到的退出码;CLI 的输出可能带有扫码会话,因此不保留。`wecom-cli` 没有撤销授权的命令,因此插件不提供断开连接。运行 DSH 的进程需要能访问 CLI 配置;`DSH_HOME` 不会迁移它。 +检查运行 `auth show --status`。授权状态按 CLI 的输出原样读作 `authorized` 或 `unauthorized`;其他输出或非零退出码会使检查失败,并保留之前的状态。`auth init` 在 stdout 中单独一行打印的链接,只有是 `work.weixin.qq.com` 上的 HTTPS 地址时才会提供。结果分为成功、已取消和失败。失败时,页面和 Host 日志显示命令和观察到的退出码;CLI 的输出可能带有扫码会话,因此不保留。`wecom-cli` 没有撤销授权的命令,因此插件不提供断开连接。运行 DSH 的进程需要能访问 CLI 配置;`DSH_HOME` 不会迁移它。 ### 配置 @@ -73,7 +72,7 @@ kind: "package-reference"
实现内部机制——点击展开 -[`src/index.ts`](src/index.ts) 是注册为 `ctx.wecom` 的 Remote 服务。它检查 `binDir/wecom-cli`(Windows 上为 `wecom-cli.exe`)是否可执行,在运行时上下文中把这个路径告诉模型,并通过[上游技能库](../upstream-skills/README.zh.md)按 [`src/skills.ts`](src/skills.ts) 中的固定信息注册 `wecom` skill。账号视图携带下载状态,每次检查都会在不等待的情况下重新开始失败的下载。[`src/directory.ts`](src/directory.ts) 定位 `@wecom/cli` 作为可选依赖安装的平台包。[CLI 账号库](../cli-account/README.zh.md)注册这条运行时上下文,按同一路径运行每条命令,并一次执行一个操作。[`src/account.ts`](src/account.ts) 在该运行时上实现企业微信的命令,并从 `auth init` 的输出行中读取扫码链接。释放时取消进行中的操作,中止正在运行的命令,并在这些进程退出后完成。 +[`src/index.ts`](src/index.ts) 是一个函数插件。它检查 `binDir/wecom-cli`(Windows 上为 `wecom-cli.exe`)是否可执行,在运行时上下文中把这个路径告诉模型,并通过[上游技能库](../upstream-skills/README.zh.md)按 [`src/skills.ts`](src/skills.ts) 中的固定信息注册 `wecom` skill。账号视图携带下载状态,每次检查都会在不等待的情况下重新开始失败的下载。[`src/directory.ts`](src/directory.ts) 定位 `@wecom/cli` 作为可选依赖安装的平台包。[CLI 账号库](../cli-account/README.zh.md)注册这条运行时上下文,按同一路径运行每条命令,并一次执行一个操作。[`src/account.ts`](src/account.ts) 在该运行时上实现企业微信的命令,并从 `auth init` 的输出行中读取扫码链接。[`src/presentation.ts`](src/presentation.ts) 用 [`src/locales.ts`](src/locales.ts) 中的文案,把每个视图映射为注册表提供的区块。释放时取消进行中的操作,中止正在运行的命令,并在这些进程退出后完成。 [`skills/wecom/SKILL.md`](skills/wecom/SKILL.md) 是本包携带的唯一 skill:DSH 指引、子指南索引和打开方式。上游只在其仓库发布这些子指南,没有放进 npm 包,因此由该库下载;它们是 skill 基础目录下的文件,不是独立的 skill。DSH 指引与 `wecomcli-shared` 不一致时,总入口要求 agent 以 DSH 指引为准:使用插件提供的 `wecom-cli`,不再自行安装,并把授权引导到插件页。引用文件是每个子指南目录中的普通文件。 @@ -88,7 +87,7 @@ kind: "package-reference" - [CLI 账号库](../cli-account/README.zh.md)——CLI 应用插件共用的命令执行与账号操作。 - [Skill](../../../docs/subsystems/skills.zh.md)——目录发布、加载与优先级。 - [企业微信插件](../wecom/README.zh.md)——插入本行与页面行的 bundle。 -- [企业微信插件页面](../../client/ui-wecom/README.zh.md)——发起授权操作的插件页。 +- [CLI 账号界面](../../client/ui-cli-account/README.zh.md)——发起授权操作的注册表和插件页区块。 ----- diff --git a/packages/connector/wecom-cli/package.json b/packages/connector/wecom-cli/package.json index aa813cdf2c..fc25fc7c43 100644 --- a/packages/connector/wecom-cli/package.json +++ b/packages/connector/wecom-cli/package.json @@ -18,17 +18,6 @@ "types": "./lib/types/index.d.ts", "default": "./lib/index.js" }, - "./remote": { - "types": "./lib/typert.remote-client.d.ts", - "default": "./lib/typert.remote-client.js" - }, - "./typert": { - "types": "./lib/typert.host.d.ts", - "default": "./lib/typert.host.js" - }, - "./types": { - "types": "./lib/types/types.d.ts" - }, "./locale/*.json": "./locale/*.json", "./src/*": "./src/*", "./package.json": "./package.json" @@ -37,11 +26,7 @@ "locale/*.json", "lib/index.js", "skills", - "lib/types/**/*.d.ts", - "lib/typert.host.js", - "lib/typert.host.d.ts", - "lib/typert.remote-client.js", - "lib/typert.remote-client.d.ts" + "lib/types/**/*.d.ts" ], "license": "MIT", "dependencies": { @@ -55,14 +40,13 @@ "@deepseek-ai/cordis": "workspace:~", "@deepseek-ai/dsh-skill": "workspace:*", "@deepseek-ai/dsh-subprocess": "workspace:*", - "@deepseek-ai/dsh-system-prompt": "workspace:*", - "@deepseek-ai/dsh-typert-protocol": "workspace:*" + "@deepseek-ai/dsh-system-prompt": "workspace:*" }, "devDependencies": { "@deepseek-ai/cordis": "workspace:~", + "@deepseek-ai/dsh-client-ui-cli-account": "workspace:*", "@deepseek-ai/dsh-skill": "workspace:*", "@deepseek-ai/dsh-subprocess": "workspace:*", - "@deepseek-ai/dsh-system-prompt": "workspace:*", - "@deepseek-ai/dsh-typert-protocol": "workspace:*" + "@deepseek-ai/dsh-system-prompt": "workspace:*" } } diff --git a/packages/connector/wecom-cli/src/index.ts b/packages/connector/wecom-cli/src/index.ts index d01825ce8f..3d4cd91568 100644 --- a/packages/connector/wecom-cli/src/index.ts +++ b/packages/connector/wecom-cli/src/index.ts @@ -1,96 +1,55 @@ /** * WeCom plugin: tells the model the managed wecom-cli's absolute path, registers - * the `wecom` skill over the upstream guides it downloads, and serves the Plugins - * page's authorization over Remote. The CLI's authorization is shared with the - * user's own terminal. + * the `wecom` skill over the upstream guides it downloads, and shows the + * authorization on the Plugins page through the CLI account registry. The CLI's + * authorization is shared with the user's own terminal. * @module @deepseek-ai/dsh-wecom-cli */ import type { Context } from '@deepseek-ai/cordis' import z from '@deepseek-ai/schemastery' -import { CliAccountConfig, CliCommandExecutor, registerCliPathContext, type CliOperationId } from '@deepseek-ai/dsh-cli-account' +import { CliAccountConfig, CliCommandExecutor, registerCliPathContext } from '@deepseek-ai/dsh-cli-account' import { registerUpstreamSkills, UpstreamSkillsConfig } from '@deepseek-ai/dsh-upstream-skills' -import { Remote, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol' +import type {} from '@deepseek-ai/dsh-client-ui-cli-account' import type {} from '@deepseek-ai/dsh-skill' import type {} from '@deepseek-ai/dsh-subprocess' import type {} from '@deepseek-ai/dsh-system-prompt' import { WecomAccount } from './account.ts' import { PROGRAM, resolveCliExecutable } from './directory.ts' +import { COPY, OPERATIONS, presentAccount, WECOM_PACKAGE } from './presentation.ts' import { ENTRY, WECOM_SKILLS } from './skills.ts' -import type { WecomState } from './types.ts' export type * from './types.ts' -declare module '@deepseek-ai/cordis' { - interface Context { - /** WeCom authorization for the Plugins page. */ - wecom: Wecom - } -} +/** Plugin name. */ +export const name = 'wecom' + +/** Services the CLI, its skills, and its runtime context need. */ +export const inject = ['skills', 'subprocess', 'systemPrompt'] /** Where wecom-cli and the upstream guides come from, a command's deadline, and a download's time limit. */ export type Config = CliAccountConfig & UpstreamSkillsConfig -/** Registers the CLI and skills, and owns the authorization operations the Plugins page drives. */ -export default class Wecom extends TypertRemoteService { - static inject = ['skills', 'subprocess', 'systemPrompt'] - static Config: z = z.intersect([CliAccountConfig, UpstreamSkillsConfig]) +/** Validates {@link Config}. */ +export const Config: z = z.intersect([CliAccountConfig, UpstreamSkillsConfig]) - private readonly account: WecomAccount - - /** - * @param ctx - Context carrying the skill registry, subprocess runtime, and system prompt. - * @param config - CLI location, command deadline, and where the upstream guides come from. - * @throws when `wecom-cli` is not executable or `skillsDir` is not a directory. - */ - constructor(ctx: Context, config: Config) { - super(ctx, 'wecom') - const executable = resolveCliExecutable(config.binDir) - registerCliPathContext(ctx, { name: 'wecom:cli', product: 'WeCom', program: PROGRAM, executable, scripts: true }) - const cli = new CliCommandExecutor(ctx.subprocess, { program: PROGRAM, executable, commandTimeoutMs: config.commandTimeoutMs }) - const skills = registerUpstreamSkills(ctx, { name: 'wecom', entry: ENTRY, set: WECOM_SKILLS, config }) - this.account = new WecomAccount(cli, ctx.logger, skills) - ctx.effect(() => () => this.account.dispose()) - ctx.effect(() => skills.watch((state) => { this.account.showSkills(state) })) - } - - /** - * Check the authorization again without changing it. - * @returns the operation identity. - * @throws while another operation runs. - */ - @Remote - check(): CliOperationId { - return this.account.start('check') - } - - /** - * Bind a bot through the CLI's QR-code page. - * @returns the operation identity. - * @throws while another operation runs. - */ - @Remote - connect(): CliOperationId { - return this.account.start('connect') - } - - /** - * Cancel one operation while it waits for the QR-code scan, and wait for its command to exit. - * @param id - the operation to cancel; a finished one or another step is ignored. - * @returns after the operation settles, or at once when nothing is cancelled. - */ - @Remote - cancel(id: CliOperationId): Promise { - return this.account.cancel(id) - } - - /** - * Follow the authorization and its operations independently of any page; each new subscriber starts a check when none runs. - * @param signal - the Client's observation lifetime. - * @returns the current view, then each changed view. - */ - @Remote({ mode: 'stream' }) - async *follow(signal: AbortSignal): AsyncIterable { - yield* this.account.follow(signal) - } +/** + * Register the CLI and its skills, and show the authorization on the Plugins page while the CLI account registry runs. + * @param ctx - Context carrying the skill registry, subprocess runtime, and system prompt. + * @param config - CLI location, command deadline, and where the upstream guides come from. + * @throws when `wecom-cli` is not executable or `skillsDir` is not a directory. + */ +export function apply(ctx: Context, config: Config): void { + const executable = resolveCliExecutable(config.binDir) + registerCliPathContext(ctx, { name: 'wecom:cli', product: 'WeCom', program: PROGRAM, executable, scripts: true }) + const cli = new CliCommandExecutor(ctx.subprocess, { program: PROGRAM, executable, commandTimeoutMs: config.commandTimeoutMs }) + const skills = registerUpstreamSkills(ctx, { name: 'wecom', entry: ENTRY, set: WECOM_SKILLS, config }) + const account = new WecomAccount(cli, ctx.logger, skills) + ctx.effect(() => () => account.dispose(), 'wecom: account') + ctx.effect(() => skills.watch((state) => { account.showSkills(state) }), 'wecom: guides') + ctx.inject(['cliAccounts'], (scope) => { + scope.effect(() => scope.cliAccounts.register({ + packageName: WECOM_PACKAGE, source: account, operations: OPERATIONS, copy: COPY, present: presentAccount, + }), 'wecom: Plugins page authorization') + }) } diff --git a/packages/client/ui-wecom/src/client/locales.ts b/packages/connector/wecom-cli/src/locales.ts similarity index 78% rename from packages/client/ui-wecom/src/client/locales.ts rename to packages/connector/wecom-cli/src/locales.ts index 13705f6280..db28d264de 100644 --- a/packages/client/ui-wecom/src/client/locales.ts +++ b/packages/connector/wecom-cli/src/locales.ts @@ -1,8 +1,5 @@ -/** Locale-owned copy for the WeCom plugin's authorization on the Plugins page. */ -import type {} from '@deepseek-ai/dsh-client-ui-slots' - -/** Dictionary namespace for every WeCom authorization surface. */ -export const NS = 'wecom' +/** The WeCom text the Plugins page shows; the browser resolves it in its active language. */ +import { accountText } from '@deepseek-ai/dsh-cli-account' /** Chinese dictionary and key source. */ export const zh = { @@ -11,20 +8,16 @@ export const zh = { 'status.disconnected': '未授权', 'status.unavailable': '暂时无法读取授权状态', 'status.connected': '已授权', - 'status.stopped': '企业微信组件未运行', 'step.authorizing': '等待扫码授权', 'step.connecting': '正在确认授权', 'detail.disconnected': '用企业微信扫码绑定一个智能机器人。授权后,可以在对话中通过这个机器人使用企业微信的文档、日程、会议、待办和消息等功能。', 'detail.unavailable': '没能读取 wecom-cli 的授权状态,可以稍后重试。', - 'detail.stopped': '“企业微信 CLI 与技能”组件没有运行,可以在下方组件列表查看原因,处理后重试。', 'detail.connected': '可以在对话中直接请 Agent 使用企业微信。', 'detail.authorizing': '在打开的页面中用企业微信扫码并确认,完成后回到这里查看结果。页面没有打开时,点击“打开扫码页面”。', 'skills.downloading': '正在从 GitHub 下载企业微信技能,下载完成后即可在对话中使用。', 'skills.failed': '企业微信技能没能下载,Agent 暂时用不了企业微信的子指南。请确认这台电脑能访问 GitHub,然后重试。', hint: '授权与这台电脑终端里的 wecom-cli 共用;关闭插件不会解除授权。', failed: '操作未完成,请重试', - 'failure.details': '排障信息:{details}', - 'failure.exitCode': '退出码 {code}', 'action.connect': '连接企业微信', 'action.open': '打开扫码页面', 'action.cancel': '取消', @@ -33,39 +26,31 @@ export const zh = { 'badge.disconnected': '未授权', 'badge.connecting': '授权中', 'badge.unavailable': '待确认', - 'badge.stopped': '未运行', 'activation.title': '连接企业微信', 'activation.body': '企业微信插件已开启。扫码授权后,就可以在对话中使用它。', - 'activation.later': '稍后', 'notice.connected': '企业微信已授权', - 'notice.action-failed': '操作未完成,请重试', - close: '关闭', } -/** Every key the WeCom authorization surfaces translate. */ -export type WecomKey = keyof typeof zh +/** Every key of the WeCom text. */ +export type WecomTextKey = keyof typeof zh /** English dictionary. */ -export const en: Record = { +export const en: Record = { 'section.title': 'WeCom authorization', 'status.checking': 'Checking authorization', 'status.disconnected': 'Not authorized', 'status.unavailable': 'Cannot read authorization right now', 'status.connected': 'Authorized', - 'status.stopped': 'WeCom component not running', 'step.authorizing': 'Waiting for the QR code scan', 'step.connecting': 'Confirming authorization', 'detail.disconnected': 'Scan a QR code with WeCom to bind a smart bot. After that, you can use WeCom docs, calendar, meetings, to-dos, messages, and other features through this bot in conversations.', 'detail.unavailable': 'The wecom-cli authorization could not be read. Try again later.', - 'detail.stopped': 'The WeCom CLI and skills component is not running. See the component list below for the reason, then retry.', 'detail.connected': 'Ask the agent to use WeCom directly in a conversation.', 'detail.authorizing': 'Scan the QR code with WeCom on the page that opened and confirm, then come back here to see the result. If the page did not open, select Open QR code page.', 'skills.downloading': 'Downloading the WeCom skills from GitHub. They become available in conversations when the download finishes.', 'skills.failed': 'The WeCom skills could not be downloaded, so the agent cannot use the WeCom guides yet. Check that this computer can reach GitHub, then retry.', hint: 'The authorization is shared with wecom-cli in this computer\'s terminal. Turning the plugin off does not revoke it.', failed: 'The action did not finish. Try again.', - 'failure.details': 'Diagnostic: {details}', - 'failure.exitCode': 'Exit code {code}', 'action.connect': 'Connect WeCom', 'action.open': 'Open QR code page', 'action.cancel': 'Cancel', @@ -74,36 +59,28 @@ export const en: Record = { 'badge.disconnected': 'Not authorized', 'badge.connecting': 'Authorizing', 'badge.unavailable': 'Unconfirmed', - 'badge.stopped': 'Not running', 'activation.title': 'Connect WeCom', 'activation.body': 'The WeCom plugin is on. Scan a QR code to authorize it, then use it in conversations.', - 'activation.later': 'Later', 'notice.connected': 'WeCom authorized', - 'notice.action-failed': 'The action did not finish. Try again.', - close: 'Close', } /** Japanese dictionary. */ -export const ja: Record = { +export const ja: Record = { 'section.title': 'WeCom の認可', 'status.checking': '認可を確認中', 'status.disconnected': '未認可', 'status.unavailable': '現在認可状態を読み取れません', 'status.connected': '認可済み', - 'status.stopped': 'WeCom コンポーネントが稼働していません', 'step.authorizing': 'QR コードのスキャン待ち', 'step.connecting': '認可を確定中', 'detail.disconnected': 'WeCom で QR コードをスキャンしてスマートボットを紐付けます。その後、会話の中でこのボットを通じて WeCom のドキュメント、カレンダー、会議、ToDo、メッセージなどの機能を使用できます。', 'detail.unavailable': 'wecom-cli の認可状態を読み取れませんでした。しばらくしてから再試行してください。', - 'detail.stopped': '「WeCom CLI とスキル」コンポーネントが稼働していません。下のコンポーネント一覧で理由を確認し、対処してから再試行してください。', 'detail.connected': '会話の中でエージェントに WeCom の使用を直接依頼できます。', 'detail.authorizing': '開いたページで WeCom を使って QR コードをスキャンして確定し、完了したらここに戻って結果を確認してください。ページが開かない場合は、「QR コードページを開く」を選択してください。', 'skills.downloading': 'GitHub から WeCom のスキルをダウンロードしています。ダウンロードが完了すると、会話の中で使用できます。', 'skills.failed': 'WeCom のスキルをダウンロードできなかったため、エージェントはまだ WeCom のガイドを使用できません。このコンピューターから GitHub にアクセスできることを確認してから、再試行してください。', hint: '認可は、このコンピューターのターミナルにある wecom-cli と共有されます。プラグインをオフにしても認可は解除されません。', failed: '操作が完了しませんでした。もう一度お試しください。', - 'failure.details': '診断情報:{details}', - 'failure.exitCode': '終了コード {code}', 'action.connect': 'WeCom を接続', 'action.open': 'QR コードページを開く', 'action.cancel': 'キャンセル', @@ -112,36 +89,28 @@ export const ja: Record = { 'badge.disconnected': '未認可', 'badge.connecting': '認可中', 'badge.unavailable': '未確認', - 'badge.stopped': '未稼働', 'activation.title': 'WeCom を接続', 'activation.body': 'WeCom プラグインがオンになりました。QR コードをスキャンして認可すると、会話の中で使用できます。', - 'activation.later': '後で', 'notice.connected': 'WeCom を認可しました', - 'notice.action-failed': '操作が完了しませんでした。もう一度お試しください。', - close: '閉じる', } /** Spanish dictionary. */ -export const es: Record = { +export const es: Record = { 'section.title': 'Autorización de WeCom', 'status.checking': 'Comprobando la autorización', 'status.disconnected': 'Sin autorizar', 'status.unavailable': 'No se puede leer la autorización en este momento', 'status.connected': 'Autorizado', - 'status.stopped': 'El componente de WeCom no está en ejecución', 'step.authorizing': 'Esperando el escaneo del código QR', 'step.connecting': 'Confirmando la autorización', 'detail.disconnected': 'Escanee un código QR con WeCom para vincular un bot inteligente. Después, podrá usar en las conversaciones, a través de este bot, los documentos, el calendario, las reuniones, las tareas pendientes, los mensajes y otras funciones de WeCom.', 'detail.unavailable': 'No se pudo leer la autorización de wecom-cli. Inténtelo de nuevo más tarde.', - 'detail.stopped': 'El componente “CLI y habilidades de WeCom” no está en ejecución. Consulte el motivo en la lista de componentes de abajo y vuelva a intentarlo.', 'detail.connected': 'Pida al agente que use WeCom directamente en una conversación.', 'detail.authorizing': 'Escanee el código QR con WeCom en la página que se abrió y confirme; luego vuelva aquí para ver el resultado. Si la página no se abrió, seleccione “Abrir página del código QR”.', 'skills.downloading': 'Descargando las habilidades de WeCom desde GitHub. Estarán disponibles en las conversaciones cuando termine la descarga.', 'skills.failed': 'No se pudieron descargar las habilidades de WeCom, por lo que el agente aún no puede usar las guías de WeCom. Compruebe que esta computadora puede acceder a GitHub y vuelva a intentarlo.', hint: 'La autorización se comparte con wecom-cli en la terminal de esta computadora. Desactivar el complemento no la revoca.', failed: 'La acción no se completó. Inténtelo de nuevo.', - 'failure.details': 'Diagnóstico: {details}', - 'failure.exitCode': 'Código de salida {code}', 'action.connect': 'Conectar WeCom', 'action.open': 'Abrir página del código QR', 'action.cancel': 'Cancelar', @@ -150,36 +119,28 @@ export const es: Record = { 'badge.disconnected': 'Sin autorizar', 'badge.connecting': 'Autorizando', 'badge.unavailable': 'Sin confirmar', - 'badge.stopped': 'No está en ejecución', 'activation.title': 'Conectar WeCom', 'activation.body': 'El complemento de WeCom está activado. Escanee un código QR para autorizarlo y luego úselo en las conversaciones.', - 'activation.later': 'Más tarde', 'notice.connected': 'WeCom autorizado', - 'notice.action-failed': 'La acción no se completó. Inténtelo de nuevo.', - close: 'Cerrar', } /** French dictionary. */ -export const fr: Record = { +export const fr: Record = { 'section.title': 'Autorisation WeCom', 'status.checking': 'Vérification de l’autorisation', 'status.disconnected': 'Non autorisé', 'status.unavailable': 'Impossible de lire l’autorisation pour le moment', 'status.connected': 'Autorisé', - 'status.stopped': 'Le composant WeCom ne fonctionne pas', 'step.authorizing': 'En attente du scan du code QR', 'step.connecting': 'Confirmation de l’autorisation', 'detail.disconnected': 'Scannez un code QR avec WeCom pour lier un bot intelligent. Vous pourrez ensuite utiliser dans les conversations, via ce bot, les documents, le calendrier, les réunions, les tâches, les messages et les autres fonctionnalités de WeCom.', 'detail.unavailable': 'Impossible de lire l’autorisation de wecom-cli. Réessayez plus tard.', - 'detail.stopped': 'Le composant « CLI et compétences WeCom » ne fonctionne pas. Consultez la raison dans la liste des composants ci-dessous, puis réessayez.', 'detail.connected': 'Demandez à l’agent d’utiliser WeCom directement dans une conversation.', 'detail.authorizing': 'Scannez le code QR avec WeCom sur la page qui s’est ouverte et confirmez, puis revenez ici pour voir le résultat. Si la page ne s’est pas ouverte, sélectionnez « Ouvrir la page du code QR ».', 'skills.downloading': 'Téléchargement des compétences WeCom depuis GitHub. Elles seront disponibles dans les conversations une fois le téléchargement terminé.', 'skills.failed': 'Les compétences WeCom n’ont pas pu être téléchargées : l’agent ne peut donc pas encore utiliser les guides WeCom. Vérifiez que cet ordinateur peut accéder à GitHub, puis réessayez.', hint: 'L’autorisation est partagée avec wecom-cli dans le terminal de cet ordinateur. Désactiver le plugin ne la révoque pas.', failed: 'L’action n’a pas abouti. Réessayez.', - 'failure.details': 'Diagnostic : {details}', - 'failure.exitCode': 'Code de sortie {code}', 'action.connect': 'Connecter WeCom', 'action.open': 'Ouvrir la page du code QR', 'action.cancel': 'Annuler', @@ -188,36 +149,28 @@ export const fr: Record = { 'badge.disconnected': 'Non autorisé', 'badge.connecting': 'Autorisation en cours', 'badge.unavailable': 'Non confirmé', - 'badge.stopped': 'Ne fonctionne pas', 'activation.title': 'Connecter WeCom', 'activation.body': 'Le plugin WeCom est activé. Scannez un code QR pour l’autoriser, puis utilisez-le dans les conversations.', - 'activation.later': 'Plus tard', 'notice.connected': 'WeCom autorisé', - 'notice.action-failed': 'L’action n’a pas abouti. Réessayez.', - close: 'Fermer', } /** German dictionary. */ -export const de: Record = { +export const de: Record = { 'section.title': 'WeCom-Autorisierung', 'status.checking': 'Autorisierung wird geprüft', 'status.disconnected': 'Nicht autorisiert', 'status.unavailable': 'Autorisierung kann gerade nicht gelesen werden', 'status.connected': 'Autorisiert', - 'status.stopped': 'WeCom-Komponente läuft nicht', 'step.authorizing': 'Warten auf das Scannen des QR-Codes', 'step.connecting': 'Autorisierung wird bestätigt', 'detail.disconnected': 'Scannen Sie mit WeCom einen QR-Code, um einen smarten Bot zu verknüpfen. Danach können Sie über diesen Bot Dokumente, Kalender, Besprechungen, Aufgaben, Nachrichten und weitere Funktionen von WeCom in Unterhaltungen verwenden.', 'detail.unavailable': 'Die Autorisierung von wecom-cli konnte nicht gelesen werden. Versuchen Sie es später erneut.', - 'detail.stopped': 'Die Komponente „WeCom-CLI und Fertigkeiten“ läuft nicht. Den Grund sehen Sie in der Komponentenliste unten; versuchen Sie es danach erneut.', 'detail.connected': 'Bitten Sie den Agenten, WeCom direkt in einer Unterhaltung zu verwenden.', 'detail.authorizing': 'Scannen Sie auf der geöffneten Seite den QR-Code mit WeCom, bestätigen Sie und kehren Sie dann hierher zurück, um das Ergebnis zu sehen. Falls sich die Seite nicht geöffnet hat, wählen Sie „QR-Code-Seite öffnen“.', 'skills.downloading': 'Die Fertigkeiten von WeCom werden von GitHub heruntergeladen. Sie stehen in Unterhaltungen zur Verfügung, sobald der Download abgeschlossen ist.', 'skills.failed': 'Die Fertigkeiten von WeCom konnten nicht heruntergeladen werden, daher kann der Agent die WeCom-Anleitungen noch nicht verwenden. Prüfen Sie, ob dieser Computer GitHub erreichen kann, und versuchen Sie es dann erneut.', hint: 'Die Autorisierung wird mit wecom-cli im Terminal dieses Computers geteilt. Wenn Sie das Plugin deaktivieren, wird sie nicht widerrufen.', failed: 'Die Aktion wurde nicht abgeschlossen. Versuchen Sie es erneut.', - 'failure.details': 'Diagnose: {details}', - 'failure.exitCode': 'Exit-Code {code}', 'action.connect': 'WeCom verbinden', 'action.open': 'QR-Code-Seite öffnen', 'action.cancel': 'Abbrechen', @@ -226,36 +179,28 @@ export const de: Record = { 'badge.disconnected': 'Nicht autorisiert', 'badge.connecting': 'Wird autorisiert', 'badge.unavailable': 'Unbestätigt', - 'badge.stopped': 'Läuft nicht', 'activation.title': 'WeCom verbinden', 'activation.body': 'Das WeCom-Plugin ist aktiviert. Scannen Sie einen QR-Code, um es zu autorisieren, und verwenden Sie es dann in Unterhaltungen.', - 'activation.later': 'Später', 'notice.connected': 'WeCom autorisiert', - 'notice.action-failed': 'Die Aktion wurde nicht abgeschlossen. Versuchen Sie es erneut.', - close: 'Schließen', } /** Russian dictionary. */ -export const ru: Record = { +export const ru: Record = { 'section.title': 'Авторизация WeCom', 'status.checking': 'Проверка авторизации', 'status.disconnected': 'Не авторизовано', 'status.unavailable': 'Сейчас не удаётся прочитать состояние авторизации', 'status.connected': 'Авторизовано', - 'status.stopped': 'Компонент WeCom не работает', 'step.authorizing': 'Ожидание сканирования QR-кода', 'step.connecting': 'Подтверждение авторизации', 'detail.disconnected': 'Отсканируйте QR-код в WeCom, чтобы привязать умного бота. После этого в беседах через этого бота можно будет использовать документы, календарь, встречи, задачи, сообщения и другие функции WeCom.', 'detail.unavailable': 'Не удалось прочитать авторизацию wecom-cli. Повторите попытку позже.', - 'detail.stopped': 'Компонент «CLI и навыки WeCom» не работает. Причину можно посмотреть в списке компонентов ниже; затем повторите попытку.', 'detail.connected': 'Попросите агента использовать WeCom прямо в беседе.', 'detail.authorizing': 'Отсканируйте QR-код в WeCom на открывшейся странице и подтвердите, затем вернитесь сюда, чтобы увидеть результат. Если страница не открылась, нажмите «Открыть страницу с QR-кодом».', 'skills.downloading': 'Навыки WeCom загружаются с GitHub. Они станут доступны в беседах, когда загрузка завершится.', 'skills.failed': 'Не удалось загрузить навыки WeCom, поэтому агент пока не может использовать руководства WeCom. Убедитесь, что этот компьютер может подключиться к GitHub, затем повторите попытку.', hint: 'Авторизация общая с wecom-cli в терминале этого компьютера. Отключение плагина её не отменяет.', failed: 'Действие не завершено. Повторите попытку.', - 'failure.details': 'Диагностика: {details}', - 'failure.exitCode': 'Код выхода {code}', 'action.connect': 'Подключить WeCom', 'action.open': 'Открыть страницу с QR-кодом', 'action.cancel': 'Отмена', @@ -264,36 +209,28 @@ export const ru: Record = { 'badge.disconnected': 'Не авторизовано', 'badge.connecting': 'Авторизация', 'badge.unavailable': 'Не подтверждено', - 'badge.stopped': 'Не работает', 'activation.title': 'Подключить WeCom', 'activation.body': 'Плагин WeCom включён. Отсканируйте QR-код, чтобы авторизовать его, и используйте его в беседах.', - 'activation.later': 'Позже', 'notice.connected': 'WeCom авторизован', - 'notice.action-failed': 'Действие не завершено. Повторите попытку.', - close: 'Закрыть', } /** Portuguese dictionary. */ -export const pt: Record = { +export const pt: Record = { 'section.title': 'Autorização do WeCom', 'status.checking': 'Verificando a autorização', 'status.disconnected': 'Não autorizado', 'status.unavailable': 'Não é possível ler a autorização no momento', 'status.connected': 'Autorizado', - 'status.stopped': 'O componente do WeCom não está em execução', 'step.authorizing': 'Aguardando a leitura do código QR', 'step.connecting': 'Confirmando a autorização', 'detail.disconnected': 'Leia um código QR com o WeCom para vincular um bot inteligente. Depois disso, você poderá usar nas conversas, por meio desse bot, os documentos, a agenda, as reuniões, as tarefas, as mensagens e outros recursos do WeCom.', 'detail.unavailable': 'Não foi possível ler a autorização do wecom-cli. Tente novamente mais tarde.', - 'detail.stopped': 'O componente “CLI e habilidades do WeCom” não está em execução. Veja o motivo na lista de componentes abaixo e tente novamente.', 'detail.connected': 'Peça ao agente que use o WeCom diretamente em uma conversa.', 'detail.authorizing': 'Leia o código QR com o WeCom na página que foi aberta e confirme; depois volte aqui para ver o resultado. Se a página não abriu, selecione “Abrir página do código QR”.', 'skills.downloading': 'Baixando as habilidades do WeCom do GitHub. Elas ficarão disponíveis nas conversas quando o download terminar.', 'skills.failed': 'Não foi possível baixar as habilidades do WeCom, então o agente ainda não pode usar os guias do WeCom. Verifique se este computador consegue acessar o GitHub e tente novamente.', hint: 'A autorização é compartilhada com o wecom-cli no terminal deste computador. Desativar o plugin não a revoga.', failed: 'A ação não foi concluída. Tente novamente.', - 'failure.details': 'Diagnóstico: {details}', - 'failure.exitCode': 'Código de saída {code}', 'action.connect': 'Conectar WeCom', 'action.open': 'Abrir página do código QR', 'action.cancel': 'Cancelar', @@ -302,17 +239,10 @@ export const pt: Record = { 'badge.disconnected': 'Não autorizado', 'badge.connecting': 'Autorizando', 'badge.unavailable': 'Não confirmado', - 'badge.stopped': 'Não está em execução', 'activation.title': 'Conectar WeCom', 'activation.body': 'O plugin do WeCom está ativado. Leia um código QR para autorizá-lo e depois use-o nas conversas.', - 'activation.later': 'Mais tarde', 'notice.connected': 'WeCom autorizado', - 'notice.action-failed': 'A ação não foi concluída. Tente novamente.', - close: 'Fechar', } -declare module '@deepseek-ai/dsh-client-ui-slots' { - interface LocaleNamespaceMap { - 'wecom': WecomKey - } -} +/** Render one key of the WeCom text in every shipped language. */ +export const text = accountText({ zh, en, ja, es, fr, de, ru, pt }) diff --git a/packages/connector/wecom-cli/src/presentation.ts b/packages/connector/wecom-cli/src/presentation.ts new file mode 100644 index 0000000000..7594c43073 --- /dev/null +++ b/packages/connector/wecom-cli/src/presentation.ts @@ -0,0 +1,92 @@ +/** The WeCom authorization section the Plugins page shows for each Host view. */ +import { failureDetails } from '@deepseek-ai/dsh-cli-account' +import type { + CliAccountButton, CliAccountCopy, CliAccountDisplay, CliAccountFailure, CliAccountNote, CliAccountOperation, +} from '@deepseek-ai/dsh-cli-account/types' +import type { UpstreamSkillsState } from '@deepseek-ai/dsh-upstream-skills/types' +import { assertNever } from '@deepseek-ai/dsh-util-values' +import { text } from './locales.ts' +import type { WecomOperationKind, WecomState } from './types.ts' + +/** The npm package whose bundle page carries the authorization section. */ +export const WECOM_PACKAGE = '@deepseek-ai/dsh-wecom' + +/** The operations the section's buttons start; binding a bot reports a notice in the browser that started it. */ +export const OPERATIONS: readonly CliAccountOperation[] = [ + { kind: 'check' }, + { kind: 'connect', notice: text('notice.connected') }, +] + +/** The section's title and hint, and the prompt after the bundle is switched on while unauthorized. */ +export const COPY: CliAccountCopy = { + title: text('section.title'), + hint: text('hint'), + activation: { title: text('activation.title'), body: text('activation.body'), connect: text('action.connect') }, +} + +const CHECK = { kind: 'start', operation: 'check' } as const +const CONNECT = { kind: 'start', operation: 'connect' } as const + +/* jscpd:ignore-start -- CLI app plugins whose guides download report the same states, each in its own text. */ +/** The row that reports guides that are not in place yet; a failed download offers a check, which restarts it. */ +function skillsNotes(skills: UpstreamSkillsState): CliAccountNote[] { + switch (skills) { + case 'installed': return [] + case 'downloading': return [{ text: text('skills.downloading') }] + case 'failed': return [{ text: text('skills.failed'), button: { label: text('action.retry'), command: CHECK } }] + /* v8 ignore next -- closed skills state union */ + default: return assertNever(skills) + } +} +/* jscpd:ignore-end */ + +/** The bound bot's QR-code page and the operation's cancel, while an authorization runs. */ +function connectingButtons(operation: NonNullable): CliAccountButton[] { + const buttons: CliAccountButton[] = [] + if (operation.authorizationUrl !== undefined) buttons.push({ label: text('action.open'), command: { kind: 'open' }, variant: 'primary' }) + if (operation.cancellable) buttons.push({ label: text('action.cancel'), command: { kind: 'cancel' }, variant: 'ghost' }) + return buttons +} + +/** + * The authorization section for one Host view. + * @param view - the authorization, the operation in progress, and the last result. + * @returns the phase, status, tag, buttons, detail, guide download row, and failure. + */ +export function presentAccount(view: WecomState): CliAccountDisplay { + const notes = skillsNotes(view.account.skills) + const { operation } = view + if (operation?.kind === 'check') return { phase: 'checking', status: text('status.checking'), buttons: [], notes } + if (operation !== undefined) { + return { + phase: 'connecting', status: text(operation.phase === 'authorizing' ? 'step.authorizing' : 'step.connecting'), + badge: text('badge.connecting'), buttons: connectingButtons(operation), notes, + ...operation.authorizationUrl === undefined ? {} : { detail: text('detail.authorizing') }, + } + } + const failed = view.result?.outcome === 'failed' ? view.result : undefined + const failure: { failure?: CliAccountFailure } = failed === undefined ? {} : { + failure: { text: text('failed'), ...failed.failure === undefined ? {} : { details: failureDetails(failed.failure) } }, + } + switch (view.account.state) { + case 'unchecked': + if (failed === undefined) return { phase: 'checking', status: text('status.checking'), buttons: [], notes } + return { + phase: 'unavailable', status: text('status.unavailable'), badge: text('badge.unavailable'), + buttons: [{ label: text('action.retry'), command: CHECK }], detail: text('detail.unavailable'), notes, ...failure, + } + case 'unauthorized': + return { + phase: 'disconnected', status: text('status.disconnected'), badge: text('badge.disconnected'), + buttons: [{ label: text('action.connect'), command: CONNECT, variant: 'primary' }], connect: CONNECT, + detail: text('detail.disconnected'), notes, ...failure, + } + case 'authorized': + return { + phase: 'connected', status: text('status.connected'), badge: text('badge.connected'), buttons: [], + detail: text('detail.connected'), notes, ...failure, + } + /* v8 ignore next -- closed account state union */ + default: return assertNever(view.account.state) + } +} diff --git a/packages/connector/wecom-cli/src/types.ts b/packages/connector/wecom-cli/src/types.ts index 41428319ac..d288e8afdd 100644 --- a/packages/connector/wecom-cli/src/types.ts +++ b/packages/connector/wecom-cli/src/types.ts @@ -1,4 +1,4 @@ -/** Credential-free WeCom authorization and operation views for Remote clients. */ +/** Credential-free WeCom authorization and operation views the Plugins page presenter reads. */ import type { CliAccountView, CliCommandFailure } from '@deepseek-ai/dsh-cli-account/types' import type { UpstreamSkillsState } from '@deepseek-ai/dsh-upstream-skills/types' @@ -19,5 +19,5 @@ export type WecomPhase = 'authorizing' /** The command and exit code of a failed operation's last command. */ export type WecomOperationFailure = CliCommandFailure<'auth-init' | 'auth-status'> -/** The complete WeCom view a Remote client replaces on every change. */ +/** The complete WeCom view the presenter reads after each change. */ export type WecomState = CliAccountView diff --git a/packages/connector/wecom-cli/tests/account.spec.ts b/packages/connector/wecom-cli/tests/account.spec.ts index 2a7c910b66..f92deb2c24 100644 --- a/packages/connector/wecom-cli/tests/account.spec.ts +++ b/packages/connector/wecom-cli/tests/account.spec.ts @@ -4,13 +4,15 @@ import { tmpdir } from 'node:os' import { join } from 'node:path' import { Context } from '@deepseek-ai/cordis' import { CliCommandExecutor, executableFileName, type CliOperationId } from '@deepseek-ai/dsh-cli-account' +import type { CliAccountRegistration, CliAccountSource } from '@deepseek-ai/dsh-cli-account/types' import SkillRegistry from '@deepseek-ai/dsh-skill' import SystemPrompt from '@deepseek-ai/dsh-system-prompt' import type { UpstreamSkillsState } from '@deepseek-ai/dsh-upstream-skills' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { WecomAccount } from '../src/account.ts' import { PROGRAM } from '../src/directory.ts' -import Wecom, { type WecomState } from '../src/index.ts' +import * as Wecom from '../src/index.ts' +import type { WecomState } from '../src/types.ts' import { createBinDir, ScriptedSubprocess, type CliReply, type ScriptedProcess } from './harness.ts' const STATUS = 'auth show --status' @@ -168,52 +170,48 @@ describe('WecomAccount', () => { }) }) -describe('WeCom Remote', () => { +describe('WeCom on the Plugins page', () => { + let account!: CliAccountSource + beforeEach(async () => { + ctx.provide('cliAccounts', { + register: (registration: CliAccountRegistration) => { + account = registration.source + return () => {} + }, + }) await ctx.plugin(Wecom, { commandTimeoutMs: 5_000, binDir, skillsDir, skillsUrls: ['https://codeload.github.com'], skillsTimeoutMs: 120_000 }) }) - it('checks for a new follower, streams each change, and starts checks and connections', async () => { + const finished = async (id: CliOperationId): Promise => { + await vi.waitFor(() => { expect(account.snapshot().result?.id).toBe(id) }) + return account.snapshot().result + } + + it('checks on refresh, then starts checks and connections one at a time and cancels one waiting for the scan', async () => { script[STATUS] = [UNAUTHORIZED] - const states: WecomState[] = [] - const leave = new AbortController() - const following = (async () => { - for await (const state of ctx.wecom.follow(leave.signal)) states.push(state) - })() - const finished = async (id?: CliOperationId): Promise => { - await vi.waitFor(() => { - expect(states.at(-1)?.result).toBeDefined() - if (id !== undefined) expect(states.at(-1)?.result?.id).toBe(id) - }) - return states.at(-1)?.result - } - expect(await finished()).toMatchObject({ kind: 'check', outcome: 'succeeded' }) - expect(states[0]).toMatchObject({ account: { state: 'unchecked', skills: 'installed' }, operation: { kind: 'check' } }) - expect(states.at(-1)?.account).toEqual({ state: 'unauthorized', skills: 'installed' }) + account.refresh() + const check = account.snapshot().operation + expect(account.snapshot()).toMatchObject({ account: { state: 'unchecked', skills: 'installed' }, operation: { kind: 'check' } }) + expect(await finished(check!.id)).toMatchObject({ kind: 'check', outcome: 'succeeded' }) + expect(account.snapshot().account).toEqual({ state: 'unauthorized', skills: 'installed' }) expect(subprocess.lookups[0]?.command).toBe(join(binDir, executableFileName('wecom-cli'))) - expect(await finished(ctx.wecom.check())).toMatchObject({ kind: 'check', outcome: 'succeeded' }) + expect(await finished(account.start('check'))).toMatchObject({ kind: 'check', outcome: 'succeeded' }) script[INIT] = () => {} - const connecting = ctx.wecom.connect() - expect(() => ctx.wecom.check()).toThrow('another account operation is in progress') + const connecting = account.start('connect') + expect(() => account.start('check')).toThrow('another account operation is in progress') await vi.waitFor(() => { expect(commands().at(-1)).toBe(INIT) }) - await ctx.wecom.cancel(connecting) + await account.cancel(connecting) expect(await finished(connecting)).toMatchObject({ kind: 'connect', outcome: 'cancelled' }) expect(subprocess.processes.at(-1)?.terminated).toBe(true) - leave.abort() - await following }) - it('ends its streams and stops authorization work on disposal', async () => { + it('stops authorization work on disposal', async () => { script[STATUS] = () => {} - const states: WecomState[] = [] - const following = (async () => { - for await (const state of ctx.wecom.follow(new AbortController().signal)) states.push(state) - })() + account.refresh() await vi.waitFor(() => { expect(subprocess.processes).toHaveLength(1) }) await ctx.fiber.dispose() - await following - expect(states.length).toBeGreaterThan(0) expect(subprocess.processes[0]?.terminated).toBe(true) }) }) diff --git a/packages/connector/wecom-cli/tests/plugin.spec.ts b/packages/connector/wecom-cli/tests/plugin.spec.ts index 48c0f37b96..a437a0e8c0 100644 --- a/packages/connector/wecom-cli/tests/plugin.spec.ts +++ b/packages/connector/wecom-cli/tests/plugin.spec.ts @@ -6,8 +6,11 @@ import SkillRegistry from '@deepseek-ai/dsh-skill' import SystemPrompt, { renderContextSections } from '@deepseek-ai/dsh-system-prompt' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { executableFileName } from '@deepseek-ai/dsh-cli-account' +import type { CliAccountRegistration } from '@deepseek-ai/dsh-cli-account/types' import { cliPathContextText } from '@deepseek-ai/dsh-cli-account/src/context.ts' -import Wecom from '../src/index.ts' +import * as Wecom from '../src/index.ts' +import { COPY, OPERATIONS, presentAccount, WECOM_PACKAGE } from '../src/presentation.ts' +import type { WecomState } from '../src/types.ts' import { createBinDir, ScriptedSubprocess } from './harness.ts' const CONFIG = { commandTimeoutMs: 5_000, skillsUrls: ['https://codeload.github.com'], skillsTimeoutMs: 120_000 } @@ -38,6 +41,19 @@ describe('WeCom plugin', () => { const runtimeContext = async () => renderContextSections(await ctx.systemPrompt.assemble()) + /** Stand in for the CLI account registry the Web app provides, and keep what the plugin registers with it. */ + function provideRegistry() { + const registered: CliAccountRegistration[] = [] + const withdrawn = vi.fn() + ctx.provide('cliAccounts', { + register: (registration: CliAccountRegistration) => { + registered.push(registration) + return withdrawn + }, + }) + return { registered, withdrawn } + } + it('publishes one wecom entry skill over the configured guides, with a body that carries the DSH guidance', async () => { await ctx.plugin(Wecom, { ...CONFIG, binDir, skillsDir }) @@ -54,13 +70,11 @@ describe('WeCom plugin', () => { const home = await mkdtemp(join(tmpdir(), 'dsh-wecom-home-')) vi.stubEnv('DSH_HOME', home) try { + const registry = provideRegistry() await ctx.plugin(Wecom, { ...CONFIG, binDir, skillsUrls: ['https://127.0.0.1:9'], skillsTimeoutMs: 5_000 }) - const seen: string[] = [] - for await (const view of ctx.wecom.follow(new AbortController().signal)) { - seen.push(view.account.skills) - if (view.account.skills === 'failed') break - } - expect(seen[0]).toBe('downloading') + const account = registry.registered[0]!.source + expect(account.snapshot().account.skills).toBe('downloading') + await vi.waitFor(() => { expect(account.snapshot().account.skills).toBe('failed') }, { timeout: 10_000 }) expect(await ctx.skills.list()).toEqual([]) } finally { await rm(home, { recursive: true, force: true }) @@ -80,4 +94,18 @@ describe('WeCom plugin', () => { expect(await runtimeContext()).toEqual([]) expect(await ctx.skills.list()).toEqual([]) }) + + it('shows the authorization on the Plugins page while the registry runs, and withdraws it with the plugin', async () => { + const registry = provideRegistry() + const fiber = await ctx.plugin(Wecom, { ...CONFIG, binDir, skillsDir }) + expect(registry.registered).toHaveLength(1) + expect(registry.registered[0]).toMatchObject({ + packageName: WECOM_PACKAGE, operations: OPERATIONS, copy: COPY, present: presentAccount, + }) + expect(registry.registered[0]!.source.snapshot().account.state).toBe('unchecked') + + await fiber.dispose() + + expect(registry.withdrawn).toHaveBeenCalledOnce() + }) }) diff --git a/packages/connector/wecom-cli/tests/presentation.spec.ts b/packages/connector/wecom-cli/tests/presentation.spec.ts new file mode 100644 index 0000000000..0d6c74a2da --- /dev/null +++ b/packages/connector/wecom-cli/tests/presentation.spec.ts @@ -0,0 +1,91 @@ +/** The WeCom section offers each state's next step, the guide download rows, and failure guidance, in every shipped language. */ +import type { CliAccountDisplay, CliOperationId } from '@deepseek-ai/dsh-cli-account/types' +import type { LocalizedText } from '@deepseek-ai/dsh-package-manifest' +import { expect, it } from 'vitest' +import { en, zh, type WecomTextKey } from '../src/locales.ts' +import { COPY, OPERATIONS, presentAccount } from '../src/presentation.ts' +import type { WecomState } from '../src/types.ts' + +const OP = 'op' as CliOperationId +const QR = 'https://work.weixin.qq.com/qr' +const CHECK = { kind: 'start', operation: 'check' } as const +const CONNECT = { kind: 'start', operation: 'connect' } as const + +/** The key's text as the Chinese and English browsers resolve it. */ +const say = (key: WecomTextKey): Partial> => ({ zh: zh[key], en: en[key] }) +const zhOf = (text: LocalizedText | undefined): string | undefined => typeof text === 'object' ? text.zh : text +const labels = (display: CliAccountDisplay): (string | undefined)[] => display.buttons.map(button => zhOf(button.label)) + +const unauthorized = { state: 'unauthorized', skills: 'installed' } as const + +it('offers the next step for each state', () => { + let shown = presentAccount({ account: unauthorized }) + expect(shown).toMatchObject({ + phase: 'disconnected', status: say('status.disconnected'), badge: say('badge.disconnected'), + detail: say('detail.disconnected'), connect: CONNECT, notes: [], + }) + expect(shown.buttons).toMatchObject([{ label: say('action.connect'), command: CONNECT, variant: 'primary' }]) + + shown = presentAccount({ account: unauthorized, operation: { id: OP, kind: 'connect', phase: 'authorizing', cancellable: true } }) + expect(shown).toMatchObject({ phase: 'connecting', status: say('step.authorizing'), badge: say('badge.connecting') }) + expect(shown.detail).toBeUndefined() + expect(shown.buttons).toMatchObject([{ label: say('action.cancel'), command: { kind: 'cancel' }, variant: 'ghost' }]) + + shown = presentAccount({ + account: unauthorized, operation: { id: OP, kind: 'connect', phase: 'authorizing', cancellable: true, authorizationUrl: QR }, + }) + expect(shown.detail).toMatchObject(say('detail.authorizing')) + expect(shown.buttons.map(button => button.command)).toEqual([{ kind: 'open' }, { kind: 'cancel' }]) + expect(labels(shown)).toEqual([zh['action.open'], zh['action.cancel']]) + + shown = presentAccount({ account: unauthorized, operation: { id: OP, kind: 'connect', phase: 'checking', cancellable: false } }) + expect(shown).toMatchObject({ status: say('step.connecting'), buttons: [] }) + + shown = presentAccount({ account: { state: 'authorized', skills: 'installed' } }) + expect(shown).toMatchObject({ phase: 'connected', status: say('status.connected'), badge: say('badge.connected'), detail: say('detail.connected'), buttons: [] }) + + for (const view of [ + { account: { state: 'authorized', skills: 'installed' }, operation: { id: OP, kind: 'check', phase: 'checking', cancellable: false } }, + { account: { state: 'unchecked', skills: 'installed' } }, + ] as const satisfies readonly WecomState[]) { + shown = presentAccount(view) + expect(shown).toMatchObject({ phase: 'checking', status: say('status.checking'), buttons: [] }) + expect(shown.badge).toBeUndefined() + } +}) + +it('reports a failed connection with its diagnostic items, and no failure for a cancelled one', () => { + let shown = presentAccount({ account: unauthorized, result: { id: OP, kind: 'connect', outcome: 'failed', failure: { command: 'auth-init', exitCode: 2 } } }) + expect(shown.failure).toMatchObject({ text: say('failed'), details: ['auth-init', 'exit 2'] }) + expect(labels(shown)).toEqual([zh['action.connect']]) + shown = presentAccount({ account: unauthorized, result: { id: OP, kind: 'connect', outcome: 'failed' } }) + expect(shown.failure).toMatchObject({ text: say('failed') }) + expect(shown.failure).not.toHaveProperty('details') + shown = presentAccount({ account: { state: 'authorized', skills: 'installed' }, result: { id: OP, kind: 'connect', outcome: 'failed' } }) + expect(shown.failure).toBeDefined() + expect(presentAccount({ account: unauthorized, result: { id: OP, kind: 'connect', outcome: 'cancelled' } }).failure).toBeUndefined() +}) + +it('retries an unreadable authorization by checking again', () => { + const shown = presentAccount({ + account: { state: 'unchecked', skills: 'installed' }, result: { id: OP, kind: 'check', outcome: 'failed', failure: { command: 'auth-status', exitCode: 1 } }, + }) + expect(shown).toMatchObject({ phase: 'unavailable', status: say('status.unavailable'), badge: say('badge.unavailable'), detail: say('detail.unavailable') }) + expect(shown.buttons).toMatchObject([{ label: say('action.retry'), command: CHECK }]) + expect(shown.failure?.details).toEqual(['auth-status', 'exit 1']) +}) + +it('reports guides that are downloading, and retries a failed download by checking again', () => { + expect(presentAccount({ account: { state: 'authorized', skills: 'downloading' } }).notes).toMatchObject([{ text: say('skills.downloading') }]) + const [note] = presentAccount({ account: { state: 'authorized', skills: 'failed' } }).notes + expect(note).toMatchObject({ text: say('skills.failed'), button: { label: say('action.retry'), command: CHECK } }) +}) + +it('names the section, its activation prompt, and the notice a connection reports', () => { + expect(COPY).toMatchObject({ + title: say('section.title'), hint: say('hint'), + activation: { title: say('activation.title'), body: say('activation.body'), connect: say('action.connect') }, + }) + expect(OPERATIONS).toMatchObject([{ kind: 'check' }, { kind: 'connect', notice: say('notice.connected') }]) + expect(OPERATIONS[0]).not.toHaveProperty('notice') +}) diff --git a/packages/connector/wecom-cli/tsconfig.json b/packages/connector/wecom-cli/tsconfig.json index 87b82d223c..e8d4410dbd 100644 --- a/packages/connector/wecom-cli/tsconfig.json +++ b/packages/connector/wecom-cli/tsconfig.json @@ -20,9 +20,6 @@ { "path": "../../util/values" }, - { - "path": "../../typert/protocol" - }, { "path": "../../skill/skill" }, @@ -34,6 +31,9 @@ }, { "path": "../../core/system-prompt" + }, + { + "path": "../../client/ui-cli-account/tsconfig.host.json" } ] } diff --git a/packages/connector/wecom/README.i18n.yaml b/packages/connector/wecom/README.i18n.yaml index c3f9a1bd63..7b2c0fc34a 100644 --- a/packages/connector/wecom/README.i18n.yaml +++ b/packages/connector/wecom/README.i18n.yaml @@ -9,8 +9,8 @@ en: 97ebb140059d2cd9 zh: b9753254b9a084f3 /deepseek-ai-dsh-wecom/summary: - en: 2b97cd118920fb64 - zh: ec8bc185d76b6078 + en: e9dcad15ae59228c + zh: d8a455329476292f /deepseek-ai-dsh-wecom/table-of-contents: en: d152484eb41ac6b4 zh: 09388d293f9be9cb @@ -21,17 +21,17 @@ en: 8241a30e5141c500 zh: 97f8736d76cf596a /deepseek-ai-dsh-wecom/use-this-package/what-you-get: - en: 1792807c71dc1378 - zh: 30a4e8bbef8465f1 + en: 1550be3af3ba2a75 + zh: 597d043cb79fe6a9 /deepseek-ai-dsh-wecom/understand-the-implementation: - en: d4754af8f28ba943 - zh: 5dd12878d10aa923 + en: edfc5fbed5409988 + zh: 1d1e6c3d6b60fdc3 /deepseek-ai-dsh-wecom/further-exploration: - en: 0ddd477478c99a83 - zh: 2973bab4a947e25d + en: 31fa7acc98f03a45 + zh: c3886613b7a02082 /deepseek-ai-dsh-wecom/model-experience: - en: 87c02cc4e367997a - zh: f177125772ea3091 + en: 56d462bac8c9d791 + zh: 556310702e5d9a5a /deepseek-ai-dsh-wecom/model-experience/kv-cache-effect: en: b558a17d38ee0f3d zh: a6a3069c1a42a02c diff --git a/packages/connector/wecom/README.md b/packages/connector/wecom/README.md index 2084e81353..71c8ed8676 100644 --- a/packages/connector/wecom/README.md +++ b/packages/connector/wecom/README.md @@ -9,7 +9,7 @@ English | [中文](README.zh.md) ## Summary -The WeCom plugin lets conversations use WeCom through the official `wecom-cli`. Installing this bundle adds two rows: the CLI with its skills, and the WeCom authorization section on the Plugins page, where the user binds a bot by scanning a QR code without starting a conversation. The CLI keeps the authorization in its default configuration, which the user's own terminal shares. Only macOS and Windows x64 are supported. +The WeCom plugin lets conversations use WeCom through the official `wecom-cli`. Installing this bundle adds one row: the CLI with its skills, which also shows the WeCom authorization section on the Plugins page, where the user binds a bot by scanning a QR code without starting a conversation. The CLI keeps the authorization in its default configuration, which the user's own terminal shares. Only macOS and Windows x64 are supported. ## Table of Contents @@ -40,8 +40,7 @@ dsh plugin --profile web remove @deepseek-ai/dsh-wecom | Row | Package | Behavior | |---|---|---| -| `wecom` | [`@deepseek-ai/dsh-wecom-cli`](../wecom-cli/README.md) | Gives the model the absolute path of `wecom-cli`, registers its skills, and runs authorization checks and QR-code connection on the Host | -| `ui-wecom` | [`@deepseek-ai/dsh-client-ui-wecom`](../../client/ui-wecom/README.md) | Shows the WeCom authorization section, an authorization tag, guidance after the bundle is switched on, and notices on the Plugins page | +| `wecom` | [`@deepseek-ai/dsh-wecom-cli`](../wecom-cli/README.md) | Gives the model the absolute path of `wecom-cli`, registers its skills, runs authorization checks and QR-code connection on the Host, and shows the authorization section, an authorization tag, guidance after the bundle is switched on, and notices on the Plugins page through the [CLI account registry](../../client/ui-cli-account/README.md) | Switching the bundle off withdraws the skills, the path in runtime context, and the page. The CLI authorization stays in place. @@ -53,7 +52,7 @@ Switching the bundle off withdraws the skills, the path in runtime context, and
Implementation internals — click to expand -[`cordis.patch.yml`](cordis.patch.yml) inserts the `wecom` and `ui-wecom` rows after the profile's other layers. The package depends on both row packages so that the rows resolve from this bundle, and [`src/index.ts`](src/index.ts) exports nothing. The Plugins page keys the authorization section by this package name. +[`cordis.patch.yml`](cordis.patch.yml) inserts the `wecom` row after the profile's other layers. The package depends on that row package so that the row resolves from this bundle, and [`src/index.ts`](src/index.ts) exports nothing. The Plugins page keys the authorization section by this package name.
@@ -64,7 +63,7 @@ Switching the bundle off withdraws the skills, the path in runtime context, and - [Connector packages](../README.md) — the group this application plugin belongs to. - [WeCom CLI and skills](../wecom-cli/README.md) — the Host row, its authorization operations, and its model guidance. -- [WeCom plugin page](../../client/ui-wecom/README.md) — the Plugins page row. +- [CLI account surfaces](../../client/ui-cli-account/README.md) — the registry that shows the authorization on the Plugins page. - [Plugin Manager](../../boot/plugin-manager/README.md) — installation and enablement. ----- @@ -72,7 +71,7 @@ Switching the bundle off withdraws the skills, the path in runtime context, and ## Model Experience -Indirectly, through the `wecom` row, whose package owns the skill catalog entries and loaded skill bodies described in its [Model Experience](../wecom-cli/README.md#model-experience); the `ui-wecom` row adds nothing model-facing. +Indirectly, through the `wecom` row, whose package owns the skill catalog entries and loaded skill bodies described in its [Model Experience](../wecom-cli/README.md#model-experience). #### KV Cache effect diff --git a/packages/connector/wecom/README.zh.md b/packages/connector/wecom/README.zh.md index 88b6a50068..265c14119f 100644 --- a/packages/connector/wecom/README.zh.md +++ b/packages/connector/wecom/README.zh.md @@ -9,7 +9,7 @@ kind: "package-bundle" ## 概述 -企业微信插件让对话通过官方 `wecom-cli` 使用企业微信。安装这个 bundle 会加入两行:带技能的 CLI,以及插件页上的企业微信授权区块;用户在插件页扫码绑定机器人,不需要先开始对话。CLI 把授权保存在默认配置中,与用户自己的终端共用。仅支持 macOS 和 Windows x64。 +企业微信插件让对话通过官方 `wecom-cli` 使用企业微信。安装这个 bundle 会加入一行:带技能的 CLI,它同时在插件页显示企业微信授权区块;用户在插件页扫码绑定机器人,不需要先开始对话。CLI 把授权保存在默认配置中,与用户自己的终端共用。仅支持 macOS 和 Windows x64。 ## 目录 @@ -40,8 +40,7 @@ dsh plugin --profile web remove @deepseek-ai/dsh-wecom | 行 | 包 | 行为 | |---|---|---| -| `wecom` | [`@deepseek-ai/dsh-wecom-cli`](../wecom-cli/README.zh.md) | 把 `wecom-cli` 的绝对路径告诉模型,注册其技能,并在 Host 上执行授权检查和扫码连接 | -| `ui-wecom` | [`@deepseek-ai/dsh-client-ui-wecom`](../../client/ui-wecom/README.zh.md) | 在插件页显示企业微信授权区块、授权标签、开启后的引导和提示 | +| `wecom` | [`@deepseek-ai/dsh-wecom-cli`](../wecom-cli/README.zh.md) | 把 `wecom-cli` 的绝对路径告诉模型,注册其技能,在 Host 上执行授权检查和扫码连接,并通过 [CLI 账号注册表](../../client/ui-cli-account/README.zh.md)在插件页显示授权区块、授权标签、开启后的引导和提示 | 关闭 bundle 会撤下技能、运行时上下文中的路径和页面。CLI 的授权保持不变。 @@ -53,7 +52,7 @@ dsh plugin --profile web remove @deepseek-ai/dsh-wecom
实现内部机制——点击展开 -[`cordis.patch.yml`](cordis.patch.yml) 在 profile 其他层之后插入 `wecom` 与 `ui-wecom` 两行。本包依赖这两个行包,使两行都从本 bundle 解析;[`src/index.ts`](src/index.ts) 不导出任何内容。插件页以本包名作为授权区块的 key。 +[`cordis.patch.yml`](cordis.patch.yml) 在 profile 其他层之后插入 `wecom` 行。本包依赖这个行包,使该行从本 bundle 解析;[`src/index.ts`](src/index.ts) 不导出任何内容。插件页以本包名作为授权区块的 key。
@@ -64,7 +63,7 @@ dsh plugin --profile web remove @deepseek-ai/dsh-wecom - [Connector 包](../README.zh.md)——这个应用插件所属的分组。 - [企业微信 CLI 与技能](../wecom-cli/README.zh.md)——Host 行、授权操作与模型指引。 -- [企业微信插件页面](../../client/ui-wecom/README.zh.md)——插件页行。 +- [CLI 账号界面](../../client/ui-cli-account/README.zh.md)——在插件页显示授权的注册表。 - [Plugin Manager](../../boot/plugin-manager/README.zh.md)——安装与启用。 ----- @@ -72,7 +71,7 @@ dsh plugin --profile web remove @deepseek-ai/dsh-wecom ## 模型体验 -间接地通过 `wecom` 行产生,该行所属的包负责技能目录条目和加载后的技能正文,见其[模型体验](../wecom-cli/README.zh.md#model-experience);`ui-wecom` 行不增加任何模型可见内容。 +间接地通过 `wecom` 行产生,该行所属的包负责技能目录条目和加载后的技能正文,见其[模型体验](../wecom-cli/README.zh.md#model-experience)。 #### KV Cache 影响 diff --git a/packages/connector/wecom/cordis.patch.yml b/packages/connector/wecom/cordis.patch.yml index fb23343875..678d17e391 100644 --- a/packages/connector/wecom/cordis.patch.yml +++ b/packages/connector/wecom/cordis.patch.yml @@ -1,5 +1,3 @@ - insert: - id: wecom name: '@deepseek-ai/dsh-wecom-cli' - - id: ui-wecom - name: '@deepseek-ai/dsh-client-ui-wecom' diff --git a/packages/connector/wecom/package.json b/packages/connector/wecom/package.json index 9562a1ea48..d46ecb9208 100644 --- a/packages/connector/wecom/package.json +++ b/packages/connector/wecom/package.json @@ -31,8 +31,7 @@ ], "license": "MIT", "dependencies": { - "@deepseek-ai/dsh-wecom-cli": "workspace:*", - "@deepseek-ai/dsh-client-ui-wecom": "workspace:*" + "@deepseek-ai/dsh-wecom-cli": "workspace:*" }, "peerDependencies": { "@deepseek-ai/cordis": "workspace:~" diff --git a/packages/extensions/tool-cordis/src/api-catalog.ts b/packages/extensions/tool-cordis/src/api-catalog.ts index a5bb675d5c..7e5b3d1f4c 100644 --- a/packages/extensions/tool-cordis/src/api-catalog.ts +++ b/packages/extensions/tool-cordis/src/api-catalog.ts @@ -4407,39 +4407,6 @@ export const SERVICE_API: readonly ServiceApiEntry[] = [ }, ], }, - { - key: 'wecom', - summary: 'Registers the CLI and skills, and owns the authorization operations the Plugins page drives.', - description: 'Registers the CLI and skills, and owns the authorization operations the Plugins page drives.', - methods: [ - { - signature: '@Remote check(): CliOperationId', - description: 'Check the authorization again without changing it.', - parameters: [], - returns: 'the operation identity.', - throws: ['while another operation runs.'], - }, - { - signature: '@Remote connect(): CliOperationId', - description: 'Bind a bot through the CLI\'s QR-code page.', - parameters: [], - returns: 'the operation identity.', - throws: ['while another operation runs.'], - }, - { - signature: '@Remote cancel(id: CliOperationId): Promise', - description: 'Cancel one operation while it waits for the QR-code scan, and wait for its command to exit.', - parameters: [{ name: 'id', description: 'the operation to cancel; a finished one or another step is ignored.' }], - returns: 'after the operation settles, or at once when nothing is cancelled.', - }, - { - signature: '@Remote({ mode: \'stream\' }) async *follow(signal: AbortSignal): AsyncIterable', - description: 'Follow the authorization and its operations independently of any page; each new subscriber starts a check when none runs.', - parameters: [{ name: 'signal', description: 'the Client\'s observation lifetime.' }], - returns: 'the current view, then each changed view.', - }, - ], - }, { key: 'workflowEngine', summary: 'Workflow Service Definition contract.', @@ -9964,10 +9931,6 @@ export const TYPE_API: readonly TypeApiEntry[] = [ name: 'UpdateTeamTaskRequest', declaration: 'export interface UpdateTeamTaskRequest {\n readonly taskId: TeamTaskId;\n readonly expectedRevision: number;\n readonly action: TeamTaskAction;\n readonly subject?: string;\n readonly description?: string;\n readonly blockedBy?: readonly TeamTaskId[];\n readonly writeScopes?: readonly string[];\n readonly owner?: SessionId;\n}', }, - { - name: 'UpstreamSkillsState', - declaration: 'export type UpstreamSkillsState = \'installed\' | \'downloading\' | \'failed\';', - }, { name: 'UserMessage', declaration: 'export interface UserMessage extends MessageBase {\n readonly role: \'user\';\n}', @@ -10104,26 +10067,6 @@ export const TYPE_API: readonly TypeApiEntry[] = [ name: 'WebUpgradeRoute', declaration: 'export interface WebUpgradeRoute {\n path: string;\n handler: (req: IncomingMessage, socket: Duplex, head: Buffer) => void | Promise;\n}', }, - { - name: 'WecomAccountState', - declaration: 'export interface WecomAccountState {\n readonly state: \'unchecked\' | \'unauthorized\' | \'authorized\';\n readonly skills: UpstreamSkillsState;\n}', - }, - { - name: 'WecomOperationFailure', - declaration: 'export type WecomOperationFailure = CliCommandFailure<\'auth-init\' | \'auth-status\'>;', - }, - { - name: 'WecomOperationKind', - declaration: 'export type WecomOperationKind = \'check\' | \'connect\';', - }, - { - name: 'WecomPhase', - declaration: 'export type WecomPhase = \'authorizing\';', - }, - { - name: 'WecomState', - declaration: 'export type WecomState = CliAccountView;', - }, { name: 'WeeklyInput', declaration: 'export interface WeeklyInput {\n readonly time: string;\n readonly time_zone: string;\n readonly weekdays: number[];\n}', 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 17bd4cccf2..ce4675dab3 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 @@ -123,7 +123,6 @@ Every package below exports a Cordis plugin that a bundle patch can name in a Lo | `@deepseek-ai/dsh-client-ui-tool` | no | Client Tool call-tree renderer and keyed per-tool presentation slot | | `@deepseek-ai/dsh-client-ui-trajectory` | yes | Trajectory event ledger and timing overview with live tool-result inspection | | `@deepseek-ai/dsh-client-ui-user-questions` | no | Web ask_user_question composer takeover and plan-review presentation UI | -| `@deepseek-ai/dsh-client-ui-wecom` | no | WeCom plugin page: authorize and check WeCom from the Plugins page | | `@deepseek-ai/dsh-client-ui-workflow-run` | no | Durable workflow-run Conversation Node and nested member disclosure for dsh web | | `@deepseek-ai/dsh-client-ui-workspace` | no | Workspace picker plugin: one WorkspacePicker registered into the sidebar and empty-state workspace slots | diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1b3ce8972c..4b00a801e7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7111,42 +7111,6 @@ importers: specifier: ^18.2.0 version: 18.3.1 - packages/client/ui-wecom: - devDependencies: - '@deepseek-ai/cordis': - specifier: workspace:~ - version: link:../../../vendor/cordis - '@deepseek-ai/dsh-api-remotes': - specifier: workspace:* - version: link:../../api/remotes - '@deepseek-ai/dsh-cli-account': - specifier: workspace:* - version: link:../../connector/cli-account - '@deepseek-ai/dsh-client-locale': - specifier: workspace:* - version: link:../locale - '@deepseek-ai/dsh-client-test-runtime': - specifier: workspace:* - version: link:../../test-support/client-runtime - '@deepseek-ai/dsh-client-ui-cli-account': - specifier: workspace:* - version: link:../ui-cli-account - '@deepseek-ai/dsh-client-ui-slots': - specifier: workspace:* - version: link:../ui-slots - '@deepseek-ai/dsh-typert-protocol': - specifier: workspace:* - version: link:../../typert/protocol - '@deepseek-ai/dsh-upstream-skills': - specifier: workspace:* - version: link:../../connector/upstream-skills - '@deepseek-ai/dsh-util-values': - specifier: workspace:* - version: link:../../util/values - '@deepseek-ai/dsh-wecom-cli': - specifier: workspace:* - version: link:../../connector/wecom-cli - packages/client/ui-workflow-run: devDependencies: '@deepseek-ai/cordis': @@ -7583,9 +7547,6 @@ importers: packages/connector/wecom: dependencies: - '@deepseek-ai/dsh-client-ui-wecom': - specifier: workspace:* - version: link:../../client/ui-wecom '@deepseek-ai/dsh-wecom-cli': specifier: workspace:* version: link:../wecom-cli @@ -7615,6 +7576,9 @@ importers: '@deepseek-ai/cordis': specifier: workspace:~ version: link:../../../vendor/cordis + '@deepseek-ai/dsh-client-ui-cli-account': + specifier: workspace:* + version: link:../../client/ui-cli-account '@deepseek-ai/dsh-skill': specifier: workspace:* version: link:../../skill/skill @@ -7624,9 +7588,6 @@ importers: '@deepseek-ai/dsh-system-prompt': specifier: workspace:* version: link:../../core/system-prompt - '@deepseek-ai/dsh-typert-protocol': - specifier: workspace:* - version: link:../../typert/protocol packages/context/agent-instructions: dependencies: diff --git a/scripts/gen-cordis-catalog.ts b/scripts/gen-cordis-catalog.ts index 4008728fe8..f3df11e368 100644 --- a/scripts/gen-cordis-catalog.ts +++ b/scripts/gen-cordis-catalog.ts @@ -87,7 +87,6 @@ export const SERVICE_PAGE: Record = { compaction: 'compaction.md', cordisInspect: 'extensions.md', authorization: 'credentials.md', - wecom: 'credentials.md', deepseekAccount: 'credentials.md', credentials: 'credentials.md', credentialsController: 'credentials.md', @@ -1003,7 +1002,6 @@ export const TYPE_LINK_EXEMPTIONS: Readonly> = { ConnectionIndexResponse: 'frontend authentication response is owned by packages/client/connection/src/rpc.ts', Profile: 'resolved profile layers are owned by packages/boot/app-boot/README.md', PatchOptions: 'Include patch entries are owned by vendor/include (vendored upstream)', - WecomState: 'authorization view fields are owned by packages/connector/wecom-cli/README.md', McpResourceProvider: 'scoped resource provider is owned by packages/mcp/mcp-resources/README.md', CliOperationId: 'account operation id is owned by packages/connector/cli-account/README.md', AnyCliAccountView: 'generic CLI account view is owned by packages/connector/cli-account/README.md', diff --git a/scripts/gen-doc-graphs.ts b/scripts/gen-doc-graphs.ts index 5328b429b5..184d8bdab5 100644 --- a/scripts/gen-doc-graphs.ts +++ b/scripts/gen-doc-graphs.ts @@ -396,14 +396,6 @@ const SERVICE_ROLES: ServiceRole[] = [ mode: 'core', note: 'Projects the user-settings seam onto the generated Remote namespace: the read is always redacted and every refusal is classified here, not on the seam Definition.', }, - { - key: 'wecom', - pkg: 'wecom-cli', - title: 'WeCom wecom-cli authorization Remote', - mode: 'service', - consumers: ['client-ui-wecom'], - note: 'Runs one Host-owned wecom-cli authorization check or QR-code connection at a time and streams the authorization view to the Plugins page.', - }, { key: 'workspaceFiles', pkg: 'api-workspace-files', diff --git a/scripts/product-package-policy.ts b/scripts/product-package-policy.ts index 64c8227dd4..00148b80df 100644 --- a/scripts/product-package-policy.ts +++ b/scripts/product-package-policy.ts @@ -34,7 +34,6 @@ export const PRODUCT_PACKAGE_POLICY: Readonly> = { 'packages/client/ui-cli-account': { kind: 'none', reason: 'Browser-side account controls over CLI app plugin Remotes; each plugin documents the CLI and skills its account enables.' }, 'packages/client/ui-settings-shell': { kind: 'none', reason: 'Browser-side settings surface; registers no model surface.' }, 'packages/client/ui-settings-session-log': { kind: 'none', reason: 'Browser preference controls request metadata, not model input.' }, - 'packages/client/ui-wecom': { kind: 'none', reason: 'Browser-side Plugins page section; registers no model surface.' }, 'packages/client/ui-settings-agent-loop': { kind: 'none', reason: 'Browser-side settings surface; registers no model surface.' }, 'packages/client/ui-settings-subagent': { kind: 'none', reason: 'Browser-side settings surface; registers no model surface.' }, 'packages/client/ui-settings-web-search': { kind: 'none', reason: 'Browser-side settings surface; registers no model surface.' }, diff --git a/tsconfig.client.json b/tsconfig.client.json index f5b448cbbc..0aff653fe3 100644 --- a/tsconfig.client.json +++ b/tsconfig.client.json @@ -163,7 +163,6 @@ { "path": "./packages/client/ui-plugin-manager/tsconfig.client.json" }, { "path": "./packages/client/ui-cli-account/tsconfig.client.json" }, { "path": "./packages/client/ui-plugin-market" }, - { "path": "./packages/client/ui-wecom" }, { "path": "./packages/client/ui-settings-plugin-inventory" }, { "path": "./packages/client/locale/tsconfig.client.json" }, { "path": "./packages/client/ui-renderer" },