refactor(cua): keep native preparation internal and remove duplicate checks

This commit is contained in:
creatixchu committed 2026-09-26 11:25:04 +08:00
1 parent a9683e8a23
commit f22177a1f9
8 files changed
+7 -14

No files matched your search

@@ -234,8 +234,8 @@ actor AXWorker {
guard let action = try ax().actions(selected).first(where: { Self.actionKey($0) == Self.actionKey(requested) }) else {
throw NativeFailure(code: "NATIVE_ERROR", message: "Element does not advertise this action; refresh getAXState")
}
try ax().requireEnabled(selected)
if action == "AXRaise" {
try ax().requireEnabled(selected)
return .foreground(ForegroundPlan(appHandle: handle, identity: identity, snapshotID: try params.string("snapshotId"),
index: try params.integer("elementIndex", in: 0...Int.max), targetWindowID: try ax().windowID(selected),
role: try ax().string(selected, "AXRole"), main: try ax().boolean(selected, "AXMain"), minimized: try ax().boolean(selected, "AXMinimized")))
@@ -62,7 +62,6 @@ import Darwin
do {
let request = try NativeRequest(data: data)
requestID = .string(request.id)
_ = try RequestParameters(request)
let requiresCatalog = ["getApp", "listApps", "typeText", "pressKey"].contains(request.method)
let catalog = requiresCatalog ? ApplicationCatalog.snapshot() : ApplicationCatalogSnapshot(applications: [], frontPID: nil)
let outcome = try await self.worker.execute(request, catalog: catalog)
-5
View File
@@ -27,15 +27,10 @@
"./bridge": {
"types": "./lib/types/bridge.d.ts",
"default": "./lib/bridge.js"
},
"./native-build": {
"types": "./lib/types/native-build.d.ts",
"default": "./lib/native-build.js"
}
},
"files": [
"lib/index.js",
"lib/native-build.js",
"native/bin",
"lib/api.js",
"lib/bridge.js",
@@ -84,7 +84,7 @@ async function compileNative(spec: NativeBuildSpec, signal: AbortSignal, executa
let outcome: SubprocessOutcome
try { outcome = await handle.done } finally {
try { handle.terminate() } finally {
if (!await handle.waitForExit()) throw new Error('Computer Use preparation process did not exit cleanly')
await handle.waitForExit()
}
}
signal.throwIfAborted()
@@ -111,10 +111,10 @@ it('awaits compiler cleanup and refuses to publish after cancellation', async ()
expect(f.spawn).toHaveBeenCalledTimes(1)
})
it('reports incomplete compiler process cleanup before publishing', async () => {
it('reports failed compiler range observation before publishing', async () => {
const f = await fixture()
f.waitForExit.mockResolvedValue(false)
await expect(buildNativeExecutable(f.spec)).rejects.toThrow('did not exit cleanly')
f.waitForExit.mockRejectedValue(new Error('compiler range observation failed'))
await expect(buildNativeExecutable(f.spec)).rejects.toThrow('compiler range observation failed')
await expect(readFile(nativeExecutablePath(f.spec.packageRoot, 'arm64'))).rejects.toMatchObject({ code: 'ENOENT' })
})
+1 -1
View File
@@ -1,7 +1,7 @@
import { defineConfig } from 'tsdown'
export default defineConfig(Object.entries({
index: 'lib/types/index.js', api: 'lib/types/api.js', bridge: 'lib/types/bridge.js', 'native-build': 'lib/types/native-build.js',
index: 'lib/types/index.js', api: 'lib/types/api.js', bridge: 'lib/types/bridge.js',
}).map(([name, path]) => ({
entry: { [name]: path },
outDir: 'lib', format: ['esm'], platform: 'node', target: 'es2024',
+1 -1
View File
@@ -175,7 +175,7 @@ export function readWorkspaceManifests(repositoryRoot: string): WorkspaceManifes
const packageFileExtras: Readonly<Record<string, readonly string[]>> = {
// CUA publishes its client API and attributed native source for local macOS builds.
'@deepseek-ai/dsh-cua': ['lib/native-build.js', 'native/bin', 'lib/api.js', 'lib/bridge.js', 'native/Package.swift', 'native/Sources', 'native/tests/swift', 'native/tests/test_swift.py', 'native/LICENSE.cua-driver', 'native/upstream.json', 'native/README.txt', 'native/protocol.schema.json'],
'@deepseek-ai/dsh-cua': ['native/bin', 'lib/api.js', 'lib/bridge.js', 'native/Package.swift', 'native/Sources', 'native/tests/swift', 'native/tests/test_swift.py', 'native/LICENSE.cua-driver', 'native/upstream.json', 'native/README.txt', 'native/protocol.schema.json'],
// Owned Worker bundles import this public bootstrap before their business entry.
'@deepseek-ai/dsh-app-boot': ['lib/worker/profile-resolution-bootstrap.js'],
// Statically linked client libraries keep their stylesheets next to the emitted
-1
View File
@@ -71,7 +71,6 @@
"@deepseek-ai/dsh-cua": ["./packages/computer-use/cua/src/index.ts"],
"@deepseek-ai/dsh-cua/api": ["./packages/computer-use/cua/src/api.ts"],
"@deepseek-ai/dsh-cua/bridge": ["./packages/computer-use/cua/src/bridge.ts"],
"@deepseek-ai/dsh-cua/native-build": ["./packages/computer-use/cua/src/native-build.ts"],
"@deepseek-ai/dsh-experimental-computer-use-cua-driver-native": ["./packages/experimental/computer-use-cua-driver-native/src/index.ts"],
"@deepseek-ai/cordis": ["./vendor/cordis/src"],
"@deepseek-ai/cosmokit": ["./vendor/cosmokit/src"],