Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(update): IM 轮次被其他输入插话后不再算主人发起
Dash7f5ea2fbeab9
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/interactionRouter.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/interactionRouter.test.tsindex 9717db874d..e80fadeb0a 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/interactionRouter.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/interactionRouter.test.ts@@ -7,6 +7,7 @@ import {requestHostInteraction,installDesktopInteractionHandler,installInteractionLifecycleObserver,+ noteInteractionRouteSteer,type InteractionHandler,} from '../interactionRouter';@@ -79,6 +80,38 @@ describe('session interaction router', () => {expect(getActiveInteractionRoute(host.session)).toBeNull();});+ it('stops vouching for the IM sender once other input is steered into the turn', () => {+ const host = makeSession();+ installDesktopInteractionHandler(host.session, vi.fn<InteractionHandler>((_request, shared) => shared!.result));+ noteInteractionRouteSteer(host.session);+ const lease = beginInteractionRoute(host.session, {+ route: {+ sessionId: host.session.id, turnId: 'turn-steered', origin: { kind: 'im', channel: 'telegram' },+ interactionSurface: 'channel-card', requesterAuthority: 'owner',+ },+ handle: vi.fn(async (): Promise<InteractionDecision> => ({ kind: 'permission', behavior: 'deny' })),+ });+ try {+ // A steer before this route began does not touch it.+ expect(getActiveInteractionRoute(host.session)?.requesterAuthority).toBe('owner');+ noteInteractionRouteSteer(host.session);+ expect(getActiveInteractionRoute(host.session)).toMatchObject({+ origin: { kind: 'im', channel: 'telegram' }, requesterAuthority: 'unknown',+ });+ expect(lease.route.requesterAuthority).toBe('owner');+ } finally { lease.release(); }+ const next = beginInteractionRoute(host.session, {+ route: {+ sessionId: host.session.id, turnId: 'turn-next', origin: { kind: 'im', channel: 'telegram' },+ interactionSurface: 'channel-card', requesterAuthority: 'owner',+ },+ handle: vi.fn(async (): Promise<InteractionDecision> => ({ kind: 'permission', behavior: 'deny' })),+ });+ try {+ expect(getActiveInteractionRoute(host.session)?.requesterAuthority).toBe('owner');+ } finally { next.release(); }+ });+it('lets the phone/Desktop or the IM card answer an app update card; the first answer wins', async () => {const host = makeSession();let desktopShared: Parameters<InteractionHandler>[1];diff --git a/apps/desktop/src/main/maker-ipc/interactionRouter.ts b/apps/desktop/src/main/maker-ipc/interactionRouter.tsindex f994166a8f..b476aa3a1c 100644--- a/apps/desktop/src/main/maker-ipc/interactionRouter.ts+++ b/apps/desktop/src/main/maker-ipc/interactionRouter.ts@@ -68,7 +68,11 @@ type RouteRegistration =onCancel?: (requestId: string, decision: InteractionDecision) => boolean | void;};-type ActiveRoute = RouteRegistration & { token: symbol };+type ActiveRoute = RouteRegistration & {+ token: symbol;+ /** Other input was steered into this turn; the triggering sender no longer speaks for it. */+ steered?: boolean;+};interface PendingRequest {shared?: SharedPermission;@@ -129,7 +133,15 @@ class SessionInteractionRouter {}getActiveRoute(): InteractionRoute | null {- return this.activeRoute?.route ?? null;+ const active = this.activeRoute;+ if (!active) return null;+ return active.steered && active.route.requesterAuthority !== undefined+ ? { ...active.route, requesterAuthority: 'unknown' }+ : active.route;+ }++ noteSteer(): void {+ if (this.activeRoute) this.activeRoute.steered = true;}private notifyState(route: InteractionRoute | undefined, state: InteractionRouteState): void {@@ -324,11 +336,19 @@ export function requestHostInteraction(return routerFor(session).dispatch(request, signal);}-/** Read-only view of the live non-Desktop route; null for ordinary Desktop turns. */+/**+ * Read-only view of the live non-Desktop route; null for ordinary Desktop turns.+ * Once other input is steered into the turn, `requesterAuthority` reads 'unknown'.+ */export function getActiveInteractionRoute(session: InteractionSession): InteractionRoute | null {return routers.get(session as object)?.getActiveRoute() ?? null;}+/** Called before a steer reaches the provider; the route stops vouching for the sender. */+export function noteInteractionRouteSteer(session: InteractionSession): void {+ routers.get(session as object)?.noteSteer();+}+export function installInteractionLifecycleObserver(session: InteractionSession,observer: InteractionLifecycleObserver | null,diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.tsindex 01ec001cb2..d3a2543871 100644--- a/apps/desktop/src/main/maker-ipc/register.ts+++ b/apps/desktop/src/main/maker-ipc/register.ts@@ -843,6 +843,7 @@ import {import {installDesktopInteractionHandler,installInteractionLifecycleObserver,+ noteInteractionRouteSteer,} from './interactionRouter.js';import { createSharedPermission, type SharedPermission } from './sharedPermission';import { registerMakerMessageDeleteHandler } from './messageDeleteHandler.js';@@ -16026,6 +16027,8 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)// 同轮插话也属于新输入。必须在 vendor await 前通知,旧轮可能先于 steer ack 结束。// 共用入口同时覆盖 INPUT_STEER、队列提升和旧 STEER IPC。publishUiSessionIntervention(sessionId);+ // A channel route vouches only for its triggering sender; steered input ends that.+ noteInteractionRouteSteer(sess);await sess.steer(steerPayload as never, {logTitle: meta?.title,messageUuid: so.messageUuid,diff --git a/docs/product-rules/agent-app-update.md b/docs/product-rules/agent-app-update.mdindex 0220dbb242..943ad3cb73 100644--- a/docs/product-rules/agent-app-update.md+++ b/docs/product-rules/agent-app-update.md@@ -40,7 +40,7 @@ Agent 只能反复引导用户去点「检查更新」;那次收紧的起因- 桌面与同账号手机:输入协调器里当前轮次的输入必须是主人亲手输入的文字;自动化、其他任务(`send_to_session`)、Orca、插件、共享任务访客、自动续跑(含零输出自动重试)、合成指令都不算。-- 个人 IM:沿用控制命令的主人判据(私聊已过渠道 owner 门;群里看发言人 `isOwner`)。+- 个人 IM:沿用控制命令的主人判据(私聊已过渠道 owner 门;群里看发言人 `isOwner`);这一轮里有别的输入插话进来后,本轮不再算主人发起。- 个人微信:私聊联系人无法证明是主人(其权限策略本就记为 `requesterAuthority: unknown`),一律拒绝,主人可在桌面、手机或其他已验证主人的渠道发起。- 官方 Hook:其轮次在 maker-core 里记为自动化来源,与 scheduler 一样拒绝;主人请用桌面、手机或个人 bot。