feat: 添加初始项目结构和基础文件
CI - 构建、测试和质量检查 / Rust 代码检查 (push) Has been cancelled
CI - 构建、测试和质量检查 / 单元测试 (push) Has been cancelled
CI - 构建、测试和质量检查 / 代码格式检查 (push) Has been cancelled
CI - 构建、测试和质量检查 / Clippy 代码质量检查 (push) Has been cancelled
CI - 构建、测试和质量检查 / 构建可执行文件 (claude_code_rs, macos-latest, x86_64-apple-darwin) (push) Has been cancelled
CI - 构建、测试和质量检查 / 构建可执行文件 (claude_code_rs, ubuntu-latest, x86_64-unknown-linux-gnu) (push) Has been cancelled
CI - 构建、测试和质量检查 / 构建可执行文件 (claude_code_rs.exe, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
CI - 构建、测试和质量检查 / Rust 代码检查 (push) Has been cancelled
CI - 构建、测试和质量检查 / 单元测试 (push) Has been cancelled
CI - 构建、测试和质量检查 / 代码格式检查 (push) Has been cancelled
CI - 构建、测试和质量检查 / Clippy 代码质量检查 (push) Has been cancelled
CI - 构建、测试和质量检查 / 构建可执行文件 (claude_code_rs, macos-latest, x86_64-apple-darwin) (push) Has been cancelled
CI - 构建、测试和质量检查 / 构建可执行文件 (claude_code_rs, ubuntu-latest, x86_64-unknown-linux-gnu) (push) Has been cancelled
CI - 构建、测试和质量检查 / 构建可执行文件 (claude_code_rs.exe, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
- 添加 Rust GUI 桌面应用程序入口点 - 添加 TypeScript/JavaScript 项目基础结构文件 - 包含组件、工具、命令、服务和工具定义 - 添加配置文件如 .gitignore、.gitattributes 和 LICENSE - 包含图片资源和演示文件 - 为各种功能模块添加占位符和类型定义
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
export type PermissionMode =
|
||||
| 'ask'
|
||||
| 'skip_all_permission_checks'
|
||||
| 'follow_a_plan'
|
||||
|
||||
export type Logger = {
|
||||
info(message: string): void
|
||||
warn(message: string): void
|
||||
error(message: string): void
|
||||
}
|
||||
|
||||
export type ClaudeForChromeContext = {
|
||||
serverName?: string
|
||||
logger?: Logger
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export const BROWSER_TOOLS: Array<{ name: string; description: string }> = [
|
||||
{
|
||||
name: 'navigate',
|
||||
description: 'Navigate a browser tab to a URL.',
|
||||
},
|
||||
{
|
||||
name: 'read_page',
|
||||
description: 'Capture high-level page state from the active tab.',
|
||||
},
|
||||
{
|
||||
name: 'get_page_text',
|
||||
description: 'Read visible page text from the active tab.',
|
||||
},
|
||||
{
|
||||
name: 'find',
|
||||
description: 'Find a pattern within page content.',
|
||||
},
|
||||
{
|
||||
name: 'form_input',
|
||||
description: 'Fill or update form inputs in the page.',
|
||||
},
|
||||
{
|
||||
name: 'computer',
|
||||
description: 'Perform browser-scoped mouse and keyboard actions.',
|
||||
},
|
||||
{
|
||||
name: 'javascript_tool',
|
||||
description: 'Run page-scoped JavaScript in the browser tab.',
|
||||
},
|
||||
{
|
||||
name: 'tabs_context_mcp',
|
||||
description: 'List or inspect browser tabs.',
|
||||
},
|
||||
{
|
||||
name: 'tabs_create_mcp',
|
||||
description: 'Create a new browser tab.',
|
||||
},
|
||||
{
|
||||
name: 'resize_window',
|
||||
description: 'Resize the browser window.',
|
||||
},
|
||||
{
|
||||
name: 'upload_image',
|
||||
description: 'Upload an image into the current page flow.',
|
||||
},
|
||||
{
|
||||
name: 'read_console_messages',
|
||||
description: 'Read browser console messages.',
|
||||
},
|
||||
{
|
||||
name: 'read_network_requests',
|
||||
description: 'Read captured network requests.',
|
||||
},
|
||||
{
|
||||
name: 'shortcuts_list',
|
||||
description: 'List extension/browser shortcuts.',
|
||||
},
|
||||
{
|
||||
name: 'shortcuts_execute',
|
||||
description: 'Execute a configured extension/browser shortcut.',
|
||||
},
|
||||
{
|
||||
name: 'gif_creator',
|
||||
description: 'Create or manage simple browser recordings.',
|
||||
},
|
||||
{
|
||||
name: 'update_plan',
|
||||
description: 'Update an in-browser action plan.',
|
||||
},
|
||||
]
|
||||
|
||||
export function createClaudeForChromeMcpServer(context: ClaudeForChromeContext) {
|
||||
let closed = false
|
||||
const handlers = new Map<unknown, unknown>()
|
||||
|
||||
return {
|
||||
async connect() {
|
||||
context.logger?.warn(
|
||||
'Claude in Chrome MCP is running with a restored compatibility shim; browser actions are not available in this workspace.',
|
||||
)
|
||||
},
|
||||
setRequestHandler(schema: unknown, handler: unknown) {
|
||||
handlers.set(schema, handler)
|
||||
},
|
||||
async close() {
|
||||
closed = true
|
||||
handlers.clear()
|
||||
context.logger?.info(
|
||||
'Claude in Chrome MCP shim closed.',
|
||||
)
|
||||
},
|
||||
get isClosed() {
|
||||
return closed
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "@ant/claude-for-chrome-mcp",
|
||||
"version": "0.0.0-restored",
|
||||
"type": "module",
|
||||
"main": "./index.ts"
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
type MouseButton = 'left' | 'right' | 'middle'
|
||||
type MouseAction = 'press' | 'release' | 'click'
|
||||
type ScrollAxis = 'vertical' | 'horizontal'
|
||||
|
||||
export type FrontmostAppInfo = {
|
||||
bundleId?: string
|
||||
appName?: string
|
||||
}
|
||||
|
||||
export type ComputerUseInputAPI = {
|
||||
moveMouse(x: number, y: number, smooth?: boolean): Promise<void>
|
||||
mouseLocation(): Promise<{ x: number; y: number }>
|
||||
key(key: string, action?: 'press' | 'release' | 'click'): Promise<void>
|
||||
keys(keys: string[]): Promise<void>
|
||||
leftClick(): Promise<void>
|
||||
rightClick(): Promise<void>
|
||||
doubleClick(): Promise<void>
|
||||
middleClick(): Promise<void>
|
||||
dragMouse(x: number, y: number): Promise<void>
|
||||
scroll(x: number, y: number): Promise<void>
|
||||
type(text: string): Promise<void>
|
||||
mouseButton(
|
||||
button: MouseButton,
|
||||
action?: MouseAction,
|
||||
count?: number,
|
||||
): Promise<void>
|
||||
mouseScroll(amount: number, axis?: ScrollAxis): Promise<void>
|
||||
typeText(text: string): Promise<void>
|
||||
getFrontmostAppInfo(): FrontmostAppInfo | null
|
||||
}
|
||||
|
||||
export type ComputerUseInput =
|
||||
| ({ isSupported: false } & Partial<ComputerUseInputAPI>)
|
||||
| ({ isSupported: true } & ComputerUseInputAPI)
|
||||
|
||||
let cursor = { x: 0, y: 0 }
|
||||
|
||||
async function noOp(): Promise<void> {}
|
||||
|
||||
const supported: ComputerUseInput = {
|
||||
isSupported: process.platform === 'darwin',
|
||||
async moveMouse(x: number, y: number): Promise<void> {
|
||||
cursor = { x, y }
|
||||
},
|
||||
async mouseLocation(): Promise<{ x: number; y: number }> {
|
||||
return cursor
|
||||
},
|
||||
async key(_key: string, _action: 'press' | 'release' | 'click' = 'click') {
|
||||
await noOp()
|
||||
},
|
||||
async keys(_keys: string[]) {
|
||||
await noOp()
|
||||
},
|
||||
async leftClick() {
|
||||
await noOp()
|
||||
},
|
||||
async rightClick() {
|
||||
await noOp()
|
||||
},
|
||||
async doubleClick() {
|
||||
await noOp()
|
||||
},
|
||||
async middleClick() {
|
||||
await noOp()
|
||||
},
|
||||
async dragMouse(x: number, y: number) {
|
||||
cursor = { x, y }
|
||||
},
|
||||
async scroll(_x: number, _y: number) {
|
||||
await noOp()
|
||||
},
|
||||
async type(_text: string) {
|
||||
await noOp()
|
||||
},
|
||||
async mouseButton(
|
||||
_button: MouseButton,
|
||||
_action: MouseAction = 'click',
|
||||
_count = 1,
|
||||
) {
|
||||
await noOp()
|
||||
},
|
||||
async mouseScroll(_amount: number, _axis: ScrollAxis = 'vertical') {
|
||||
await noOp()
|
||||
},
|
||||
async typeText(_text: string) {
|
||||
await noOp()
|
||||
},
|
||||
getFrontmostAppInfo(): FrontmostAppInfo | null {
|
||||
return null
|
||||
},
|
||||
}
|
||||
|
||||
export default supported
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "@ant/computer-use-input",
|
||||
"version": "0.0.0-restored",
|
||||
"type": "module",
|
||||
"main": "./index.ts"
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
export const DEFAULT_GRANT_FLAGS = {
|
||||
accessibility: false,
|
||||
screenRecording: false,
|
||||
}
|
||||
|
||||
export const API_RESIZE_PARAMS = {}
|
||||
|
||||
export type ToolDef = {
|
||||
name: string
|
||||
description: string
|
||||
inputSchema?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export type DisplayGeometry = Record<string, unknown>
|
||||
export type FrontmostApp = Record<string, unknown>
|
||||
export type InstalledApp = { name?: string; bundleId?: string }
|
||||
export type ResolvePrepareCaptureResult = Record<string, unknown>
|
||||
export type RunningApp = Record<string, unknown>
|
||||
export type ScreenshotResult = Record<string, unknown>
|
||||
export type ScreenshotDims = {
|
||||
width: number
|
||||
height: number
|
||||
displayWidth?: number
|
||||
displayHeight?: number
|
||||
displayId?: number
|
||||
originX?: number
|
||||
originY?: number
|
||||
}
|
||||
export type CuPermissionRequest = {
|
||||
apps?: Array<{ bundleId?: string; displayName?: string }>
|
||||
flags?: Record<string, boolean>
|
||||
tccState?: { accessibility?: boolean; screenRecording?: boolean }
|
||||
}
|
||||
export type CuPermissionResponse = {
|
||||
granted: Array<{ bundleId?: string; displayName?: string; grantedAt?: string }>
|
||||
denied: Array<{ bundleId?: string; displayName?: string }>
|
||||
flags: Record<string, boolean>
|
||||
}
|
||||
export type CuCallToolResult = {
|
||||
is_error?: boolean
|
||||
content?: Array<{
|
||||
type: string
|
||||
text?: string
|
||||
mimeType?: string
|
||||
data?: string
|
||||
}>
|
||||
telemetry?: Record<string, unknown>
|
||||
}
|
||||
export type ComputerUseSessionContext = {
|
||||
onPermissionRequest?: (
|
||||
req: CuPermissionRequest,
|
||||
signal?: AbortSignal,
|
||||
) => Promise<CuPermissionResponse> | CuPermissionResponse
|
||||
getAllowedApps?: () => Array<{ bundleId?: string; displayName?: string }>
|
||||
getGrantFlags?: () => Record<string, boolean>
|
||||
[key: string]: unknown
|
||||
}
|
||||
export type ComputerExecutor = Record<string, unknown>
|
||||
|
||||
function successText(text: string): CuCallToolResult {
|
||||
return {
|
||||
content: [{ type: 'text', text }],
|
||||
}
|
||||
}
|
||||
|
||||
function errorText(text: string): CuCallToolResult {
|
||||
return {
|
||||
is_error: true,
|
||||
content: [{ type: 'text', text }],
|
||||
}
|
||||
}
|
||||
|
||||
export function targetImageSize(width: number, height: number) {
|
||||
return [width, height] as const
|
||||
}
|
||||
|
||||
const TOOL_DEFS: ToolDef[] = [
|
||||
{
|
||||
name: 'request_access',
|
||||
description:
|
||||
'Request access to applications and computer-use permissions for this session.',
|
||||
},
|
||||
{
|
||||
name: 'list_granted_applications',
|
||||
description: 'List applications currently granted for computer use.',
|
||||
},
|
||||
{ name: 'screenshot', description: 'Capture a screenshot.' },
|
||||
{ name: 'zoom', description: 'Capture a zoomed screenshot region.' },
|
||||
{ name: 'cursor_position', description: 'Read the current cursor position.' },
|
||||
{ name: 'mouse_move', description: 'Move the mouse cursor.' },
|
||||
{ name: 'left_click', description: 'Left click at a coordinate.' },
|
||||
{ name: 'right_click', description: 'Right click at a coordinate.' },
|
||||
{ name: 'middle_click', description: 'Middle click at a coordinate.' },
|
||||
{ name: 'double_click', description: 'Double click at a coordinate.' },
|
||||
{ name: 'triple_click', description: 'Triple click at a coordinate.' },
|
||||
{ name: 'left_mouse_down', description: 'Press the left mouse button.' },
|
||||
{ name: 'left_mouse_up', description: 'Release the left mouse button.' },
|
||||
{ name: 'left_click_drag', description: 'Drag with the left mouse button.' },
|
||||
{ name: 'scroll', description: 'Scroll at a coordinate or direction.' },
|
||||
{ name: 'type', description: 'Type text through the active application.' },
|
||||
{ name: 'key', description: 'Press a key or key chord.' },
|
||||
{ name: 'hold_key', description: 'Hold one or more keys for a duration.' },
|
||||
{ name: 'read_clipboard', description: 'Read clipboard text.' },
|
||||
{ name: 'write_clipboard', description: 'Write clipboard text.' },
|
||||
{
|
||||
name: 'open_application',
|
||||
description: 'Open an application by bundle identifier.',
|
||||
},
|
||||
{ name: 'wait', description: 'Wait for a short duration.' },
|
||||
{
|
||||
name: 'computer_batch',
|
||||
description: 'Execute a sequence of computer-use actions.',
|
||||
},
|
||||
]
|
||||
|
||||
export function buildComputerUseTools() {
|
||||
return TOOL_DEFS
|
||||
}
|
||||
|
||||
export function createComputerUseMcpServer(
|
||||
adapter?: { logger?: { warn(message: string): void; info?(message: string): void } },
|
||||
) {
|
||||
let closed = false
|
||||
const handlers = new Map<unknown, unknown>()
|
||||
|
||||
return {
|
||||
async connect() {
|
||||
adapter?.logger?.warn(
|
||||
'Computer Use MCP is running with a restored compatibility shim; request_access works, but native desktop actions remain unavailable in this workspace.',
|
||||
)
|
||||
},
|
||||
setRequestHandler(schema: unknown, handler: unknown) {
|
||||
handlers.set(schema, handler)
|
||||
},
|
||||
async close() {
|
||||
closed = true
|
||||
handlers.clear()
|
||||
adapter?.logger?.info?.('Computer Use MCP shim closed.')
|
||||
},
|
||||
get isClosed() {
|
||||
return closed
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export function bindSessionContext(
|
||||
_adapter?: unknown,
|
||||
_coordinateMode?: unknown,
|
||||
ctx?: ComputerUseSessionContext,
|
||||
) {
|
||||
return async (
|
||||
name: string,
|
||||
args: CuPermissionRequest | Record<string, unknown>,
|
||||
): Promise<CuCallToolResult> => {
|
||||
switch (name) {
|
||||
case 'request_access': {
|
||||
if (ctx?.onPermissionRequest) {
|
||||
const response = await ctx.onPermissionRequest(args as CuPermissionRequest)
|
||||
const grantedCount = Array.isArray(response.granted)
|
||||
? response.granted.length
|
||||
: 0
|
||||
return successText(
|
||||
grantedCount > 0
|
||||
? `Computer-use access updated for ${grantedCount} application(s).`
|
||||
: 'Computer-use access request completed.',
|
||||
)
|
||||
}
|
||||
return errorText(
|
||||
'Computer-use access approval is not configured in this restored workspace.',
|
||||
)
|
||||
}
|
||||
|
||||
case 'list_granted_applications': {
|
||||
const apps = ctx?.getAllowedApps?.() ?? []
|
||||
if (apps.length === 0) {
|
||||
return successText('No computer-use applications are currently granted.')
|
||||
}
|
||||
const names = apps
|
||||
.map(app => app.displayName || app.bundleId || 'unknown')
|
||||
.join(', ')
|
||||
return successText(`Granted computer-use applications: ${names}`)
|
||||
}
|
||||
|
||||
case 'read_clipboard':
|
||||
return errorText(
|
||||
'Clipboard access is unavailable in the restored computer-use shim.',
|
||||
)
|
||||
|
||||
default:
|
||||
return errorText(
|
||||
`Computer-use tool "${name}" is not available in this restored workspace. The shim currently supports session approval flows, but not native desktop execution.`,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "@ant/computer-use-mcp",
|
||||
"version": "0.0.0-restored",
|
||||
"type": "module",
|
||||
"main": "./index.ts",
|
||||
"exports": {
|
||||
".": "./index.ts",
|
||||
"./types": "./types.ts",
|
||||
"./sentinelApps": "./sentinelApps.ts"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export function getSentinelCategory() {
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
export const DEFAULT_GRANT_FLAGS = {
|
||||
accessibility: false,
|
||||
screenRecording: false,
|
||||
}
|
||||
|
||||
export type CoordinateMode = 'screen' | 'viewport'
|
||||
export type CuSubGates = Record<string, boolean>
|
||||
export type Logger = {
|
||||
silly?(message: string, ...args: unknown[]): void
|
||||
debug?(message: string, ...args: unknown[]): void
|
||||
info(message: string): void
|
||||
warn(message: string): void
|
||||
error(message: string): void
|
||||
}
|
||||
export type ComputerUseHostAdapter = {
|
||||
logger?: Logger
|
||||
executor?: Record<string, unknown>
|
||||
[key: string]: unknown
|
||||
}
|
||||
export type CuPermissionRequest = {
|
||||
apps?: Array<{ bundleId?: string; displayName?: string }>
|
||||
flags?: Record<string, boolean>
|
||||
tccState?: { accessibility?: boolean; screenRecording?: boolean }
|
||||
[key: string]: unknown
|
||||
}
|
||||
export type CuPermissionResponse = {
|
||||
granted: Array<{ bundleId?: string; displayName?: string; grantedAt?: string }>
|
||||
denied: Array<{ bundleId?: string; displayName?: string }>
|
||||
flags: Record<string, boolean>
|
||||
}
|
||||
@@ -0,0 +1,297 @@
|
||||
import { execFileSync } from 'child_process'
|
||||
|
||||
type DisplayGeometry = {
|
||||
id: number
|
||||
width: number
|
||||
height: number
|
||||
scaleFactor: number
|
||||
originX: number
|
||||
originY: number
|
||||
}
|
||||
|
||||
type InstalledApp = {
|
||||
bundleId: string
|
||||
displayName: string
|
||||
path?: string
|
||||
}
|
||||
|
||||
type RunningApp = {
|
||||
bundleId: string
|
||||
displayName: string
|
||||
}
|
||||
|
||||
type ScreenshotResult = {
|
||||
base64: string
|
||||
width: number
|
||||
height: number
|
||||
displayWidth: number
|
||||
displayHeight: number
|
||||
displayId: number
|
||||
originX: number
|
||||
originY: number
|
||||
}
|
||||
|
||||
const BLANK_JPEG_BASE64 =
|
||||
'/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxAQEBUQEBAVFRUVFRUVFRUVFRUVFRUVFRUXFhUVFRUYHSggGBolHRUVITEhJSkrLi4uFx8zODMsNygtLisBCgoKDg0OGhAQGi0mHyYtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLf/AABEIAAEAAQMBIgACEQEDEQH/xAAXAAADAQAAAAAAAAAAAAAAAAAAAQID/8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAAB6gD/xAAVEAEBAAAAAAAAAAAAAAAAAAABAP/aAAgBAQABBQJf/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwEf/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwEf/8QAFBABAAAAAAAAAAAAAAAAAAAAEP/aAAgBAQAGPwJf/8QAFBABAAAAAAAAAAAAAAAAAAAAEP/aAAgBAQABPyFf/9k='
|
||||
|
||||
function safeExec(
|
||||
file: string,
|
||||
args: string[],
|
||||
): { ok: true; stdout: string } | { ok: false } {
|
||||
try {
|
||||
const stdout = execFileSync(file, args, {
|
||||
encoding: 'utf8',
|
||||
stdio: ['ignore', 'pipe', 'ignore'],
|
||||
})
|
||||
return { ok: true, stdout: stdout.trim() }
|
||||
} catch {
|
||||
return { ok: false }
|
||||
}
|
||||
}
|
||||
|
||||
function getDefaultDisplay(): DisplayGeometry {
|
||||
return {
|
||||
id: 0,
|
||||
width: 1440,
|
||||
height: 900,
|
||||
scaleFactor: 1,
|
||||
originX: 0,
|
||||
originY: 0,
|
||||
}
|
||||
}
|
||||
|
||||
function getDisplay(displayId?: number): DisplayGeometry {
|
||||
const display = getDefaultDisplay()
|
||||
if (displayId === undefined || displayId === display.id) {
|
||||
return display
|
||||
}
|
||||
return { ...display, id: displayId }
|
||||
}
|
||||
|
||||
function buildScreenshotResult(
|
||||
width: number,
|
||||
height: number,
|
||||
displayId?: number,
|
||||
): ScreenshotResult {
|
||||
const display = getDisplay(displayId)
|
||||
return {
|
||||
base64: BLANK_JPEG_BASE64,
|
||||
width,
|
||||
height,
|
||||
displayWidth: display.width,
|
||||
displayHeight: display.height,
|
||||
displayId: display.id,
|
||||
originX: display.originX,
|
||||
originY: display.originY,
|
||||
}
|
||||
}
|
||||
|
||||
function openBundle(bundleId: string): void {
|
||||
if (!bundleId) return
|
||||
safeExec('open', ['-b', bundleId])
|
||||
}
|
||||
|
||||
function getRunningApps(): RunningApp[] {
|
||||
const result = safeExec('osascript', [
|
||||
'-e',
|
||||
'tell application "System Events" to get the name of every application process',
|
||||
])
|
||||
if (!result.ok || result.stdout.length === 0) return []
|
||||
return result.stdout
|
||||
.split(/\s*,\s*/u)
|
||||
.map(name => name.trim())
|
||||
.filter(Boolean)
|
||||
.map(name => ({
|
||||
bundleId: '',
|
||||
displayName: name,
|
||||
}))
|
||||
}
|
||||
|
||||
function createInstalledApp(displayName: string): InstalledApp {
|
||||
return {
|
||||
bundleId: '',
|
||||
displayName,
|
||||
}
|
||||
}
|
||||
|
||||
export type ComputerUseAPI = {
|
||||
_drainMainRunLoop(): void
|
||||
tcc: {
|
||||
checkAccessibility(): boolean
|
||||
checkScreenRecording(): boolean
|
||||
}
|
||||
hotkey: {
|
||||
registerEscape(onEscape: () => void): boolean
|
||||
unregister(): void
|
||||
notifyExpectedEscape(): void
|
||||
}
|
||||
display: {
|
||||
getSize(displayId?: number): DisplayGeometry
|
||||
listAll(): DisplayGeometry[]
|
||||
}
|
||||
apps: {
|
||||
prepareDisplay(
|
||||
allowlistBundleIds: string[],
|
||||
surrogateHost: string,
|
||||
displayId?: number,
|
||||
): Promise<{ hidden: string[]; activated?: string }>
|
||||
previewHideSet(
|
||||
allowlistBundleIds: string[],
|
||||
displayId?: number,
|
||||
): Promise<Array<{ bundleId: string; displayName: string }>>
|
||||
findWindowDisplays(
|
||||
bundleIds: string[],
|
||||
): Promise<Array<{ bundleId: string; displayIds: number[] }>>
|
||||
appUnderPoint(
|
||||
x: number,
|
||||
y: number,
|
||||
): Promise<{ bundleId: string; displayName: string } | null>
|
||||
listInstalled(): Promise<InstalledApp[]>
|
||||
iconDataUrl(path: string): string | null
|
||||
listRunning(): Promise<RunningApp[]>
|
||||
open(bundleId: string): Promise<void>
|
||||
unhide(bundleIds: string[]): Promise<void>
|
||||
}
|
||||
screenshot: {
|
||||
captureExcluding(
|
||||
allowedBundleIds: string[],
|
||||
quality: number,
|
||||
width: number,
|
||||
height: number,
|
||||
displayId?: number,
|
||||
): Promise<ScreenshotResult>
|
||||
captureRegion(
|
||||
allowedBundleIds: string[],
|
||||
x: number,
|
||||
y: number,
|
||||
width: number,
|
||||
height: number,
|
||||
outW: number,
|
||||
outH: number,
|
||||
quality: number,
|
||||
displayId?: number,
|
||||
): Promise<ScreenshotResult>
|
||||
}
|
||||
resolvePrepareCapture(
|
||||
allowedBundleIds: string[],
|
||||
surrogateHost: string,
|
||||
quality: number,
|
||||
targetW: number,
|
||||
targetH: number,
|
||||
preferredDisplayId?: number,
|
||||
autoResolve?: boolean,
|
||||
doHide?: boolean,
|
||||
): Promise<
|
||||
ScreenshotResult & {
|
||||
hidden: string[]
|
||||
activated?: string
|
||||
autoResolved: boolean
|
||||
}
|
||||
>
|
||||
}
|
||||
|
||||
const stub: ComputerUseAPI = {
|
||||
_drainMainRunLoop() {},
|
||||
tcc: {
|
||||
checkAccessibility() {
|
||||
return false
|
||||
},
|
||||
checkScreenRecording() {
|
||||
return false
|
||||
},
|
||||
},
|
||||
hotkey: {
|
||||
registerEscape(_onEscape: () => void) {
|
||||
return false
|
||||
},
|
||||
unregister() {},
|
||||
notifyExpectedEscape() {},
|
||||
},
|
||||
display: {
|
||||
getSize(displayId?: number) {
|
||||
return getDisplay(displayId)
|
||||
},
|
||||
listAll() {
|
||||
return [getDefaultDisplay()]
|
||||
},
|
||||
},
|
||||
apps: {
|
||||
async prepareDisplay(
|
||||
_allowlistBundleIds: string[],
|
||||
_surrogateHost: string,
|
||||
_displayId?: number,
|
||||
) {
|
||||
return { hidden: [] as string[] }
|
||||
},
|
||||
async previewHideSet(
|
||||
_allowlistBundleIds: string[],
|
||||
_displayId?: number,
|
||||
) {
|
||||
return []
|
||||
},
|
||||
async findWindowDisplays(bundleIds: string[]) {
|
||||
return bundleIds.map(bundleId => ({
|
||||
bundleId,
|
||||
displayIds: [],
|
||||
}))
|
||||
},
|
||||
async appUnderPoint(_x: number, _y: number) {
|
||||
return null
|
||||
},
|
||||
async listInstalled() {
|
||||
return getRunningApps().map(app => createInstalledApp(app.displayName))
|
||||
},
|
||||
iconDataUrl(_path: string) {
|
||||
return null
|
||||
},
|
||||
async listRunning() {
|
||||
return getRunningApps()
|
||||
},
|
||||
async open(bundleId: string) {
|
||||
openBundle(bundleId)
|
||||
},
|
||||
async unhide(_bundleIds: string[]) {},
|
||||
},
|
||||
screenshot: {
|
||||
async captureExcluding(
|
||||
_allowedBundleIds: string[],
|
||||
_quality: number,
|
||||
width: number,
|
||||
height: number,
|
||||
displayId?: number,
|
||||
) {
|
||||
return buildScreenshotResult(width, height, displayId)
|
||||
},
|
||||
async captureRegion(
|
||||
_allowedBundleIds: string[],
|
||||
_x: number,
|
||||
_y: number,
|
||||
_width: number,
|
||||
_height: number,
|
||||
outW: number,
|
||||
outH: number,
|
||||
_quality: number,
|
||||
displayId?: number,
|
||||
) {
|
||||
return buildScreenshotResult(outW, outH, displayId)
|
||||
},
|
||||
},
|
||||
async resolvePrepareCapture(
|
||||
_allowedBundleIds: string[],
|
||||
_surrogateHost: string,
|
||||
_quality: number,
|
||||
targetW: number,
|
||||
targetH: number,
|
||||
preferredDisplayId?: number,
|
||||
autoResolve = false,
|
||||
_doHide = false,
|
||||
) {
|
||||
return {
|
||||
...buildScreenshotResult(targetW, targetH, preferredDisplayId),
|
||||
hidden: [],
|
||||
autoResolved: autoResolve,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default stub
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "@ant/computer-use-swift",
|
||||
"version": "0.0.0-restored",
|
||||
"type": "module",
|
||||
"main": "./index.ts"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
export {
|
||||
ColorDiff,
|
||||
ColorFile,
|
||||
getSyntaxTheme,
|
||||
getNativeModule,
|
||||
} from '../../src/native-ts/color-diff/index.ts'
|
||||
export type {
|
||||
ColorDiffClass,
|
||||
ColorFileClass,
|
||||
Hunk,
|
||||
SyntaxTheme,
|
||||
} from '../../src/native-ts/color-diff/index.ts'
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "color-diff-napi",
|
||||
"version": "0.0.0-restored",
|
||||
"type": "module",
|
||||
"main": "./index.ts"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export {
|
||||
getModifiers,
|
||||
isModifierPressed,
|
||||
prewarm,
|
||||
} from '../../vendor/modifiers-napi-src/index.ts'
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "modifiers-napi",
|
||||
"version": "0.0.0-restored",
|
||||
"type": "module",
|
||||
"main": "./index.ts"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { waitForUrlEvent } from '../../vendor/url-handler-src/index.ts'
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "url-handler-napi",
|
||||
"version": "0.0.0-restored",
|
||||
"type": "module",
|
||||
"main": "./index.ts"
|
||||
}
|
||||
Reference in New Issue
Block a user