From 805a3a70cc5669bbe2aba82be9d1fc8287c1e6e3 Mon Sep 17 00:00:00 2001 From: gengruilin Date: Tue, 13 Oct 2026 14:07:27 +0800 Subject: [PATCH] revert(feishu): drop the ungranted-permission state from the plugin page The CLI's missing permissions include ones the app has not enabled, such as vc:meeting.realtime:read, which no sign-in can grant, so the section kept a warning and a Grant more action that could never clear it. The connected account is again connected or not; a sign-in that leaves permissions ungranted still succeeds, and a command that needs a missing permission reports it when it runs. --- packages/client/ui-feishu/README.i18n.yaml | 4 +-- packages/client/ui-feishu/README.md | 4 +-- packages/client/ui-feishu/README.zh.md | 4 +-- .../ui-feishu/src/client/FeishuConnection.tsx | 6 +--- .../client/ui-feishu/src/client/connection.ts | 29 ++++--------------- .../client/ui-feishu/src/client/locales.ts | 6 ---- .../tests/components.client.spec.tsx | 12 -------- .../ui-feishu/tests/connection.client.spec.ts | 14 +-------- .../connector/feishu-cli/README.i18n.yaml | 8 ++--- packages/connector/feishu-cli/README.md | 3 +- packages/connector/feishu-cli/README.zh.md | 3 +- packages/connector/feishu-cli/src/account.ts | 19 ++---------- packages/connector/feishu-cli/src/types.ts | 11 +------ .../feishu-cli/tests/account.spec.ts | 28 +----------------- .../extensions/tool-cordis/src/api-catalog.ts | 2 +- 15 files changed, 25 insertions(+), 128 deletions(-) diff --git a/packages/client/ui-feishu/README.i18n.yaml b/packages/client/ui-feishu/README.i18n.yaml index 93e5575626..9f433f4474 100644 --- a/packages/client/ui-feishu/README.i18n.yaml +++ b/packages/client/ui-feishu/README.i18n.yaml @@ -15,8 +15,8 @@ en: d152484eb41ac6b4 zh: 09388d293f9be9cb /deepseek-ai-dsh-client-ui-feishu/use-this-package: - en: 37df0d11443431c4 - zh: b2ecd48185b43539 + en: 3ab90424d79ee916 + zh: 241b77216a6dc01b /deepseek-ai-dsh-client-ui-feishu/understand-the-implementation: en: 3599958abbfb2f52 zh: 68eae79d08462831 diff --git a/packages/client/ui-feishu/README.md b/packages/client/ui-feishu/README.md index ef7414b7cf..c179efa058 100644 --- a/packages/client/ui-feishu/README.md +++ b/packages/client/ui-feishu/README.md @@ -34,11 +34,11 @@ Install the [Feishu plugin bundle](../../connector/feishu/README.md), which inse | Not connected, app linked | **Sign in to Feishu** opens the Feishu authorization page | | Any state with a linked app | The section shows the app id; **Change app** asks for confirmation, then links an app again, which replaces the CLI's configuration for the terminal too and requires another sign-in | | Step 1: Link a Feishu app, or Step 2: Sign in to Feishu | The browser that clicked opens the step's Feishu page once; **Open Feishu page** opens it again, and **Cancel** ends the step | -| Connected | **Sign out** asks for confirmation, then signs out the CLI's default account. When the last sign-in left permissions ungranted, the section says how many and offers **Grant more**, which signs in again | +| Connected | **Sign out** asks for confirmation, then signs out the CLI's default account | | Cannot confirm sign-in right now | **Retry** runs the connection again and keeps the existing setup and sign-in | | Feishu component not running | The Host's `feishu` row did not load; the section points to the component list for the reason, and **Retry** subscribes to the Host again | -Leaving the page does not cancel a connection, which the Host owns. Each step opens its page from the user's own click, because browsers block a window that opens long after it. A failed step or sign-out shows **The action did not finish. Try again.** in the section; a failed page action shows a toast, and so does a finished app link, sign-in, or sign-out; a sign-in that left permissions ungranted shows a warning toast instead of a success one. The section notes that the account is shared with the Feishu CLI in the computer's terminal. +Leaving the page does not cancel a connection, which the Host owns. Each step opens its page from the user's own click, because browsers block a window that opens long after it. A failed step or sign-out shows **The action did not finish. Try again.** in the section; a failed page action shows a toast, and so does a finished app link, sign-in, or sign-out. The section notes that the account is shared with the Feishu CLI in the computer's terminal. ----- diff --git a/packages/client/ui-feishu/README.zh.md b/packages/client/ui-feishu/README.zh.md index baab2d56f6..fec7f03fe6 100644 --- a/packages/client/ui-feishu/README.zh.md +++ b/packages/client/ui-feishu/README.zh.md @@ -34,11 +34,11 @@ kind: "package-reference" | 未连接,已关联应用 | **登录飞书账号**打开飞书授权页面 | | 任何已关联应用的状态 | 区块显示应用 id;**更换应用**确认后重新关联应用,这会一并替换终端使用的 CLI 配置,之后需要重新登录 | | 第 1 步:关联飞书应用,或第 2 步:登录飞书账号 | 点击的浏览器会把这一步的飞书页面打开一次;**打开飞书页面**再次打开,**取消**结束这一步 | -| 已连接 | **退出登录**确认后退出 CLI 的默认账号。上次登录仍有权限未被授予时,区块说明数量并提供**补充授权**,它会重新登录 | +| 已连接 | **退出登录**确认后退出 CLI 的默认账号 | | 暂时无法确认登录状态 | **重试**重新运行连接,保留现有配置和登录 | | 飞书组件未运行 | Host 的 `feishu` 行没有加载;区块提示到组件列表查看原因,**重试**重新订阅 Host | -离开页面不会取消连接,连接由 Host 持有。每一步都由用户自己的点击打开页面,因为浏览器会拦截点击很久之后才打开的窗口。某一步或退出登录失败时,区块显示**操作未完成,请重试**;页面操作失败时显示提示,关联应用、登录或退出登录完成时也会显示提示;登录后仍有权限未被授予时,显示提醒而不是成功提示。区块会说明该账号与这台电脑终端里的飞书 CLI 共用。 +离开页面不会取消连接,连接由 Host 持有。每一步都由用户自己的点击打开页面,因为浏览器会拦截点击很久之后才打开的窗口。某一步或退出登录失败时,区块显示**操作未完成,请重试**;页面操作失败时显示提示,关联应用、登录或退出登录完成时也会显示提示。区块会说明该账号与这台电脑终端里的飞书 CLI 共用。 ----- diff --git a/packages/client/ui-feishu/src/client/FeishuConnection.tsx b/packages/client/ui-feishu/src/client/FeishuConnection.tsx index 49f45f1ad4..3d51b3eae3 100644 --- a/packages/client/ui-feishu/src/client/FeishuConnection.tsx +++ b/packages/client/ui-feishu/src/client/FeishuConnection.tsx @@ -48,7 +48,6 @@ export function FeishuConnectionSection(props: FaceProps): ReactNode { case 'unavailable': actions.push(action('action.retry', check)); detail = t('detail.unavailable'); break case 'stopped': actions.push(action('action.retry', retry)); detail = t('detail.stopped'); break case 'connected': - if (shown.ungranted !== undefined) actions.push(action('action.grantMore', signIn)) actions.push(action('action.signOut', () => { setConfirming('sign-out') })) detail = shown.userName === undefined ? t('detail.connected') : t('detail.connectedAs', { name: shown.userName }) break @@ -71,9 +70,6 @@ export function FeishuConnectionSection(props: FaceProps): ReactNode {
{actions}
{detail === undefined ? null :

{detail}

} - {shown.phase === 'connected' && shown.ungranted !== undefined - ?

{t('detail.ungranted', { count: shown.ungranted })}

- : null} {'appId' in shown ?
{t('app.linked', { id: shown.appId })} @@ -151,7 +147,7 @@ export function FeishuConnectionActivation(props: FaceProps & PropsRuntime<'plug export function FeishuConnectionToast({ useFeishuConnection, dismissNotice, t }: FaceProps): ReactNode { const notice = useFeishuConnection(value => value.notice) if (notice === undefined) return null - const failed = notice.kind === 'action-failed' || notice.kind === 'connected-partially' + const failed = notice.kind === 'action-failed' return ( } : { tone: 'success' as const }} /> diff --git a/packages/client/ui-feishu/src/client/connection.ts b/packages/client/ui-feishu/src/client/connection.ts index b417b6bac6..099deb251c 100644 --- a/packages/client/ui-feishu/src/client/connection.ts +++ b/packages/client/ui-feishu/src/client/connection.ts @@ -13,7 +13,7 @@ export const FEISHU_PACKAGE = '@deepseek-ai/dsh-feishu' /** A transient outcome the page reports outside its own lifetime. */ export interface ConnectionNotice { readonly seq: number - readonly kind: 'app-linked' | 'connected' | 'connected-partially' | 'signed-out' | 'action-failed' + readonly kind: 'app-linked' | 'connected' | 'signed-out' | 'action-failed' } /** The page's whole view: the Host's account view plus this browser's pending action and notice. */ @@ -29,6 +29,7 @@ export interface ConnectionSnapshot { readonly notice: ConnectionNotice | undefined } +const NOTICE = { 'link-app': 'app-linked', 'sign-in': 'connected', 'sign-out': 'signed-out' } as const /** The step a connection or sign-out in progress shows. */ export type ConnectionStep = 'configuring' | 'authorizing' | 'connecting' | 'signing-out' @@ -39,14 +40,7 @@ export type ConnectionPresentation = | { readonly phase: 'disconnected'; readonly next: 'link-app'; readonly failed: boolean } | { readonly phase: 'disconnected'; readonly next: 'sign-in'; readonly appId: FeishuAppId; readonly failed: boolean } | { readonly phase: 'unavailable'; readonly appId: FeishuAppId; readonly failed: boolean } - | { - readonly phase: 'connected' - readonly appId: FeishuAppId - readonly userName: string | undefined - /** Requested permissions the last sign-in did not grant. */ - readonly ungranted: number | undefined - readonly failed: boolean - } + | { readonly phase: 'connected'; readonly appId: FeishuAppId; readonly userName: string | undefined; readonly failed: boolean } | { readonly phase: 'connecting' readonly step: ConnectionStep @@ -107,8 +101,7 @@ export function presentConnection(snapshot: Pick['kind'], state: FeishuState): ConnectionNotice['kind'] | undefined { - switch (kind) { - case 'check': return undefined - case 'link-app': return 'app-linked' - case 'sign-in': return state.account.state === 'connected' && state.account.ungrantedPermissions !== undefined ? 'connected-partially' : 'connected' - case 'sign-out': return 'signed-out' - /* v8 ignore next -- closed operation kind union */ - default: return assertNever(kind) - } -} - function openAuthorizationPage(url: string | undefined): void { if (url !== undefined && URL.canParse(url) && new URL(url).protocol === 'https:') window.open(url, '_blank', 'noopener,noreferrer') } @@ -226,8 +208,7 @@ export class FeishuConnection { const result = state.result if (result === undefined || result.id !== this.started) return this.started = undefined - const notice = result.outcome === 'succeeded' ? noticeOf(result.kind, state) : undefined - if (notice !== undefined) this.notify(notice) + if (result.outcome === 'succeeded' && result.kind !== 'check') this.notify(NOTICE[result.kind]) } private async start(call: () => Promise>): Promise { diff --git a/packages/client/ui-feishu/src/client/locales.ts b/packages/client/ui-feishu/src/client/locales.ts index 7f892a31aa..0dfc927f75 100644 --- a/packages/client/ui-feishu/src/client/locales.ts +++ b/packages/client/ui-feishu/src/client/locales.ts @@ -22,7 +22,6 @@ export const zh = { 'detail.stopped': '“飞书 CLI 与技能”组件没有运行,可以在下方组件列表查看原因,处理后重试。', 'detail.connected': '可以在对话中直接请 Agent 使用飞书。', 'detail.connectedAs': '已登录为 {name}。可以在对话中直接请 Agent 使用飞书。', - 'detail.ungranted': '有 {count} 项权限尚未生效,可能正在等待企业管理员审批。审批通过后,点击“补充授权”。', 'detail.configuring': '在打开的飞书页面中新建或选择应用,完成后回到这里登录。页面没有打开时,点击“打开飞书页面”。', 'detail.authorizing': '在打开的飞书页面中确认授权,完成后回到这里查看结果。页面没有打开时,点击“打开飞书页面”。', hint: '飞书账号与这台电脑终端里的飞书 CLI 共用。', @@ -33,7 +32,6 @@ export const zh = { 'action.signIn': '登录飞书账号', 'action.open': '打开飞书页面', 'action.cancel': '取消', - 'action.grantMore': '补充授权', 'action.signOut': '退出登录', 'action.replaceApp': '更换应用', 'action.retry': '重试', @@ -51,7 +49,6 @@ export const zh = { 'activation.later': '稍后', 'notice.app-linked': '飞书应用已关联,下一步登录飞书账号', 'notice.connected': '飞书已连接', - 'notice.connected-partially': '飞书已连接,部分权限尚未生效', 'notice.signed-out': '已退出飞书登录', 'notice.action-failed': '操作未完成,请重试', close: '关闭', @@ -78,7 +75,6 @@ export const en: Record = { 'detail.stopped': 'The Feishu CLI and skills component is not running. See the component list below for the reason, then retry.', 'detail.connected': 'Ask the agent to use Feishu directly in a conversation.', 'detail.connectedAs': 'Signed in as {name}. Ask the agent to use Feishu directly in a conversation.', - 'detail.ungranted': '{count} permissions are not in effect yet and may be waiting for an administrator to approve them. After approval, select Grant more.', 'detail.configuring': 'Create or choose an app on the Feishu page, then come back here to sign in. If the page did not open, select Open Feishu page.', 'detail.authorizing': 'Confirm the authorization on the Feishu page, then come back here to see the result. If the page did not open, select Open Feishu page.', hint: 'The Feishu account is shared with the Feishu CLI in this computer\'s terminal.', @@ -89,7 +85,6 @@ export const en: Record = { 'action.signIn': 'Sign in to Feishu', 'action.open': 'Open Feishu page', 'action.cancel': 'Cancel', - 'action.grantMore': 'Grant more', 'action.signOut': 'Sign out', 'action.replaceApp': 'Change app', 'action.retry': 'Retry', @@ -107,7 +102,6 @@ export const en: Record = { 'activation.later': 'Later', 'notice.app-linked': 'Feishu app linked. Next, sign in to Feishu.', 'notice.connected': 'Feishu connected', - 'notice.connected-partially': 'Feishu connected; some permissions are not in effect yet', 'notice.signed-out': 'Signed out of Feishu', 'notice.action-failed': 'The action did not finish. Try again.', close: 'Close', diff --git a/packages/client/ui-feishu/tests/components.client.spec.tsx b/packages/client/ui-feishu/tests/components.client.spec.tsx index f5b5e0acfc..e0fc79b3d2 100644 --- a/packages/client/ui-feishu/tests/components.client.spec.tsx +++ b/packages/client/ui-feishu/tests/components.client.spec.tsx @@ -120,16 +120,6 @@ it('shows the linked app and changes it only after confirmation', () => { expect(b.face.linkApp).toHaveBeenCalledOnce() }) -it('explains ungranted permissions and grants more through another sign-in', () => { - const b = fixture({ account: { state: 'connected', appId: APP, userName: '张三', ungrantedPermissions: 4 } }) - render() - expect(screen.getByText(text('detail.ungranted', { count: '4' }))).toBeTruthy() - fireEvent.click(button(zh['action.grantMore'])) - expect(b.face.signIn).toHaveBeenCalledOnce() - b.set({ feishu: { account: { state: 'connected', appId: APP, userName: '张三' } } }) - expect(screen.queryByRole('button', { name: zh['action.grantMore'] })).toBeNull() -}) - it('disables actions while one is pending or the Host stream is offline', () => { const b = fixture({ account: { state: 'unconfigured' } }) render() @@ -185,6 +175,4 @@ it('reports the latest notice', () => { expect(screen.getByText(zh['notice.signed-out'])).toBeTruthy() b.set({ notice: { seq: 2, kind: 'action-failed' } }) expect(screen.getByText(zh['notice.action-failed'])).toBeTruthy() - b.set({ notice: { seq: 3, kind: 'connected-partially' } }) - expect(screen.getByText(zh['notice.connected-partially'])).toBeTruthy() }) diff --git a/packages/client/ui-feishu/tests/connection.client.spec.ts b/packages/client/ui-feishu/tests/connection.client.spec.ts index b08bc3eb8a..f5dc9b6ceb 100644 --- a/packages/client/ui-feishu/tests/connection.client.spec.ts +++ b/packages/client/ui-feishu/tests/connection.client.spec.ts @@ -27,10 +27,7 @@ it.each<[string, FeishuState | undefined, ReturnType]> ['a linked app', SIGNED_OUT, { phase: 'disconnected', next: 'sign-in', appId: APP, failed: false }], ['a failed sign-in', { ...SIGNED_OUT, result: { id: OP, kind: 'sign-in', outcome: 'failed' } }, { phase: 'disconnected', next: 'sign-in', appId: APP, failed: true }], ['an unconfirmed sign-in', { account: { state: 'unverified', appId: APP } }, { phase: 'unavailable', appId: APP, failed: false }], - ['a connection', { account: { state: 'connected', appId: APP, userName: '张三' } }, - { phase: 'connected', appId: APP, userName: '张三', ungranted: undefined, failed: false }], - ['a partial connection', { account: { state: 'connected', appId: APP, ungrantedPermissions: 3 } }, - { phase: 'connected', appId: APP, userName: undefined, ungranted: 3, failed: false }], + ['a connection', { account: { state: 'connected', appId: APP, userName: '张三' } }, { phase: 'connected', appId: APP, userName: '张三', failed: false }], ['app setup', { ...SIGNED_OUT, operation: operation('link-app', 'configuring', 'https://open.feishu.cn/x') }, connecting('configuring', 'https://open.feishu.cn/x', true)], ['sign-in', { ...SIGNED_OUT, operation: operation('sign-in', 'authorizing') }, connecting('authorizing', undefined, true)], ['an app link check', { ...SIGNED_OUT, operation: operation('link-app', 'checking') }, connecting('connecting', undefined, true)], @@ -140,15 +137,6 @@ it('opens each new link of an operation this browser started once, then reports expect(b.snapshot().notice).toBeUndefined() }) -it('reports a sign-in that left permissions ungranted', async () => { - const b = fixture() - await b.publish(SIGNED_OUT) - b.face.signIn() - await settle(b) - await b.publish({ account: { state: 'connected', appId: APP, ungrantedPermissions: 2 }, result: { id: OP, kind: 'sign-in', outcome: 'succeeded' } }) - expect(b.snapshot().notice).toEqual({ seq: 1, kind: 'connected-partially' }) -}) - it('checks again without a notice', async () => { const b = fixture() await b.publish({ account: { state: 'unverified', appId: APP } }) diff --git a/packages/connector/feishu-cli/README.i18n.yaml b/packages/connector/feishu-cli/README.i18n.yaml index 34714bd8eb..873c1afaa4 100644 --- a/packages/connector/feishu-cli/README.i18n.yaml +++ b/packages/connector/feishu-cli/README.i18n.yaml @@ -24,8 +24,8 @@ en: f0d233dd69bb21c7 zh: 4aedc72d52cd0523 /deepseek-ai-dsh-feishu-cli/use-this-package/account-operations: - en: 080b49fc53d58e33 - zh: 7312f7d47e930e10 + en: c734e1b33eb362b8 + zh: 70978a41c5bbeb43 /deepseek-ai-dsh-feishu-cli/use-this-package/configure: en: 2aa0db3a03b797f8 zh: 6d63b0c12de0b97c @@ -66,8 +66,8 @@ en: 1f6b842a95e14ce4 zh: 0d57cdec5e828828 /deepseek-ai-dsh-feishu-cli/known-limitations-and-deferred-work: - en: 3da69a24a87a35e2 - zh: 2e5111231f99db77 + en: 17bc46eb45cd97de + zh: 958c14fb116e6acf /deepseek-ai-dsh-feishu-cli/known-limitations-and-deferred-work/dev-note: en: ae8a15329b9dc2d8 zh: bec9872542b38b58 diff --git a/packages/connector/feishu-cli/README.md b/packages/connector/feishu-cli/README.md index 61999d9eed..85800dbb25 100644 --- a/packages/connector/feishu-cli/README.md +++ b/packages/connector/feishu-cli/README.md @@ -49,7 +49,7 @@ The `feishu` Remote serves the Plugins page. It runs at most one account operati | `signOut()` | Runs `auth logout --json`, which also signs out the user's own terminal, then checks again | | `cancel(id)` | Cancels that operation and waits for its command to exit; a finished id is ignored | -A check runs `auth status --verify --json`. The account reads `connected` only when the CLI reports an available user that its server verified, `signed-out` when the user is missing, not configured, or needs a refresh, `unconfigured` when no app exists, and `unverified` otherwise, for example when verification cannot reach the server. Every state except `unconfigured` carries the configured `appId`. Each link that `config init` prints and each device-authorization link that `auth login` reports is offered only when it is an HTTPS address on `feishu.cn` or `larksuite.com`. A sign-in that leaves requested permissions ungranted (`auth login` exits with code 3 and lists them as missing) still succeeds; the connected account then carries `ungrantedPermissions` for that user until a sign-in grants every permission, another user is signed in, or the user signs out. Results report succeeded, cancelled, or failed; native diagnostics stay on the Host. +A check runs `auth status --verify --json`. The account reads `connected` only when the CLI reports an available user that its server verified, `signed-out` when the user is missing, not configured, or needs a refresh, `unconfigured` when no app exists, and `unverified` otherwise, for example when verification cannot reach the server. Every state except `unconfigured` carries the configured `appId`. Each link that `config init` prints and each device-authorization link that `auth login` reports is offered only when it is an HTTPS address on `feishu.cn` or `larksuite.com`. A sign-in that leaves requested permissions ungranted (`auth login` exits with code 3 and lists them as missing) still succeeds; a command that later needs a missing permission reports it. Results report succeeded, cancelled, or failed; native diagnostics stay on the Host. ### Configure @@ -145,7 +145,6 @@ Loading appends a tool result and does not rewrite earlier context. - Sign-in reads the device-authorization link and the completion from `lark-cli auth login --json` events; a CLI version that changes those events fails the connection with a retryable result. - Under a file sandbox, a token refresh during an ordinary command can be denied and then needs single-command approval. - A failed skill catalog stays empty until the plugin reloads. -- The ungranted-permission count lives in Host memory and is lost when the Host restarts. The CLI does not tell a permission that waits for an administrator's approval from one that was declined. ### Dev Note diff --git a/packages/connector/feishu-cli/README.zh.md b/packages/connector/feishu-cli/README.zh.md index 6a5e4edf0c..e4d2246268 100644 --- a/packages/connector/feishu-cli/README.zh.md +++ b/packages/connector/feishu-cli/README.zh.md @@ -49,7 +49,7 @@ kind: "package-reference" | `signOut()` | 运行 `auth logout --json`,同时退出用户自己终端里的登录,然后重新检查 | | `cancel(id)` | 取消该操作并等待其命令退出;已结束的 id 会被忽略 | -检查运行 `auth status --verify --json`。只有 CLI 报告用户可用且已被服务端核实时,账号才是 `connected`;用户缺失、未配置或需要刷新时为 `signed-out`;没有应用时为 `unconfigured`;其他情况为 `unverified`,例如核实时无法连到服务端。除 `unconfigured` 外,每种状态都带有已配置的 `appId`。`config init` 打印的链接和 `auth login` 报告的设备授权链接,只有是 `feishu.cn` 或 `larksuite.com` 上的 HTTPS 地址时才会提供。登录后仍有申请的权限未被授予时(`auth login` 以退出码 3 结束并把它们列为缺失),登录仍算成功;此后已连接的账号会带上该用户的 `ungrantedPermissions`,直到某次登录授予了全部权限、换成其他用户登录或用户退出登录。结果分为成功、已取消和失败;原生诊断信息保留在 Host 上。 +检查运行 `auth status --verify --json`。只有 CLI 报告用户可用且已被服务端核实时,账号才是 `connected`;用户缺失、未配置或需要刷新时为 `signed-out`;没有应用时为 `unconfigured`;其他情况为 `unverified`,例如核实时无法连到服务端。除 `unconfigured` 外,每种状态都带有已配置的 `appId`。`config init` 打印的链接和 `auth login` 报告的设备授权链接,只有是 `feishu.cn` 或 `larksuite.com` 上的 HTTPS 地址时才会提供。登录后仍有申请的权限未被授予时(`auth login` 以退出码 3 结束并把它们列为缺失),登录仍算成功;之后需要这些权限的命令会报告缺少哪些。结果分为成功、已取消和失败;原生诊断信息保留在 Host 上。 ### 配置 @@ -145,7 +145,6 @@ Do not install another lark-cli or run `lark-cli update`. - 登录从 `lark-cli auth login --json` 的事件中读取设备授权链接和完成结果;CLI 版本改变这些事件时,连接以可重试的结果失败。 - 在文件沙箱下,普通命令中的 token 刷新可能被拒绝,此时需要单条命令审批。 - skill 目录读取失败后,在插件重新加载前保持为空。 -- 未生效权限的数量保存在 Host 内存中,Host 重启后丢失。CLI 不区分等待管理员审批的权限和已被拒绝的权限。 ### 开发备注 diff --git a/packages/connector/feishu-cli/src/account.ts b/packages/connector/feishu-cli/src/account.ts index 3578ccf6c6..e5eba63bdf 100644 --- a/packages/connector/feishu-cli/src/account.ts +++ b/packages/connector/feishu-cli/src/account.ts @@ -49,8 +49,6 @@ class Operation { /** Runs at most one account operation at a time; subscribers observe it without owning it. */ export class FeishuAccount { private account: FeishuAccountState = { state: 'unchecked' } - /** The user the last completed sign-in left without some requested permissions, and how many. */ - private ungranted: { readonly openId: string; readonly count: number } | undefined private active: Operation | undefined private result: FeishuOperationResult | undefined private readonly lifetime = new AbortController() @@ -196,7 +194,6 @@ export class FeishuAccount { if (complete === undefined || (login.exitCode !== 0 && !(login.exitCode === 3 && complete.missing.length > 0))) { throw new Error('feishu: auth login did not complete') } - this.ungranted = complete.missing.length === 0 ? undefined : { openId: complete.user_open_id, count: complete.missing.length } this.stage(operation, 'verifying') const found = await this.check(signal) if (found.account.state !== 'connected' || found.openId !== complete.user_open_id) throw new Error('feishu: sign-in did not verify') @@ -208,24 +205,14 @@ export class FeishuAccount { const result = await this.cli.run(args, signal, { timeoutMs: this.limits.commandTimeoutMs }) if (result.exitCode !== 0) { if (!NotConfigured.safeParse(parseJson(args, result.stderr)).success) throw new Error('feishu: auth status failed') - this.ungranted = undefined return { account: this.publish({ state: 'unconfigured' }) } } const status = Status.parse(parseJson(args, result.stdout)) const appId = brandString(status.appId) const user = status.identities.user - if (!user.available || user.verified !== true) { - const signedOut = SIGNED_OUT.has(user.status) - if (signedOut) this.ungranted = undefined - return { account: this.publish({ state: signedOut ? 'signed-out' : 'unverified', appId }), openId: user.openId } - } - const ungranted = this.ungranted !== undefined && this.ungranted.openId === user.openId ? this.ungranted.count : undefined - const account: FeishuAccountState = { - state: 'connected', - appId, - ...user.userName === undefined ? {} : { userName: user.userName }, - ...ungranted === undefined ? {} : { ungrantedPermissions: ungranted }, - } + const account: FeishuAccountState = user.available && user.verified === true + ? { state: 'connected', appId, ...user.userName === undefined ? {} : { userName: user.userName } } + : { state: SIGNED_OUT.has(user.status) ? 'signed-out' : 'unverified', appId } return { account: this.publish(account), openId: user.openId } } diff --git a/packages/connector/feishu-cli/src/types.ts b/packages/connector/feishu-cli/src/types.ts index 2fe953345f..1669233afa 100644 --- a/packages/connector/feishu-cli/src/types.ts +++ b/packages/connector/feishu-cli/src/types.ts @@ -12,16 +12,7 @@ export type FeishuAppId = Branded<'FeishuAppId'> export type FeishuAccountState = | { readonly state: 'unchecked' | 'unconfigured' } | { readonly state: 'signed-out' | 'unverified'; readonly appId: FeishuAppId } - | { - readonly state: 'connected' - readonly appId: FeishuAppId - readonly userName?: string - /** - * Requested permissions the last sign-in on this Host did not grant, which may await an administrator's - * approval; absent when every permission was granted or no sign-in ran since the Host started. - */ - readonly ungrantedPermissions?: number - } + | { readonly state: 'connected'; readonly appId: FeishuAppId; readonly userName?: string } /** The account operation in progress; links are restricted to HTTPS Feishu and Lark hosts. */ export interface FeishuOperationState { diff --git a/packages/connector/feishu-cli/tests/account.spec.ts b/packages/connector/feishu-cli/tests/account.spec.ts index 282a14fe23..31731602fa 100644 --- a/packages/connector/feishu-cli/tests/account.spec.ts +++ b/packages/connector/feishu-cli/tests/account.spec.ts @@ -59,7 +59,6 @@ describe('FeishuAccount', () => { account = new FeishuAccount(new FeishuCli(ctx.subprocess, ctx.shellEnv, LIMITS), LIMITS, () => { changes++ }) }) - const start = (kind: Parameters[0]) => account.start(kind) const settled = async (id: FeishuOperationId): Promise => { await vi.waitFor(() => { expect(account.snapshot().result?.id).toBe(id) }) return account.snapshot() @@ -118,37 +117,12 @@ describe('FeishuAccount', () => { authorizing.reply({ stdout: login(['im:message']) + '\n', exitCode: 3 }) expect(await settled(id)).toEqual({ - account: { state: 'connected', appId: APP, userName: '张三', ungrantedPermissions: 1 }, + account: { state: 'connected', appId: APP, userName: '张三' }, result: { id, kind: 'sign-in', outcome: 'succeeded' }, }) expect(commands()).toEqual(['auth login --json', STATUS]) }) - it('keeps the ungranted count for the signed-in user until a full sign-in, another user, or a sign-out', async () => { - const OTHER = status({ status: 'ready', available: true, verified: true, openId: 'ou_2' }) - script[STATUS] = [CONNECTED, CONNECTED, OTHER, CONNECTED, CONNECTED, SIGNED_OUT, CONNECTED] - script['auth login --json'] = [{ stdout: login(['im:message', 'drive:file']) + '\n', exitCode: 3 }, { stdout: login() + '\n' }] - script['auth logout --json'] = [{ stdout: '{"ok":true}' }] - const account = async (kind: 'check' | 'sign-in' | 'sign-out') => (await settled(start(kind))).account - - expect(await account('sign-in')).toEqual({ state: 'connected', appId: APP, userName: '张三', ungrantedPermissions: 2 }) - expect(await account('check')).toEqual({ state: 'connected', appId: APP, userName: '张三', ungrantedPermissions: 2 }) - expect(await account('check')).toEqual({ state: 'connected', appId: APP }) - expect(await account('check')).toEqual({ state: 'connected', appId: APP, userName: '张三', ungrantedPermissions: 2 }) - script['auth login --json'] = [{ stdout: login(['im:message']) + '\n', exitCode: 3 }] - expect(await account('sign-in')).toEqual({ state: 'connected', appId: APP, userName: '张三', ungrantedPermissions: 1 }) - expect(await account('sign-out')).toEqual({ state: 'signed-out', appId: APP }) - expect(await account('check')).toEqual({ state: 'connected', appId: APP, userName: '张三' }) - }) - - it('drops the ungranted count when the CLI has no app', async () => { - script[STATUS] = [CONNECTED, NOT_CONFIGURED, CONNECTED] - script['auth login --json'] = [{ stdout: login(['im:message']) + '\n', exitCode: 3 }] - expect((await settled(start('sign-in'))).account).toMatchObject({ ungrantedPermissions: 1 }) - expect((await settled(start('check'))).account).toEqual({ state: 'unconfigured' }) - expect((await settled(start('check'))).account).toEqual({ state: 'connected', appId: APP, userName: '张三' }) - }) - it.each<[string, 'link-app' | 'sign-in', Record]>([ ['a failed app setup', 'link-app', { 'config init --new': [{ exitCode: 1 }] }], ['an app setup that left no app', 'link-app', { [STATUS]: [NOT_CONFIGURED], 'config init --new': [{}] }], diff --git a/packages/extensions/tool-cordis/src/api-catalog.ts b/packages/extensions/tool-cordis/src/api-catalog.ts index 59be674ed2..e9fd9a2ca3 100644 --- a/packages/extensions/tool-cordis/src/api-catalog.ts +++ b/packages/extensions/tool-cordis/src/api-catalog.ts @@ -6185,7 +6185,7 @@ export const TYPE_API: readonly TypeApiEntry[] = [ }, { name: 'FeishuAccountState', - declaration: 'export type FeishuAccountState = {\n readonly state: \'unchecked\' | \'unconfigured\';\n} | {\n readonly state: \'signed-out\' | \'unverified\';\n readonly appId: FeishuAppId;\n} | {\n readonly state: \'connected\';\n readonly appId: FeishuAppId;\n readonly userName?: string;\n readonly ungrantedPermissions?: number;\n};', + declaration: 'export type FeishuAccountState = {\n readonly state: \'unchecked\' | \'unconfigured\';\n} | {\n readonly state: \'signed-out\' | \'unverified\';\n readonly appId: FeishuAppId;\n} | {\n readonly state: \'connected\';\n readonly appId: FeishuAppId;\n readonly userName?: string;\n};', }, { name: 'FeishuAppId',