Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(desktop): 手机远控的每一轮告知 agent 来源,倾向自包含单文件产物 (#1471)
Chris Zhanga8919cf07e12
diff --git a/apps/desktop/src/main/__tests__/mobileClientPromptNote.test.ts b/apps/desktop/src/main/__tests__/mobileClientPromptNote.test.tsnew file mode 100644index 0000000000..55f6294843--- /dev/null+++ b/apps/desktop/src/main/__tests__/mobileClientPromptNote.test.ts@@ -0,0 +1,333 @@+/**+ * 手机客户端说明:来源判据(体验分流用,**非**安全边界 —— 平台值由对端自报,见+ * device-link/invoke-context 的可信度说明)、wire 注入形态、以及「只进喂给 agent 的+ * 内容、不进落库原话」这条不变量的源码级守卫。+ */+import { readFileSync } from 'node:fs';+import { resolve } from 'node:path';+import { describe, it, expect, beforeEach } from 'vitest';++import {+ clearControllerPlatforms,+ getControllerPlatform,+ isMobilePlatform,+ setControllerPlatform,+} from '../device-link/controllerPlatform';+import {+ isDeviceLinkInvoke,+ isMobileControllerInvoke,+ runDeviceLinkInvokeContext,+} from '../device-link/invoke-context';+import {+ prependHandoffToUserMessage,+ prependNoteToWireUserMessage,+} from '../maker-ipc/agentHandoff';+import {+ buildMobileClientPromptNote,+ stampMobileClientOrigin,+ stripMainOnlySendOpts,+} from '../maker-ipc/mobileClientPromptNote';++describe('isMobilePlatform(平台判据)', () => {+ it('手机平台为真', () => {+ expect(isMobilePlatform('ios')).toBe(true);+ expect(isMobilePlatform('android')).toBe(true);+ });++ it('桌面平台为假', () => {+ expect(isMobilePlatform('darwin')).toBe(false);+ expect(isMobilePlatform('win32')).toBe(false);+ expect(isMobilePlatform('linux')).toBe(false);+ });++ it('未知 / 缺失一律为假(fail-closed,不能靠 !isDesktopPlatform 取反)', () => {+ // presence 未到、旧客户端报了别的字符串时,平台是「未知」而不是「手机」。+ expect(isMobilePlatform(undefined)).toBe(false);+ expect(isMobilePlatform(null)).toBe(false);+ expect(isMobilePlatform('')).toBe(false);+ expect(isMobilePlatform('freebsd')).toBe(false);+ expect(isMobilePlatform('iOS')).toBe(false); // 大小写敏感,presence 报的是小写+ });+});++describe('控制端平台登记表', () => {+ beforeEach(() => {+ clearControllerPlatforms();+ });++ it('登记后可按 deviceId 查回;未登记为 undefined', () => {+ setControllerPlatform('dev-phone', 'ios');+ expect(getControllerPlatform('dev-phone')).toBe('ios');+ expect(getControllerPlatform('dev-unknown')).toBeUndefined();+ });++ it('清空后不残留(账号切换 / 连接重置)', () => {+ setControllerPlatform('dev-phone', 'ios');+ clearControllerPlatforms();+ expect(getControllerPlatform('dev-phone')).toBeUndefined();+ });+});++describe('isMobileControllerInvoke(来源判据)', () => {+ it('本机 renderer(无 device-link 上下文)为假', () => {+ expect(isDeviceLinkInvoke()).toBe(false);+ expect(isMobileControllerInvoke()).toBe(false);+ });++ it('手机控制端为真', () => {+ const seen = runDeviceLinkInvokeContext(+ { controllerDeviceId: 'dev-phone', channel: 'maker:send', controllerPlatform: 'android' },+ () => isMobileControllerInvoke(),+ );+ expect(seen).toBe(true);+ });++ it('另一台桌面作控制端为假(远控不等于手机)', () => {+ const seen = runDeviceLinkInvokeContext(+ { controllerDeviceId: 'dev-mac', channel: 'maker:send', controllerPlatform: 'darwin' },+ () => isMobileControllerInvoke(),+ );+ expect(seen).toBe(false);+ });++ it('platform 未知为假,但仍算 device-link 调用(两个判据互不干扰)', () => {+ const seen = runDeviceLinkInvokeContext(+ { controllerDeviceId: 'dev-x', channel: 'maker:send' },+ () => ({ mobile: isMobileControllerInvoke(), remote: isDeviceLinkInvoke() }),+ );+ expect(seen).toEqual({ mobile: false, remote: true });+ });++ it('跨 await 后仍成立 —— send 路径外面套了串行锁,上下文必须能穿过它', async () => {+ const seen = await runDeviceLinkInvokeContext(+ { controllerDeviceId: 'dev-phone', channel: 'maker:send', controllerPlatform: 'ios' },+ async () => {+ // 模拟 withSendToSessionLock:先 await 一个别处 resolve 的锁,再读来源。+ let release: (() => void) | null = null;+ const lock = new Promise<void>((r) => {+ release = r;+ });+ setTimeout(() => release?.(), 0);+ await lock;+ return isMobileControllerInvoke();+ },+ );+ expect(seen).toBe(true);+ });++ it('上下文结束后不残留', () => {+ runDeviceLinkInvokeContext(+ { controllerDeviceId: 'dev-phone', channel: 'maker:send', controllerPlatform: 'ios' },+ () => isMobileControllerInvoke(),+ );+ expect(isMobileControllerInvoke()).toBe(false);+ });+});++describe('buildMobileClientPromptNote(送进模型的文本)', () => {+ const note = buildMobileClientPromptNote();++ it('首句声明这不是用户消息(否则模型会当请求回应或复述)', () => {+ expect(note.startsWith('[客户端说明]')).toBe(true);+ expect(note).toContain('不是用户发来的消息');+ expect(note).toContain('不要把它当作用户的请求');+ });++ it('给出自包含单文件的产出偏好', () => {+ expect(note).toContain('手机客户端');+ expect(note).toContain('自包含单文件');+ });++ it('是偏好不是禁令:用户明确要多文件时不被挡住', () => {+ expect(note).toContain('优先');+ expect(note).toContain('明确要求多文件时照常产出');+ expect(note).not.toContain('必须做成');+ expect(note).not.toContain('禁止');+ });++ it('不写「不要给本地路径」—— 手机端本就能打开路径,那样写会和已有能力打架', () => {+ // 路径在手机上可点、可渲染、同目录资源会被取回(见 mobile 的 HtmlFileReader /+ // htmlLocalResources)。这里只要求「别只回一个路径」,不否定给路径本身。+ expect(note).not.toContain('不要给出路径');+ expect(note).not.toContain('不要给本地路径');+ expect(note).toContain('不要只回一个路径');+ });++ it('逐字节稳定:不含时间戳 / 随机量等易变内容(否则污染 prompt 前缀假设)', () => {+ expect(buildMobileClientPromptNote()).toBe(note);+ expect(note).not.toMatch(/\d{4}-\d{2}-\d{2}/);+ expect(note).not.toMatch(/\d{10,}/);+ });+});++describe('prependNoteToWireUserMessage(wire 注入形态)', () => {+ it('string 形态直接前拼', () => {+ expect(prependNoteToWireUserMessage('原话', 'NOTE')).toBe('NOTE\n\n原话');+ });++ it('content 为 string 的对象形态', () => {+ expect(prependNoteToWireUserMessage({ type: 'user', content: '原话' }, 'NOTE'))+ .toEqual({ type: 'user', content: 'NOTE\n\n原话' });+ });++ it('blocks 形态前插独立 text block,原 blocks 不变', () => {+ const blocks = [{ type: 'image', url: 'x' }, { type: 'text', text: '原话' }];+ expect(prependNoteToWireUserMessage({ type: 'user', content: blocks }, 'NOTE'))+ .toEqual({ type: 'user', content: [{ type: 'text', text: 'NOTE' }, ...blocks] });+ // 不原地改入参(调用方还要用 normalized 去落库)。+ expect(blocks[0]).toEqual({ type: 'image', url: 'x' });+ });++ it('交接前缀仍走同一份实现(向后兼容)', () => {+ expect(prependHandoffToUserMessage('原话', 'HANDOFF')).toBe('HANDOFF\n\n原话');+ });++ it('说明 + 交接叠加时说明在最前(交接自带结束标记,必须收尾在后)', () => {+ const withHandoff = prependHandoffToUserMessage('原话', 'HANDOFF');+ expect(prependNoteToWireUserMessage(withHandoff, 'NOTE')).toBe('NOTE\n\nHANDOFF\n\n原话');+ });+});++describe('注入接线(源码级守卫)', () => {+ const source = readFileSync(+ resolve(process.cwd(), 'src/main/maker-ipc/makerSendTransaction.ts'),+ 'utf8',+ );++ it('说明只进 wire payload,落库走 persistUserMessage.content', () => {+ expect(source).toContain('const mobileClientNote = deps.isMobileClientInvoke?.() === true');+ expect(source).toContain('prependNoteToWireUserMessage(withHandoff as HandoffWireMessage, mobileClientNote)');+ // 落库内容必须仍取 persistUserMessage.content —— 若改成 outgoing,提示语会写进+ // 用户消息、污染界面显示的原话。+ expect(source).toContain('content: persistUserMessage.content');+ expect(source).not.toMatch(/content:\s*outgoing/);+ });++ it('来源判据经 deps 注入,不在事务里直接 import ALS', () => {+ // 只看 import 与调用形态 —— deps 字段的注释里会提到这个函数名,那不算直连。+ expect(source).not.toMatch(/from '\.\.\/device-link\/invoke-context/);+ expect(source).not.toMatch(/isMobileControllerInvoke\s*\(/);+ });++ it('注释不得把平台值说成安全边界(平台由对端 hello 自报,无服务端校验)', () => {+ const files = [+ 'src/main/device-link/invoke-context.ts',+ 'src/main/device-link/controllerPlatform.ts',+ 'src/main/maker-ipc/makerSendTransaction.ts',+ ].map((rel) => readFileSync(resolve(process.cwd(), rel), 'utf8'));+ for (const text of files) {+ expect(text).not.toContain('不可伪造');+ }+ // 三处都必须显式声明它只用于体验分流。+ expect(files[0]).toContain('不是安全 / 鉴权 / 权限边界');+ expect(files[1]).toContain('仅体验分流,不是安全边界');+ expect(files[2]).toContain('不是安全判据');+ });++ it('装配处每次调用现取,不提前求值缓存', () => {+ const register = readFileSync(+ resolve(process.cwd(), 'src/main/maker-ipc/register.ts'),+ 'utf8',+ );+ expect(register).toContain('isMobileClientInvoke: () => isMobileControllerInvoke()');+ });+});++describe('stampMobileClientOrigin(IPC 边界盖章)', () => {+ it('手机来源盖上标记,返回新对象不改入参', () => {+ // 显式标出可选字段:真实入参是 AgentInputQueuedMessage(该字段是可选的),+ // 字面量不写这一项会让 TS 判「与约束无公共属性」(TS2559)而拒收。+ const item: { clientId: string; text: string; fromMobileClient?: boolean } = { clientId: 'a', text: 'hi' };+ const out = stampMobileClientOrigin(item, true);+ expect(out).toEqual({ clientId: 'a', text: 'hi', fromMobileClient: true });+ expect(item).toEqual({ clientId: 'a', text: 'hi' });+ });++ it('非手机来源:客户端自填的标记必须被剥掉(wire 值一律不生效)', () => {+ // item 来自 wire,客户端可以自己填 true —— 必须无条件覆盖。+ const forged = { clientId: 'a', text: 'hi', fromMobileClient: true };+ expect(stampMobileClientOrigin(forged, false)).toEqual({ clientId: 'a', text: 'hi' });+ expect(stampMobileClientOrigin(forged, false)).not.toHaveProperty('fromMobileClient');+ });++ it('手机来源时覆盖为 true(即使 wire 传的是 false)', () => {+ expect(stampMobileClientOrigin({ fromMobileClient: false }, true))+ .toEqual({ fromMobileClient: true });+ });+});++describe('stripMainOnlySendOpts(直连路径消毒)', () => {+ it('剥掉客户端自报的 fromMobileClient', () => {+ expect(stripMainOnlySendOpts({ messageUuid: 'u', fromMobileClient: true }))+ .toEqual({ messageUuid: 'u' });+ });++ it('其它字段原样保留', () => {+ const opts = { messageUuid: 'u', userName: 'n', origin: { kind: 'scheduler' } };+ expect(stripMainOnlySendOpts(opts)).toEqual(opts);+ });++ it('非对象输入原样返回(事务自己 ?? {} 兜底)', () => {+ expect(stripMainOnlySendOpts(undefined)).toBeUndefined();+ expect(stripMainOnlySendOpts(null)).toBeNull();+ expect(stripMainOnlySendOpts('x')).toBe('x');+ });+});++describe('排队 / 插入两条路径的接线(源码级守卫)', () => {+ const register = readFileSync(resolve(process.cwd(), 'src/main/maker-ipc/register.ts'), 'utf8');+ const coordinator = readFileSync(+ resolve(process.cwd(), 'src/main/maker-ipc/agent-input-coordinator.ts'),+ 'utf8',+ );+ const transaction = readFileSync(+ resolve(process.cwd(), 'src/main/maker-ipc/makerSendTransaction.ts'),+ 'utf8',+ );+ const sendHandler = readFileSync(+ resolve(process.cwd(), 'src/main/maker-ipc/sessionSendHandler.ts'),+ 'utf8',+ );++ it('enqueue 与 steer 两个 IPC 边界都盖章', () => {+ // 手机会话页所有发送都走这两条,只在 invoke context 里读来源实际读不到(review P1)。+ const stamps = register.match(/stampMobileClientOrigin\(/g) ?? [];+ expect(stamps.length).toBe(2);+ expect(register).toContain('isMobileControllerInvoke(),');+ });++ it('coordinator 在 drain 与 steer 两处都透传', () => {+ const passes = coordinator.match(/fromMobileClient: true \} : \{\}\)/g) ?? [];+ expect(passes.length).toBe(2);+ });++ it('send 事务认 async context 与透传值两个来源', () => {+ expect(transaction).toContain(+ "deps.isMobileClientInvoke?.() === true || so.fromMobileClient === true",+ );+ });++ it('steer 投递也注入说明,且只进 wire payload', () => {+ expect(register).toContain("isMobileControllerInvoke() || so.fromMobileClient === true");+ expect(register).toContain('prependNoteToWireUserMessage(normalized as HandoffWireMessage, steerNote)');+ expect(register).toContain('await sess.steer(steerPayload as never');+ });++ it('直连 maker:send 的 wire sendOpts 必须消毒', () => {+ expect(sendHandler).toContain('stripMainOnlySendOpts(sendOpts)');+ });++ it('直连 maker:steer 的 wire sendOpts 同样必须消毒', () => {+ // 这个 channel 在 device-link allowlist 里开放,sendOpts 是调用方可控输入 ——+ // 不剥的话传 `{ fromMobileClient: true }` 就能让非手机轮次收到伪造的手机说明+ // (review P1/P2 各报一次)。契约与 maker:send 一致:该字段只由 main 盖章。+ expect(register).toMatch(+ /MAKER_INVOKE\.STEER[\s\S]*?steerToAgentAccepted\(sessionId, message, stripMainOnlySendOpts\(sendOpts\)\)/,+ );+ // coordinator 的内部调用**不得**被消毒 —— 那条路的 sendOpts 是 main 构造的透传值。+ expect(register).toContain('steerToAgent: (sessionId, message, sendOpts) =>');+ expect(register).toMatch(+ /steerToAgent: \(sessionId, message, sendOpts\) =>\s*\n\s*steerToAgentAccepted\(sessionId, message, sendOpts\),/,+ );+ });+});diff --git a/apps/desktop/src/main/device-link/controllerPlatform.ts b/apps/desktop/src/main/device-link/controllerPlatform.tsnew file mode 100644index 0000000000..129e4c628a--- /dev/null+++ b/apps/desktop/src/main/device-link/controllerPlatform.ts@@ -0,0 +1,53 @@+/**+ * 控制端平台登记表(deviceId → platform)。+ *+ * platform 来自 relay 广播的 presence 快照(`PresenceSnapshot.platform`):桌面报+ * `process.platform`(`darwin` / `win32` / `linux`),手机报 `Platform.OS`+ * (`ios` / `android`)。两端取值天然不重叠,所以它是现成可用的「控制端是电脑还是+ * 手机」判据 —— 不需要往 relay 协议里新加 clientType 字段。+ *+ * ⚠️ **可信度:仅体验分流,不是安全边界。** 这个值由对端设备在 hello 帧里自报+ * (`HelloPayload.platform`,client→server),本仓没有服务端校验或覆盖 —— 一台改过的+ * 同账号已配对设备可以声称自己是 `ios`。消费方只能拿它做"要不要换个呈现 / 多说一句"+ * 这类无权限后果的分流;任何鉴权、权限或安全判定都不得建立在它上面。+ *+ * 单独成模块而不是留在 device-link/index.ts 里,是为了让 dispatch.ts 也能读:+ * index.ts 已经 import dispatch.ts(`index.ts` 顶部),反向 import 会成环。这里是+ * 无依赖叶子模块,两边都能安全引用,且平台事实只有一份。+ */++/**+ * 手机平台取值(手机侧 `Platform.OS` 的全集)。+ * 对应的桌面侧判据是 voice-input/dictionarySyncDriver 的 `DESKTOP_PLATFORMS`+ * (`darwin` / `win32` / `linux`);两张表互不重叠,新增平台时同步。+ */+const MOBILE_PLATFORMS = new Set(['ios', 'android']);++/**+ * 是否手机平台。+ *+ * **刻意写成正向判定,而不是 `!isDesktopPlatform(p)`**:presence 可能还没到、旧版本+ * 客户端可能报别的字符串,那些情况下 platform 是未知而非「手机」。取反会把未知一律+ * 当手机,是 fail-open;正向白名单在未知时返回 false,行为退化成「不加任何手机相关+ * 处理」,这才是安全方向。+ */+export function isMobilePlatform(platform: string | undefined | null): boolean {+ return typeof platform === 'string' && MOBILE_PLATFORMS.has(platform);+}++const platformByDevice = new Map<string, string>();++/** presence 变更时登记(唯一写入点在 device-link/index.ts 的 onPresenceChanged)。 */+export function setControllerPlatform(deviceId: string, platform: string): void {+ platformByDevice.set(deviceId, platform);+}++/** 未登记(presence 未到 / 已清空)返回 undefined —— 调用方按未知处理,不要猜。 */+export function getControllerPlatform(deviceId: string): string | undefined {+ return platformByDevice.get(deviceId);+}++/** 账号切换 / 连接重置时清空(与其它 presence 缓存同点清理)。 */+export function clearControllerPlatforms(): void {+ platformByDevice.clear();+}diff --git a/apps/desktop/src/main/device-link/dispatch.ts b/apps/desktop/src/main/device-link/dispatch.tsindex c6e85a66f9..fd9882010d 100644--- a/apps/desktop/src/main/device-link/dispatch.ts+++ b/apps/desktop/src/main/device-link/dispatch.ts@@ -61,6 +61,7 @@ import { createLogger } from '../logger';import { normalizeSessionProviderId } from '../maker-host/session-provider-store.js';import { readDeviceLinkSettings } from './settings-store';import { dispatchLocalInvoke } from './invoke-registry';+import { getControllerPlatform } from './controllerPlatform';import { runDeviceLinkInvokeContext } from './invoke-context';import { fetchLocalMediaToOss } from './mediaFetch';import { transcribeRemoteVoiceInput } from './voiceTranscribe';@@ -2127,7 +2128,13 @@ export async function runInvoke(? invokeControllerCapabilities(payload): [];const result = await runDeviceLinkInvokeContext(- { controllerDeviceId: src, channel: payload.channel },+ {+ controllerDeviceId: src,+ channel: payload.channel,+ // 平台按 server 盖章的 src 查本机 presence 登记表,不采信控制端自报的任何+ // 帧内字段(allowlist 只挡 channel 不挡 args,见下方 dispatchLocalInvoke 前的说明)。+ controllerPlatform: getControllerPlatform(src),+ },// provider:list 的首参只承载隧道能力协商,不进入本机 IPC handler。() => dispatchLocalInvoke(payload.channel,diff --git a/apps/desktop/src/main/device-link/index.ts b/apps/desktop/src/main/device-link/index.tsindex 813173789f..2b39681a4c 100644--- a/apps/desktop/src/main/device-link/index.ts+++ b/apps/desktop/src/main/device-link/index.ts@@ -65,6 +65,11 @@ import {handleControllerOffline,purgeRevokedController,} from './dispatch';+import {+ clearControllerPlatforms,+ getControllerPlatform,+ setControllerPlatform,+} from './controllerPlatform';import { setBusyProbe, helloBusy, pollBusyChange, resetBusyDedupe } from './busyReporter';import {DL_VOICE_DICTIONARY_SYNC_CHANNEL,@@ -225,7 +230,7 @@ const RESPONSIVENESS_PROBE_TICK_MS = 5_000;* push 帧不属于 relay 的控制类帧,自己设备之间同步词典不该要求对方开放被控。*/const presenceOnlineByDevice = new Map<string, boolean>();-const presencePlatformByDevice = new Map<string, string>();+const presenceNameByDevice = new Map<string, string>();let unsubscribeDictionaryChanged: (() => void) | null = null;@@ -477,7 +482,7 @@ export function initDeviceLinkService(options: DeviceLinkServiceOptions = {}): v// 权威 presence 已宣布不可用(离线 / 关被控):「响应性」判定失去意义,清熔断状态// 并作废在途结果,让离线态自己的 UI 接管;设备回来后首个请求再超时会重新累计。if (!available && wasAvailable === true) responsivenessTracker?.clearDevice(snap.deviceId);- presencePlatformByDevice.set(snap.deviceId, snap.platform);+ setControllerPlatform(snap.deviceId, snap.platform);presenceNameByDevice.set(snap.deviceId, snap.selfName || snap.deviceName);void rememberLastKnownDeviceName(snap.deviceId, snap.deviceName); // best-effort 名称缓存,不阻塞 presence 处理broadcast(DEVICE_LINK_PUSH.PRESENCE_CHANGED, snap);@@ -561,7 +566,7 @@ export function initDeviceLinkService(options: DeviceLinkServiceOptions = {}): vif (shouldExchangeDictionaryWith({online: true,- platform: presencePlatformByDevice.get(env.src),+ platform: getControllerPlatform(env.src),revoked: isDeviceRevoked(env.src),})) {@@ -573,7 +578,7 @@ export function initDeviceLinkService(options: DeviceLinkServiceOptions = {}): vif (shouldExchangeDictionaryWith({online: true,- platform: presencePlatformByDevice.get(env.src),+ platform: getControllerPlatform(env.src),revoked: isDeviceRevoked(env.src),})) {@@ -598,7 +603,7 @@ export function initDeviceLinkService(options: DeviceLinkServiceOptions = {}): v.filter(([deviceId, online]) =>shouldExchangeDictionaryWith({online,- platform: presencePlatformByDevice.get(deviceId),+ platform: getControllerPlatform(deviceId),revoked: isDeviceRevoked(deviceId),}),)@@ -613,7 +618,7 @@ export function initDeviceLinkService(options: DeviceLinkServiceOptions = {}): vdeviceId !== client?.getSelfDeviceId() &&shouldExchangeDictionaryWith({online,- platform: presencePlatformByDevice.get(deviceId),+ platform: getControllerPlatform(deviceId),revoked: isDeviceRevoked(deviceId),}),)@@ -625,7 +630,7 @@ export function initDeviceLinkService(options: DeviceLinkServiceOptions = {}): vdeviceId !== client?.getSelfDeviceId() &&shouldExchangeDictionaryWith({online: presenceOnlineByDevice.get(deviceId) === true,- platform: presencePlatformByDevice.get(deviceId),+ platform: getControllerPlatform(deviceId),revoked: isDeviceRevoked(deviceId),}),sendRelayFrame: (deviceId, frame) => {@@ -847,7 +852,7 @@ function teardownActiveLink(): void {// 同步在降级过一次之后永久失效。清空 presence 就够了 —— 没有对端就不会发送,// client 为 null 时 sendPush 也是 no-op。presenceOnlineByDevice.clear();- presencePlatformByDevice.clear();+ clearControllerPlatforms();presenceNameByDevice.clear();resetSubscriptionRefs();resetBusyDedupe(); // 重置 busy dedupe,避免重连后首个真实 busy 状态被旧值压掉diff --git a/apps/desktop/src/main/device-link/invoke-context.ts b/apps/desktop/src/main/device-link/invoke-context.tsindex 15541fc3be..5f5b8950ae 100644--- a/apps/desktop/src/main/device-link/invoke-context.ts+++ b/apps/desktop/src/main/device-link/invoke-context.ts@@ -8,9 +8,28 @@import { AsyncLocalStorage } from 'node:async_hooks';+import { isMobilePlatform } from './controllerPlatform';+export interface DeviceLinkInvokeContext {controllerDeviceId: string;channel: string;+ /**+ * 控制端平台(presence 登记的 `PresenceSnapshot.platform`);未登记时 undefined。+ *+ * ⚠️ **只用于体验分流,不是安全 / 鉴权 / 权限边界**(review 修正)。两个字段的可信度+ * 不同,不要混为一谈:+ * - `controllerDeviceId` 来自 server 填的 `env.src`(客户端传入值会被覆盖,见+ * device-link-protocol 的 Envelope 注释),有服务端背书;+ * - `controllerPlatform` 则是**对端设备在 hello 帧里自报**的值+ * (`HelloPayload.platform`,client→server),经 relay 的 presence 广播进本机缓存。+ * 本仓没有任何服务端校验或覆盖逻辑,所以一台改过的同账号已配对设备可以声称+ * 自己是 `ios`。+ *+ * 它比控制端在每次 invoke 的 args / sendOpts 里现报要稳(不随单次调用摆动、由 presence+ * 统一维护),这就够用来决定"要不要多追加一段体验说明";但**不得**据它放行权限、+ * 跳过校验或做任何安全判定。+ */+ controllerPlatform?: string;}const storage = new AsyncLocalStorage<DeviceLinkInvokeContext>();@@ -29,3 +48,19 @@ export function getDeviceLinkInvokeContext(): DeviceLinkInvokeContext | null {export function isDeviceLinkInvoke(): boolean {return storage.getStore() !== undefined;}++/**+ * 当前调用是否来自**手机**控制端 —— **体验分流用,不是安全判据**(见+ * DeviceLinkInvokeContext.controllerPlatform 的说明)。+ *+ * 本机 renderer 自己发的 invoke 不在 store 里 → false;另一台桌面作控制端 → platform+ * 是 `darwin`/`win32`/`linux` → false;presence 还没到、platform 未知 → 同样 false+ * (fail-closed,见 controllerPlatform.isMobilePlatform 的说明)。+ *+ * ⚠️ 只在**同一条 await 链**上有效。排队路径(maker:input:enqueue → coordinator 队列+ * → drain 派发)在 drain 时已脱离本上下文,读不到来源;那条路要覆盖需要把来源盖章在+ * 入队项上透传到 drain,属独立改动。+ */+export function isMobileControllerInvoke(): boolean {+ return isMobilePlatform(storage.getStore()?.controllerPlatform);+}diff --git a/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts b/apps/desktop/src/main/maker-ipc/agent-input-coordinator.tsindex ee6c888c9c..1e4bc069a9 100644--- a/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts+++ b/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts@@ -166,6 +166,12 @@ export interface AgentInputSendOpts {* 其它路径(用户输入 / orca)不设,行为不变。*/origin?: { kind: 'scheduler'; scheduleId: string; scheduleName: string; runId?: string };+ /**+ * 队列项上盖的手机来源(见 AgentInputQueuedMessage.fromMobileClient)。+ * drain / steer 都在原 invoke 的 async context 之外派发,只能靠这条透传把来源带到+ * 最终 wire 消息。**由 main 构造,不是 wire 输入。**+ */+ fromMobileClient?: boolean;persistUserMessage?: {clientId: string;content: string;@@ -1385,7 +1391,13 @@ export class AgentInputCoordinator {await this.deps.steerToAgent(sessionId,buildMakerUserMessage(item, referenceContexts),- { messageUuid, userName: item.userName, signal: steerAbort.signal },+ {+ messageUuid,+ userName: item.userName,+ signal: steerAbort.signal,+ // 同 drain:steer 投递也在入队时的 async context 之外。+ ...(item.fromMobileClient ? { fromMobileClient: true } : {}),+ },);} catch (err) {this.clearSteerAbortController(sessionId, item.clientId);@@ -2611,6 +2623,8 @@ export class AgentInputCoordinator {userName: head.userName,throwOnStartFailure: true,...(head.origin?.kind === 'scheduler' ? { origin: head.origin } : {}),+ // 手机来源透传到 send 事务:drain 已脱离入队时的 async context。+ ...(head.fromMobileClient ? { fromMobileClient: true } : {}),persistUserMessage: {clientId: head.clientId,content: head.persistedContent,diff --git a/apps/desktop/src/main/maker-ipc/agentHandoff.ts b/apps/desktop/src/main/maker-ipc/agentHandoff.tsindex ba4ac44be0..613a6142ef 100644--- a/apps/desktop/src/main/maker-ipc/agentHandoff.ts+++ b/apps/desktop/src/main/maker-ipc/agentHandoff.ts@@ -539,20 +539,31 @@ export type HandoffWireMessage =| { type: 'user'; content: string | Array<{ type: string; [k: string]: unknown }> };/**- * 把交接文本前置到发给 agent 的 wire 消息上(不影响落库/显示内容)。+ * 把一段内部说明前置到发给 agent 的 wire 消息上(**不影响落库/显示内容**)。* blocks 形态下前插独立 text block,string 形态下直接前拼。+ *+ * 交接前缀与手机客户端说明(mobileClientPromptNote)共用这一份形态处理 —— blocks /+ * string 两态各自前置的写法复制一遍就会有一处写错的风险,判据只留一份。*/-export function prependHandoffToUserMessage(+export function prependNoteToWireUserMessage(message: HandoffWireMessage,- handoff: string,+ note: string,): HandoffWireMessage {if (typeof message === 'string') {- return `${handoff}\n\n${message}`;+ return `${note}\n\n${message}`;}if (typeof message.content === 'string') {- return { ...message, content: `${handoff}\n\n${message.content}` };+ return { ...message, content: `${note}\n\n${message.content}` };}- return { ...message, content: [{ type: 'text', text: handoff }, ...message.content] };+ return { ...message, content: [{ type: 'text', text: note }, ...message.content] };+}++/** 把交接文本前置到发给 agent 的 wire 消息上(不影响落库/显示内容)。 */+export function prependHandoffToUserMessage(+ message: HandoffWireMessage,+ handoff: string,+): HandoffWireMessage {+ return prependNoteToWireUserMessage(message, handoff);}/**diff --git a/apps/desktop/src/main/maker-ipc/makerSendTransaction.ts b/apps/desktop/src/main/maker-ipc/makerSendTransaction.tsindex 56a5b0e5e0..fac1bd0e1c 100644--- a/apps/desktop/src/main/maker-ipc/makerSendTransaction.ts+++ b/apps/desktop/src/main/maker-ipc/makerSendTransaction.ts@@ -15,8 +15,10 @@ import { isCredentialModeSwitchBusyError } from '../maker-host/codex-credential-import { throwIpcError } from '../utils/ipcValidate.js';import {prependHandoffToUserMessage,+ prependNoteToWireUserMessage,type HandoffWireMessage,} from './agentHandoff.js';+import { buildMobileClientPromptNote } from './mobileClientPromptNote.js';import type { MakerSessionCreateOpts } from './sessionRequest.js';type CreateOpts = MakerSessionCreateOpts;@@ -42,6 +44,14 @@ type MakerSendOptions = {* 打到 sess.send 的 origin(本轮 turnOrigin)并合进落库 user 消息 agentMeta.origin。*/origin?: { kind: 'scheduler'; scheduleId: string; scheduleName: string; runId?: string };+ /**+ * 手机来源(coordinator 从队列项透传;**main 构造,不是 wire 输入**——直连 maker:send+ * 的客户端 sendOpts 在 sessionSendHandler 边界被剥掉,见那里的说明)。+ *+ * 必须认这一条:手机会话页所有发送都走 input:enqueue / input:steer,drain 派发时+ * 入队时的 async context 早已结束,只靠 isMobileClientInvoke() 实际读不到来源。+ */+ fromMobileClient?: boolean;persistUserMessage?: {clientId?: unknown;content?: unknown;@@ -179,6 +189,18 @@ export interface MakerSendTransactionDeps {*/peekPendingHandoff?(sessionId: string): Promise<string | null>;consumePendingHandoff?(sessionId: string): void;+ /**+ * 本次调用是否来自手机控制端(缺省 = 否)。**纯体验分流,不是安全判据。**+ *+ * 注入而非直接 import `isMobileControllerInvoke`,是为了可单测(同+ * newMakerWorktreePreferenceHandler 把 isDeviceLinkInvoke 做成 deps 的写法)。+ *+ * ⚠️ 判据里的平台值是**对端设备在 hello 帧自报**的(经 presence 广播进本机缓存),+ * 本仓没有服务端校验 —— 一台改过的同账号已配对设备可以声称自己是手机。它的唯一+ * 后果是多追加一段体验说明,所以够用;但不得据它放行权限或跳过任何校验。+ * 完整可信度说明见 device-link/invoke-context.ts。+ */+ isMobileClientInvoke?(): boolean;log: MakerSendTransactionLog;}@@ -531,11 +553,23 @@ export function createMakerSendTransaction(deps: MakerSendTransactionDeps): Make// session-agent-switch:切换后的首条消息把交接前缀拼进 wire payload。// 落库/显示内容(persistUserMessage.content)不含交接段——display 与 sent 分离。const pendingHandoff = (await deps.peekPendingHandoff?.(sessionId)) ?? null;- const outgoing = pendingHandoff+ const withHandoff = pendingHandoff? prependHandoffToUserMessage(normalized as HandoffWireMessage, pendingHandoff): normalized;- const meta = await deps.getSessionMeta(sessionId).catch(() => null);const so = (outgoingSendOpts ?? {}) as MakerSendOptions;+ // 手机客户端说明:同样只进 wire payload,落库/显示内容(persistUserMessage.content)+ // 不含它。位置在交接段**之前** —— 交接正文自带「以下是用户的新消息」结束标记,+ // 排在它后面会让说明插到那句话之后(顺序推导同 agentHandoff.composeForkOriginHandoff:+ // 元信息在前、交接正文在后、由交接自带的标记统一收尾)。+ // 两个来源:直连 maker:send 走 async context(deps 注入);排队 / 插入路径走+ // coordinator 从队列项透传的 so.fromMobileClient(drain 时 context 已结束)。+ const mobileClientNote = deps.isMobileClientInvoke?.() === true || so.fromMobileClient === true+ ? buildMobileClientPromptNote()+ : null;+ const outgoing = mobileClientNote+ ? prependNoteToWireUserMessage(withHandoff as HandoffWireMessage, mobileClientNote)+ : withHandoff;+ const meta = await deps.getSessionMeta(sessionId).catch(() => null);const persistUserMessage = readPersistUserMessageOption(so);const directPreDispatchHook = persistUserMessage ? null : deps.beforeDispatchDirectUserTurn;let directPreDispatchHookStarted = false;diff --git a/apps/desktop/src/main/maker-ipc/mobileClientPromptNote.ts b/apps/desktop/src/main/maker-ipc/mobileClientPromptNote.tsnew file mode 100644index 0000000000..53596c18cc--- /dev/null+++ b/apps/desktop/src/main/maker-ipc/mobileClientPromptNote.ts@@ -0,0 +1,77 @@+/**+ * 手机客户端来源 —— 盖章、透传、以及逐轮追加到**发给 agent 的 wire 消息**上的说明。+ *+ * 为什么需要:同一个桌面会话既可能在电脑上用,也可能被手机远程控制。产出 HTML 之类+ * 可预览成品时,自包含单文件在手机上体验明显更好(多文件产物的同目录资源要逐个回取,+ * 见 mobile 的 htmlLocalResources),而模型无从得知这一轮是谁在问。+ *+ * ── 为什么不进 system prompt(重要,别"优化"回去) ─────────────────────────+ * docs/dev-rules/maker-core-and-agent-behavior.md:+ * - §3.1:prompt cache 命中依赖请求前缀逐字节稳定,**易变内容只能进 per-call+ * userPrompt 段**。控制端会中途切换(在电脑上开的会话,走开后用手机继续),放进+ * system 前缀既拖缓存率,又会在切换后变成陈旧信息反过来误导模型。+ * - §4:system prompt 任何改动都要仓库维护者显式确认。本机制刻意不碰它。+ * 追加在 wire 消息上,与 IM 渠道说明(hook-control/outbound.buildHookPromptNote)+ * 及引擎交接前缀(agentHandoff.prependHandoffToUserMessage)同一层、同一套语义:+ * **只进喂给 agent 的内容,不进落库/显示的用户消息原话。**+ *+ * ── 与代码职责的分界(§2 能用代码保证的不甩给 prompt) ────────────────────+ * 「产出物在手机上打不开」已经由代码解决:手机端能渲染 HTML 并把同目录资源取回来。+ * 所以这里**不写**「不要给本地路径」——路径在手机上是可点可渲染的,那样写会和已有+ * 能力打架。prompt 只承担代码补不了的那半:让模型在**生成时**就倾向自包含单文件。+ */++/**+ * 固定文本(不含时间戳 / 计数器等易变量,同一版本逐字节稳定)。+ *+ * 措辞约束:+ * - 首句必须声明这不是用户消息,否则模型会把它当请求来回应或复述(IM 渠道说明踩过);+ * - 用「优先」而不是「必须」:用户明确要多文件产物时不该被这条挡住;+ * - 不解释机制细节,只给可执行的产出偏好。+ */+export function buildMobileClientPromptNote(): string {+ return (+ '[客户端说明] 以下为系统每轮自动追加的环境说明,不是用户发来的消息;'+ + '回复时不要把它当作用户的请求,也不要引用、复述或据此臆测用户意图。'+ + '本轮请求来自手机客户端(小屏、远程查看被控电脑上的文件)。'+ + '产出 HTML 等可预览成品时**优先做成自包含单文件**:样式与脚本内联,'+ + '图片用 data: URI 或公网地址,避免拆成需要同目录资源的多文件产物;'+ + '用户明确要求多文件时照常产出。'+ + '给出文件路径时同时给出结论或内容摘要,不要只回一个路径。'+ );+}++/**+ * 在 IPC 边界给队列项盖上手机来源(返回新对象,不原地改入参)。+ *+ * **必须无条件覆盖**:`item` 来自 wire,客户端可以自己填 `fromMobileClient: true`。+ * 由被控端按可信来源判据重写(不是手机就删掉该字段),客户端自报一律不生效。+ *+ * 为什么要盖在队列项上:手机会话页的所有发送都走 input:enqueue / input:steer,而+ * drain 派发与 steer 投递都在原 invoke 的 AsyncLocalStorage 之外发生 —— 只在+ * invoke context 里读来源的话,真实使用中几乎永远读不到(review P1 实捉)。+ */+export function stampMobileClientOrigin<T extends { fromMobileClient?: boolean }>(+ item: T,+ fromMobileClient: boolean,+): T {+ if (fromMobileClient) return { ...item, fromMobileClient: true };+ const { fromMobileClient: _ignored, ...rest } = item;+ return rest as T;+}++/**+ * 剥掉 sendOpts 里「只允许 main 写」的字段。+ *+ * `fromMobileClient` 是 coordinator 从队列项透传给 send 事务的内部字段;直连+ * `maker:send` 的 sendOpts 却来自 wire —— 不剥的话客户端自填一个就能让 agent 收到手机+ * 说明。直连路径的来源判据只能是 async context(invoke-context),不看 sendOpts。+ *+ * 非对象输入原样返回(事务自己会按 `?? {}` 兜底)。+ */+export function stripMainOnlySendOpts(sendOpts: unknown): unknown {+ if (!sendOpts || typeof sendOpts !== 'object' || Array.isArray(sendOpts)) return sendOpts;+ if (!('fromMobileClient' in sendOpts)) return sendOpts;+ const { fromMobileClient: _ignored, ...rest } = sendOpts as Record<string, unknown>;+ return rest;+}diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.tsindex a9dd4a2a7c..96472e5c41 100644--- a/apps/desktop/src/main/maker-ipc/register.ts+++ b/apps/desktop/src/main/maker-ipc/register.ts@@ -430,7 +430,11 @@ import {registerMakerSessionAgentSwitchHandler,type MakerSessionAgentSwitchHandlerDeps,} from './sessionAgentSwitchHandler.js';-import { prependHandoffToUserMessage } from './agentHandoff.js';+import {+ prependNoteToWireUserMessage,+ prependHandoffToUserMessage,+ type HandoffWireMessage,+} from './agentHandoff.js';import { hydrateQueuedAgentReferences } from './agentInputReferences.js';import { agentHandoffPending } from './agentHandoffPendingSingleton.js';import { type MakerSessionCreateOpts, withCreateSessionStderr } from './sessionRequest.js';@@ -560,7 +564,12 @@ import {setRemoteWorkingDirGuard as setDeviceLinkRemoteWorkingDirGuard,setRemoteSettingsPersist as setDeviceLinkRemoteSettingsPersist,} from '../device-link/dispatch.js';-import { isDeviceLinkInvoke } from '../device-link/invoke-context.js';+import { isDeviceLinkInvoke, isMobileControllerInvoke } from '../device-link/invoke-context.js';+import {+ buildMobileClientPromptNote,+ stampMobileClientOrigin,+ stripMainOnlySendOpts,+} from './mobileClientPromptNote.js';import {assertResolveInteractionOrigin,isPluginSetupInteractionDecision,@@ -7826,6 +7835,10 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)reconcileCreateOptsWithDb: reconcileCreateOptsAgainstDb,peekPendingHandoff: (sessionId) => agentHandoffPending.peek(sessionId),consumePendingHandoff: (sessionId) => agentHandoffPending.consume(sessionId),+ // 手机客户端说明的开关:被控端盖章的来源判据(本机 renderer / 桌面控制端 / 平台+ // 未知一律 false)。必须在这里现取,不能提前求值缓存——同一个装配好的事务会服务+ // 后续所有 send,来源是逐次调用的属性。+ isMobileClientInvoke: () => isMobileControllerInvoke(),applyPendingAgentSwitch: (sessionId) => applyPendingAgentSwitchIfIdle(agentSwitchDeps, sessionId),log,});@@ -7888,9 +7901,23 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)throwIpcError('NO_ACTIVE_TURN', `Session ${sessionId} has no active turn`);}const meta = await maker.getSessionMeta(sessionId).catch(() => null);- const so = (sendOpts ?? {}) as { messageUuid?: string; userName?: string; signal?: AbortSignal };+ const so = (sendOpts ?? {}) as {+ messageUuid?: string;+ userName?: string;+ signal?: AbortSignal;+ /** coordinator 从队列项透传的手机来源(main 构造,非 wire 输入)。 */+ fromMobileClient?: boolean;+ };+ // 手机说明同样只进 wire payload(steer 路径不落库用户消息,天然不污染原话)。+ // 两个来源都要认:IPC 直连 steer 时 async context 在;coordinator 投递时靠透传。+ const steerNote = isMobileControllerInvoke() || so.fromMobileClient === true+ ? buildMobileClientPromptNote()+ : null;+ const steerPayload = steerNote+ ? prependNoteToWireUserMessage(normalized as HandoffWireMessage, steerNote)+ : normalized;try {- await sess.steer(normalized as never, {+ await sess.steer(steerPayload as never, {logTitle: meta?.title,messageUuid: so.messageUuid,userName: so.userName,@@ -7923,7 +7950,14 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions));ipcMain.handle(MAKER_INVOKE.STEER, async (_e, sessionId: unknown, message: unknown, sendOpts?: unknown) => {- await steerToAgentAccepted(sessionId, message, sendOpts);+ // **wire sendOpts 必须消毒**(review P1/P2,两个 bot 各报一次):这个 channel 在+ // device-link allowlist 里开放,`sendOpts` 是调用方可控输入。不剥的话,桌面 renderer+ // 或任意获准远控的非手机客户端只要传 `{ fromMobileClient: true }`,就能让本轮拿到伪造+ // 的手机环境说明、按错误的来源调整产物形态。+ //+ // 契约与 maker:send 一致(sessionSendHandler 同样在 IPC 边界剥):**该字段只由 main+ // 盖章**。coordinator 的内部 steerToAgent 调用不经过这里,透传值不受影响。+ await steerToAgentAccepted(sessionId, message, stripMainOnlySendOpts(sendOpts));});ipcMain.handle(MAKER_INVOKE.GET_CONTEXT_USAGE, async (_e, sessionId: unknown, createOpts?: unknown): Promise<ContextUsageData> => {@@ -8976,7 +9010,12 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)sid,requireQueuedMessage(item),)) as AgentInputQueuedMessage;- const queued = await hydrateQueuedAgentReferences(queuedWithAttachments);+ // 手机来源在**入队这一刻**盖章:drain 派发时已脱离本 invoke 的 async context。+ // 无条件覆盖 —— item 来自 wire,客户端自填的 fromMobileClient 一律不生效。+ const queued = stampMobileClientOrigin(+ await hydrateQueuedAgentReferences(queuedWithAttachments),+ isMobileControllerInvoke(),+ );const commitAutoTitle = await prepareDeviceLinkAutoTitle(sid, queued);// 「继续任务」durable ack 延后到 vendor dispatch 成功(onDispatchedUserTurn):@@ -9026,7 +9065,11 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)allowMissingTrustedContexts: isDeviceLinkInvoke() && steerOpts?.removeFromQueue === true,}),)) as AgentInputQueuedMessage;- const queued = await hydrateQueuedAgentReferences(queuedWithAttachments);+ // 与 enqueue 同:steer 投递也在本 invoke 的 async context 之外发生。+ const queued = stampMobileClientOrigin(+ await hydrateQueuedAgentReferences(queuedWithAttachments),+ isMobileControllerInvoke(),+ );// 插话也补起名:远控用户完全可能趁这一轮还在跑就写下第一句话,只认入队的话// 标题会一直停在首条纯附件消息的合成占位上(PR #510 review P1)。是否真的该// 改名由 runSessionAutoTitle 权威判定。diff --git a/apps/desktop/src/main/maker-ipc/sessionSendHandler.ts b/apps/desktop/src/main/maker-ipc/sessionSendHandler.tsindex 1b26e60826..a9f8081827 100644--- a/apps/desktop/src/main/maker-ipc/sessionSendHandler.ts+++ b/apps/desktop/src/main/maker-ipc/sessionSendHandler.ts@@ -1,6 +1,7 @@import { throwIpcError } from '../utils/ipcValidate.js';import { MAKER_INVOKE } from './channels.js';import type { IpcHandlerRegistry } from './ipcHandlerRegistry.js';+import { stripMainOnlySendOpts } from './mobileClientPromptNote.js';/*** SEND adapter 只校验 IPC 入口并委托事务;lazy-create / rehydrate / accepted@@ -31,7 +32,14 @@ export function registerMakerSessionSendHandler<TResult>(if (typeof sessionId !== 'string') {throwIpcError('INVALID_PARAMS', 'sessionId required');}- return await deps.sendToAgentAccepted(sessionId, message, createOpts, sendOpts);+ // sendOpts 来自 wire:剥掉只允许 main 写的字段(fromMobileClient 由 coordinator+ // 从队列项透传,客户端不得自报 —— 直连路径的来源判据只能是 async context)。+ return await deps.sendToAgentAccepted(+ sessionId,+ message,+ createOpts,+ stripMainOnlySendOpts(sendOpts),+ );},);}diff --git a/apps/desktop/src/shared/agentInputQueue.ts b/apps/desktop/src/shared/agentInputQueue.tsindex 380034848a..62635c8815 100644--- a/apps/desktop/src/shared/agentInputQueue.ts+++ b/apps/desktop/src/shared/agentInputQueue.ts@@ -196,6 +196,19 @@ export interface AgentInputQueuedMessage {/** 老队列快照可能没有;新 scheduler run 始终写入。 */runId?: string;};+ /**+ * 本条由**手机控制端**入队 / 插入。+ *+ * 手机会话页的所有发送都走 input:enqueue / input:steer(没有一处调 maker:send),+ * 而 drain 派发与 steer 都发生在原 invoke 的 AsyncLocalStorage 之外 —— 来源必须在+ * 入队/插入的那一刻盖在队列项上,才能一路带到最终 wire 消息(见+ * maker-ipc/mobileClientPromptNote)。+ *+ * **只由被控端在 IPC 边界写入,不采信 wire 传来的值**(客户端可控数据)。语义上仅用于+ * 体验分流(要不要追加一段手机说明),不是安全 / 鉴权判据 —— 平台值本身也是对端自报的,+ * 见 device-link/invoke-context 的可信度说明。+ */+ fromMobileClient?: boolean;/*** 一次性跳过意识拦截钩(订阅槽①)。**预留字段,v1 无调用点置位**:当前* 没有"强制发送"UI,被拦消息只能编辑后重发且重发仍会再审;未来落地