mirror of
https://github.com/NanmiCoder/claude-code-haha.git
synced 2026-10-10 11:53:10 +08:00
b8a90626ce
Rebuilt against main so the branch carries the Computer Use work and no other divergence. Three unrelated efforts had been sitting uncommitted in this worktree and were swept into an earlier commit; they are preserved on cu-worktree-full-backup and belong on their own branches — adapter control credentials, Electron asar sealing, and the sidecar code-loading audit. Every file outside Computer Use now matches main exactly. The engine A Swift helper drives apps through the accessibility tree, with coordinate actuation for the Chromium and Electron apps whose tree is a bare window frame. Ten primitives matching the shape Codex uses, so an app's guidance and the model's habits transfer. Coordinate actions resolve their target window once and refuse when none can be named. The unbound event they used to fall back to is discarded by custom renderers, so a minimized target produced a whole session of "Action completed" with nothing behind it. Input acceptance is established for typing and key presses as well as clicks: each MCP call is seconds apart, so the keyboard cannot inherit the focus a click established. The synthetic focus notification is gated on the target not already being active — sent unconditionally it names window 0 at an app that already owns a key window, and nine window-bound clicks were discarded with the traffic lights fully lit. State the model can trust An off-screen target says so, and says which tools still reach it: element actions need no on-screen geometry, so an app with a real tree can still be driven from the Dock. A fully covered window is recovered once, then left alone — burying it again is the user wanting their screen back. A repeated capture is reported with the cause that actually applies rather than both, because coverage is something we compute. Signing The helper is signed under a stable identity before electron-builder sees it, and excluded from re-signing: macOS ties Accessibility and Screen Recording grants to the signing identity, so rotating it drops both on every update. Discoverability The desktop slash menu falls back to a directory scan while a session's CLI has not started, which is when the menu is first opened. Built-ins and bundled skills live in the binary, so /computer-use was absent until after the first message.
77 lines
2.2 KiB
TypeScript
77 lines
2.2 KiB
TypeScript
import { describe, expect, test } from 'bun:test'
|
|
import path from 'node:path'
|
|
|
|
const buildScript = path.resolve(import.meta.dirname, 'build.sh')
|
|
|
|
function resolveTimestampArgument(identity: string, mode = 'auto') {
|
|
const result = Bun.spawnSync([
|
|
'bash',
|
|
'-c',
|
|
[
|
|
'source "$1"',
|
|
'SIGN_IDENTITY="$2"',
|
|
'CU_HELPER_TIMESTAMP_MODE="$3"',
|
|
'resolve_timestamp_mode',
|
|
'printf "%s" "$CODESIGN_TIMESTAMP_ARG"',
|
|
].join('; '),
|
|
'cu-helper-build-test',
|
|
buildScript,
|
|
identity,
|
|
mode,
|
|
])
|
|
|
|
if (result.exitCode !== 0) {
|
|
throw new Error(result.stderr.toString() || `build.sh probe exited ${result.exitCode}`)
|
|
}
|
|
return result.stdout.toString()
|
|
}
|
|
|
|
function resolveIdentityWithOnlyDeveloperId() {
|
|
const result = Bun.spawnSync([
|
|
'bash',
|
|
'-c',
|
|
[
|
|
'source "$1"',
|
|
'first_apple_development_identity() { return 1; }',
|
|
'first_developer_id_application_identity() { printf "%s" "Developer ID Application: Example Corp (TEAM123456)"; }',
|
|
'resolve_identity',
|
|
'printf "%s" "$SIGN_IDENTITY"',
|
|
].join('; '),
|
|
'cu-helper-build-test',
|
|
buildScript,
|
|
])
|
|
|
|
return {
|
|
exitCode: result.exitCode,
|
|
stdout: result.stdout.toString(),
|
|
stderr: result.stderr.toString(),
|
|
}
|
|
}
|
|
|
|
describe('cu-helper build signing timestamp', () => {
|
|
test('uses a secure timestamp for Developer ID distribution signatures', () => {
|
|
expect(
|
|
resolveTimestampArgument('Developer ID Application: Example Corp (TEAM123456)'),
|
|
).toBe('--timestamp')
|
|
})
|
|
|
|
test('keeps local Apple Development builds offline by default', () => {
|
|
expect(
|
|
resolveTimestampArgument('Apple Development: Developer (TEAM123456)'),
|
|
).toBe('--timestamp=none')
|
|
})
|
|
|
|
test('allows CI to require a secure timestamp explicitly', () => {
|
|
expect(resolveTimestampArgument('0123456789ABCDEF', 'secure')).toBe('--timestamp')
|
|
})
|
|
})
|
|
|
|
describe('cu-helper build signing identity', () => {
|
|
test('falls through to Developer ID when no Apple Development identity exists', () => {
|
|
const result = resolveIdentityWithOnlyDeveloperId()
|
|
|
|
expect(result.exitCode).toBe(0)
|
|
expect(result.stdout).toBe('Developer ID Application: Example Corp (TEAM123456)')
|
|
})
|
|
})
|