Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(computer): negotiate optional cursor setup
nothingyuancando5697229252a4
diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/computer-contract.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/computer-contract.test.tsindex 3a74054e92..6534573032 100644--- a/apps/desktop/src/main/mcp-integrations/__tests__/computer-contract.test.ts+++ b/apps/desktop/src/main/mcp-integrations/__tests__/computer-contract.test.ts@@ -1,6 +1,10 @@import { describe, expect, it } from 'vitest';import fixture from './fixtures/cua-driver-0.23.2.json';-import { adaptComputerDriverArgs, type ComputerDriverToolSchema } from '../computer-contract.js';+import {+ adaptComputerDriverArgs,+ selectAdvertisedComputerDriverArgs,+ type ComputerDriverToolSchema,+} from '../computer-contract.js';const schemas = new Map(fixture.tools.map((tool) => [tool.name, tool.inputSchema as ComputerDriverToolSchema]),@@ -113,4 +117,37 @@ describe('installed Computer Use contract', () => {adaptComputerDriverArgs('verify_state', { pid: 1, window_id: 2 }, schemas),).toThrow('requires expect');});+ // 测试价值:#6979 中 cua-driver 0.38 的闭合 schema 移除了旧光标样式字段;生产契约+ // 协商必须在派发前跳过无兼容参数的可选装饰,避免每个新会话产生拒绝日志。旧覆盖只验证+ // 必需动作的 fail-closed 适配;最小失败输入是一个仅声明新运动字段的闭合 schema,unit tier。+ it('negotiates optional cursor decoration against the advertised schema', () => {+ const legacyInput = {+ cursor_id: 'session',+ cursor_icon: 'arrow',+ cursor_color: '#DF0C27',+ };+ const v038 = new Map<string, ComputerDriverToolSchema>([+ ['set_agent_cursor_motion', {+ properties: { arc_flow: {}, style: {}, timing: {} },+ additionalProperties: false,+ }],+ ]);+ expect(selectAdvertisedComputerDriverArgs('set_agent_cursor_motion', legacyInput, v038)).toBeNull();+ expect(selectAdvertisedComputerDriverArgs('set_agent_cursor_style', legacyInput, v038)).toBeNull();++ const compatible = new Map<string, ComputerDriverToolSchema>([+ ['set_agent_cursor_motion', {+ properties: { cursor_color: {} },+ additionalProperties: false,+ }],+ ]);+ expect(selectAdvertisedComputerDriverArgs('set_agent_cursor_motion', legacyInput, compatible))+ .toEqual({ cursor_color: '#DF0C27' });++ const permissive = new Map<string, ComputerDriverToolSchema>([+ ['set_agent_cursor_motion', { additionalProperties: true }],+ ]);+ expect(selectAdvertisedComputerDriverArgs('set_agent_cursor_motion', legacyInput, permissive))+ .toEqual(legacyInput);+ });});diff --git a/apps/desktop/src/main/mcp-integrations/computer-contract.ts b/apps/desktop/src/main/mcp-integrations/computer-contract.tsindex d25c14199f..5c5ac53207 100644--- a/apps/desktop/src/main/mcp-integrations/computer-contract.ts+++ b/apps/desktop/src/main/mcp-integrations/computer-contract.ts@@ -9,6 +9,26 @@ export class ComputerContractError extends Error {readonly code = 'COMPUTER_DRIVER_INCOMPATIBLE';}+/**+ * Negotiate arguments for an optional driver decoration. Missing tools or a+ * closed schema with no compatible Cindy fields mean the decoration is not+ * available; they must not become rejected driver calls.+ */+export function selectAdvertisedComputerDriverArgs(+ name: string,+ input: Record<string, unknown>,+ schemas: ReadonlyMap<string, ComputerDriverToolSchema>,+): Record<string, unknown> | null {+ const schema = schemas.get(name);+ if (!schema) return null;+ if (schema.additionalProperties !== false) return { ...input };+ const properties = schema.properties ?? {};+ const args = Object.fromEntries(+ Object.entries(input).filter(([key, value]) => value !== undefined && Object.hasOwn(properties, key)),+ );+ return Object.keys(args).length > 0 ? args : null;+}+/** Fields Cindy may advertise after an older installed driver froze its schema. */const DRIVER_COMPAT_OPTIONAL_FIELDS = new Set(['delivery_mode']);diff --git a/apps/desktop/src/main/mcp-integrations/computer.ts b/apps/desktop/src/main/mcp-integrations/computer.tsindex 481003981f..49b048c1c4 100644--- a/apps/desktop/src/main/mcp-integrations/computer.ts+++ b/apps/desktop/src/main/mcp-integrations/computer.ts@@ -24,7 +24,11 @@ import type {import { createLogger } from '../logger.js';import { outboundFetch } from '../maker-host/outbound-fetch.js';import { resolveDesktopOutboundProxy } from '../maker-host/outbound-proxy-resolver.js';-import { adaptComputerDriverArgs, type ComputerDriverToolSchema } from './computer-contract.js';+import {+ adaptComputerDriverArgs,+ selectAdvertisedComputerDriverArgs,+ type ComputerDriverToolSchema,+} from './computer-contract.js';import { computerResultOutcome, getComputerTool, isUnavailableWindowObservation } from '@cindy/mcps/computer';import { callComputerToolWithOutputValidation } from './computer-output.js';@@ -2414,11 +2418,16 @@ async function initializeDefaultCursorStyle(assertActive();signal?.throwIfAborted();if (entry.cursorSetup[call.stateKey] !== 'pending') continue;+ const driverArgs = selectAdvertisedComputerDriverArgs(call.tool, call.args, entry.toolSchemas);+ if (!driverArgs) {+ entry.cursorSetup[call.stateKey] = 'unavailable';+ continue;+ }try {await callCuaMcpTool(entry,call.tool,- call.args,+ driverArgs,STATUS_TIMEOUT_MS,signal,);