Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(device-link): sync removed-device shared contract
zqchris61caca55b3f4
diff --git a/packages/maker-shared/src/__tests__/deviceLinkContract.test.ts b/packages/maker-shared/src/__tests__/deviceLinkContract.test.tsindex 9c8f7f92de..404696856c 100644--- a/packages/maker-shared/src/__tests__/deviceLinkContract.test.ts+++ b/packages/maker-shared/src/__tests__/deviceLinkContract.test.ts@@ -1,3 +1,4 @@+import { readFileSync } from 'node:fs';import { describe, expect, it, vi } from 'vitest';import {DEVICE_LINK_MEDIA_FETCH_CHANNEL,@@ -123,6 +124,8 @@ describe('device-link shared contract', () => {it('maps connection issue kinds to actionable copy', () => {expect(connectionIssueTitle('auth-failed')).toBe('登录已失效');expect(connectionIssueHint('auth-failed')).toContain('重新登录');+ expect(connectionIssueTitle('device-removed')).toBe('设备已移除');+ expect(connectionIssueHint('device-removed')).toBe('请退出后重新登录,以重新加入设备列表。');expect(connectionIssueTitle('replaced')).toContain('顶替');expect(connectionIssueHint('too-many-connections')).toContain('断开其它设备');expect(connectionIssueHint('version-mismatch')).toContain('升级到最新版本');@@ -130,6 +133,16 @@ describe('device-link shared contract', () => {expect(connectionIssueHint('unstable')).toContain('本机');});+ it('keeps connection issue kinds aligned with the device-link source contract', () => {+ const issueKinds = (path: string) => {+ const source = readFileSync(new URL(path, import.meta.url), 'utf8');+ const union = source.match(/export type DeviceLinkConnectionIssueKind\s*=([^;]+);/);+ expect(union).not.toBeNull();+ return [...union![1].matchAll(/'([^']+)'/g)].map((match) => match[1]).sort();+ };+ expect(issueKinds('../deviceLinkContract.ts')).toEqual(issueKinds('../../../device-link/src/client.ts'));+ });+it('preserves structured remote error codes and access revoked classification', () => {expect(formatRemoteError(Object.assign(new Error('access revoked by target device'), { code: 'ACCESS_REVOKED' }))).toBe('[ACCESS_REVOKED] access revoked by target device');diff --git a/packages/maker-shared/src/deviceLinkContract.ts b/packages/maker-shared/src/deviceLinkContract.tsindex 570fc39019..875910ffbf 100644--- a/packages/maker-shared/src/deviceLinkContract.ts+++ b/packages/maker-shared/src/deviceLinkContract.ts@@ -500,10 +500,11 @@ export function relayStatusHint(status: DeviceLinkRelayStatus, lastSyncedAt: num/*** 镜像 @cindy/device-link 的 DeviceLinkConnectionIssueKind。* maker-shared 保持零运行时依赖(与 DeviceLinkRelayStatus 同款处理),两边字面量- * 必须一致;drift 会被 desktop/mobile 消费处的 TS 赋值检查拦下。+ * 必须一致;deviceLinkContract.test.ts 校验两处字面量,避免消费端迁移后静默漂移。*/export type DeviceLinkConnectionIssueKind =| 'auth-failed'+ | 'device-removed'| 'replaced'| 'too-many-connections'| 'version-mismatch'@@ -514,6 +515,8 @@ export function connectionIssueTitle(kind: DeviceLinkConnectionIssueKind): strinswitch (kind) {case 'auth-failed':return '登录已失效';+ case 'device-removed':+ return '设备已移除';case 'replaced':return '连接被顶替';case 'too-many-connections':@@ -530,6 +533,8 @@ export function connectionIssueHint(kind: DeviceLinkConnectionIssueKind): stringswitch (kind) {case 'auth-failed':return '登录状态已过期,请退出后重新登录。';+ case 'device-removed':+ return '请退出后重新登录,以重新加入设备列表。';case 'replaced':return '本设备的连接被另一处相同设备顶替,正在重新连接。';case 'too-many-connections':