diff --git a/.fallowrc.json b/.fallowrc.json index 979cc3a6d7..69b82a35f1 100644 --- a/.fallowrc.json +++ b/.fallowrc.json @@ -367,11 +367,6 @@ "file": "packages/platform-harmonyos/src/app-lifecycle.ts", "exports": ["resolveHarmonyArchiveBundleName"] }, - { - // Linux package façade loader is a named external seam. Its dynamic property read is not visible to --production analysis. - "file": "packages/platform-linux/src/index.ts", - "exports": ["createLocalLinuxToolProvider"] - }, { // Web package façade loaders are named external seams. Their dynamic property reads are not visible to --production analysis, and the timeout is pinned by the daemon teardown test. "file": "packages/platform-web/src/index.ts", diff --git a/docs/adr/0001-provider-first-integration-scenarios.md b/docs/adr/0001-provider-first-integration-scenarios.md index 8ab82f1e5c..0d70f81730 100644 --- a/docs/adr/0001-provider-first-integration-scenarios.md +++ b/docs/adr/0001-provider-first-integration-scenarios.md @@ -8,6 +8,8 @@ Completed process history is in git history. > **Amended by [ADR 0019](0019-request-bound-platform-runtime.md).** Provider-first scenario coverage and semantic provider operations remain accepted. > Request-bound runtime facets and explicit provider ownership supersede the monolithic `Interactor` and the request callback-stack topology one command at a time. +> +> **Amended 2026-11-22 (Linux).** The Linux family has no request-scoped provider seam. Its desktop vocabulary is internal to `packages/platform-linux`, and the family answers every desktop intent through the `PlatformHost` its plugin was set up with. A Provider-backed integration scenario for Linux scripts that host instead of injecting a provider. The semantic Linux operations below still hold; the plugin owns them. ## Rules at a glance @@ -48,7 +50,6 @@ For commands that still use the legacy adapter, use these request-scoped provide - Android ADB provider. - Apple tool provider with semantic `simctl`, `devicectl`, macOS helper, and macOS host subproviders. - Apple runner provider. -- Linux tool provider with semantic subproviders for desktop lifecycle, accessibility, clipboard, and screenshots. - App-log provider for semantic start and stop of app log streams. - Recording provider for semantic local and remote screen-recording start operations that would otherwise be raw host processes. @@ -66,7 +67,7 @@ The macOS host provider owns these operations: The reason is that remote desktop providers should not need to infer these intents from `open`, `find`, `plutil`, `pbcopy`, `pbpaste`, or `osascript`. -Linux desktop lifecycle exposes semantic `openTarget` and `closeApp` operations for two reasons: +Linux desktop lifecycle uses semantic `openTarget` and `closeApp` operations internally for two reasons: - Provider-backed integration covers these user workflows. - Remote desktop providers should not need to infer intent from `xdg-open`, binary launch, `wmctrl`, or `pkill`. @@ -80,6 +81,8 @@ Linux accessibility snapshots, clipboard, screenshots, and input synthesis are a The local implementation details `python3`/AT-SPI, `xclip`, `scrot`, `grim`, `xdotool`, and `ydotool` are not the contracts. +The Linux family keeps that vocabulary to itself: the plugin builds one provider from the host it was set up with, and no request-scoped provider is resolved for it. A Linux scenario therefore scripts the host — which desktop tools exist, and what each command answers — and asserts the desktop argv the family produced. That keeps the plugin's own tool selection under test, which an injected provider would have stepped around. + App-log stream start/stop is semantic observability behavior, not generic host process execution. Thus, provider-backed integration injects an app-log provider, and it does not spawn `log stream` or `logcat`. diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 36efd27e7e..91d0a469d7 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -316,10 +316,6 @@ "types": "./src/macos-platform-leaf.ts", "default": "./src/macos-platform-leaf.ts" }, - "./linux-tool-provider": { - "types": "./src/linux-tool-provider.ts", - "default": "./src/linux-tool-provider.ts" - }, "./vega-tool-provider": { "types": "./src/vega-tool-provider.ts", "default": "./src/vega-tool-provider.ts" diff --git a/packages/contracts/src/platform-plugin.ts b/packages/contracts/src/platform-plugin.ts index 6be7bb9c55..377f86d96a 100644 --- a/packages/contracts/src/platform-plugin.ts +++ b/packages/contracts/src/platform-plugin.ts @@ -2,7 +2,6 @@ import type { ManagedWebBackend } from './managed-web-backend.ts'; import type { DoctorCheck } from './doctor.ts'; import type { HostDiagnosticsContext } from './host-diagnostics.ts'; import type { InventoryPlatformModule, PlatformModuleRegistry } from './platform-module.ts'; -import type { LinuxToolProvider } from './linux-tool-provider.ts'; import type { MacOsPlatformLeafSelection } from './macos-platform-leaf.ts'; import type { PlatformRuntimeModule } from './platform-runtime-operations.ts'; import type { WebProvider } from './web-provider.ts'; @@ -146,9 +145,9 @@ export type HarmonyPlatformSelection = Readonly<{ /** * What the core asks of the Linux plugin: the toolchain probe that answers `doctor --platform - * linux`, and the request scope the family owns. The desktop capture and every interaction the - * family runs go through the registration's runtime and interactor, which use the host the plugin - * was set up with. + * linux`. Every other Linux operation — the desktop capture, every interaction, and the host tool + * provider they all run through — the package owns, because it runs them through the host it was + * set up with. The provider never leaves the package, so the core names none of its vocabulary. */ export type LinuxPlatformOperations = Readonly<{ toolchainCheck(): Promise; @@ -159,7 +158,6 @@ export type LinuxPlatformRegistration = Readonly<{ inventoryModule: InventoryPlatformModule<'linux'>; runtimeModule: PlatformRuntimeModule & { readonly family: 'linux' }; createInteractor: PlatformPlugin['createInteractor']; - withRequestProvider(provider: LinuxToolProvider, task: () => Promise): Promise; operations: LinuxPlatformOperations; }>; diff --git a/packages/contracts/src/platform-providers.ts b/packages/contracts/src/platform-providers.ts index 7519e10d4d..1c18919636 100644 --- a/packages/contracts/src/platform-providers.ts +++ b/packages/contracts/src/platform-providers.ts @@ -64,5 +64,4 @@ export type PlatformGatedProviderResolverKey = | 'appleRunnerProvider' | 'appleToolProvider' | 'vegaToolProvider' - | 'linuxToolProvider' | 'webProvider'; diff --git a/packages/platform-linux/src/__tests__/input-actions.test.ts b/packages/platform-linux/src/__tests__/input-actions.test.ts index 6a253ca049..82c10cfcaf 100644 --- a/packages/platform-linux/src/__tests__/input-actions.test.ts +++ b/packages/platform-linux/src/__tests__/input-actions.test.ts @@ -3,7 +3,7 @@ import assert from 'node:assert/strict'; import { createLinuxHostStub, type LinuxHostStub } from '../toolbox.fixtures.ts'; import { createLinuxToolProvider } from '../tool-provider.ts'; import { fillLinux, pressLinux, scrollLinux, sendKey, typeLinux } from '../input-actions.ts'; -import type { LinuxToolProvider } from '@agent-device/contracts/linux-tool-provider'; +import type { LinuxToolProvider } from '../tool-provider-types.ts'; import { AppError } from '@agent-device/kernel/errors'; function x11Stub(): LinuxHostStub { diff --git a/packages/platform-linux/src/app-lifecycle.ts b/packages/platform-linux/src/app-lifecycle.ts index 47c06e1373..7b4409b7f6 100644 --- a/packages/platform-linux/src/app-lifecycle.ts +++ b/packages/platform-linux/src/app-lifecycle.ts @@ -1,4 +1,4 @@ -import type { LinuxToolProvider } from '@agent-device/contracts/linux-tool-provider'; +import type { LinuxToolProvider } from './tool-provider-types.ts'; import { sendKey } from './input-actions.ts'; /** diff --git a/packages/platform-linux/src/atspi-bridge.ts b/packages/platform-linux/src/atspi-bridge.ts index 8d2d07c885..aac53caa3d 100644 --- a/packages/platform-linux/src/atspi-bridge.ts +++ b/packages/platform-linux/src/atspi-bridge.ts @@ -10,7 +10,7 @@ import { AppError } from '@agent-device/kernel/errors'; import type { RawSnapshotNode, Rect } from '@agent-device/kernel/snapshot'; -import type { LinuxAccessibilityProvider } from '@agent-device/contracts/linux-tool-provider'; +import type { LinuxAccessibilityProvider } from './tool-provider-types.ts'; import { normalizeAtspiRole } from './role-map.ts'; import type { LinuxCommandRunner } from './command-runner.ts'; import { createLinuxAtspiScriptResolver, LINUX_ATSPI_SCRIPT_NAME } from './atspi-script.ts'; diff --git a/packages/platform-linux/src/clipboard.ts b/packages/platform-linux/src/clipboard.ts index 60106cd12b..09e93a4423 100644 --- a/packages/platform-linux/src/clipboard.ts +++ b/packages/platform-linux/src/clipboard.ts @@ -1,4 +1,4 @@ -import type { LinuxToolProvider } from '@agent-device/contracts/linux-tool-provider'; +import type { LinuxToolProvider } from './tool-provider-types.ts'; export async function readLinuxClipboard(provider: LinuxToolProvider): Promise { return await provider.clipboard.readText(); diff --git a/packages/platform-linux/src/command-runner.ts b/packages/platform-linux/src/command-runner.ts index 0670c47d52..8f71cb16ee 100644 --- a/packages/platform-linux/src/command-runner.ts +++ b/packages/platform-linux/src/command-runner.ts @@ -5,10 +5,7 @@ import type { DetachedCommandExit, HostOperatingSystem, } from '@agent-device/contracts/platform-runtime-host'; -import type { - LinuxCommandOptions, - LinuxCommandResult, -} from '@agent-device/contracts/linux-tool-provider'; +import type { LinuxCommandOptions, LinuxCommandResult } from './tool-provider-types.ts'; /** * The plugin's route to host commands, bound to the `PlatformHost` the core handed `setup()`. The diff --git a/packages/platform-linux/src/display.ts b/packages/platform-linux/src/display.ts index 30cf8415ba..6d8efce58b 100644 --- a/packages/platform-linux/src/display.ts +++ b/packages/platform-linux/src/display.ts @@ -1,4 +1,4 @@ -import type { LinuxDisplayServer } from '@agent-device/contracts/linux-tool-provider'; +import type { LinuxDisplayServer } from './tool-provider-types.ts'; /** The display decision bound to one host environment. */ export type LinuxDisplayConfig = Readonly<{ diff --git a/packages/platform-linux/src/doctor.ts b/packages/platform-linux/src/doctor.ts index 6687057bd5..8570c136aa 100644 --- a/packages/platform-linux/src/doctor.ts +++ b/packages/platform-linux/src/doctor.ts @@ -1,5 +1,5 @@ import type { DoctorCheck } from '@agent-device/contracts/observability'; -import type { LinuxToolProvider } from '@agent-device/contracts/linux-tool-provider'; +import type { LinuxToolProvider } from './tool-provider-types.ts'; import { linuxToolSlotCommands } from './tool-provider.ts'; /** diff --git a/packages/platform-linux/src/index.test.ts b/packages/platform-linux/src/index.test.ts index ac073960de..789f108524 100644 --- a/packages/platform-linux/src/index.test.ts +++ b/packages/platform-linux/src/index.test.ts @@ -106,7 +106,6 @@ test('setup registers the Linux modules and operations', () => { assert.equal(typeof registration.inventoryModule.loadInventory, 'function'); assert.equal(typeof registration.runtimeModule.loadRuntime, 'function'); assert.equal(typeof registration.createInteractor, 'function'); - assert.equal(typeof registration.withRequestProvider, 'function'); assert.equal(typeof registration.operations.toolchainCheck, 'function'); }); @@ -271,75 +270,6 @@ test('the Linux interactor drives the host the plugin was set up with', async () assert.equal(commands[0]?.env?.XDG_SESSION_TYPE, 'x11'); }); -test('a request-scoped provider answers the interactor instead of the setup host', async () => { - const hostCommands: HostCommand[] = []; - const registration = setupLinuxPlatform( - createPluginHost({ - env: { PATH: '/usr/bin', XDG_SESSION_TYPE: 'x11' }, - tools: ['xdotool'], - commands: hostCommands, - }), - ); - const scopedCommands: Array<[string, readonly string[]]> = []; - const scoped = { - display: { detectDisplayServer: () => 'x11' as const }, - runCommand: async (cmd: string, args: readonly string[]) => { - scopedCommands.push([cmd, args]); - return { stdout: '', stderr: '', exitCode: 0 }; - }, - whichCommand: async (cmd: string) => cmd === 'xdotool', - launchDetached: () => ({ exited: Promise.resolve({ pid: 1, exitCode: 0 }) }), - sleep: async () => {}, - desktop: { - openTarget: async () => {}, - closeApp: async () => {}, - }, - // The parts this request never reaches: reading one would mean the tap went somewhere the test - // did not script, so the assertion is the throw. - clipboard: { - readText: async () => { - throw new Error('this request reads no clipboard'); - }, - writeText: async () => { - throw new Error('this request writes no clipboard'); - }, - }, - screenshot: { - capture: async () => { - throw new Error('this request captures no screenshot'); - }, - }, - accessibility: { - captureTree: async () => { - throw new Error('this request captures no tree'); - }, - }, - }; - const interactor = await registration.createInteractor( - { - platform: 'linux', - id: 'local', - name: 'builder', - kind: 'device', - target: 'desktop', - booted: true, - }, - {}, - { env: {}, cwd: '/host-cwd' }, - ); - - await registration.withRequestProvider(scoped, async () => { - await interactor.tap(1, 2); - }); - - assert.deepEqual(scopedCommands, [ - ['xdotool', ['getmouselocation', '--shell']], - ['xdotool', ['mousemove', '--sync', '1', '2']], - ['xdotool', ['click', '1']], - ]); - assert.equal(hostCommands.length, 0); -}); - test('two setups keep separate host environments', async () => { const x11Commands: HostCommand[] = []; const waylandCommands: HostCommand[] = []; diff --git a/packages/platform-linux/src/index.ts b/packages/platform-linux/src/index.ts index cec790b7ce..67f556c1c0 100644 --- a/packages/platform-linux/src/index.ts +++ b/packages/platform-linux/src/index.ts @@ -9,7 +9,7 @@ import type { LinuxPlatformRegistration, } from '@agent-device/contracts/platform-plugin'; import type { LinuxToolbox } from './toolbox.ts'; -import type { LinuxToolProvider } from '@agent-device/contracts/linux-tool-provider'; +import type { LinuxToolProvider } from './tool-provider-types.ts'; const metadata = Object.freeze({ family: 'linux', @@ -75,10 +75,6 @@ function linuxPlatformPlugin() { const { toolbox, provider } = await bind(); return createLinuxInteractor(toolbox, provider); }, - withRequestProvider: async (provider: LinuxToolProvider, task: () => Promise) => { - const { withLinuxToolProvider } = await import('./tool-provider.ts'); - return await withLinuxToolProvider(provider, task); - }, operations: { toolchainCheck: async () => { const [{ linuxToolchainCheck }, { provider }] = await Promise.all([ diff --git a/packages/platform-linux/src/input-actions.ts b/packages/platform-linux/src/input-actions.ts index 9d3b78f386..f0fbb44171 100644 --- a/packages/platform-linux/src/input-actions.ts +++ b/packages/platform-linux/src/input-actions.ts @@ -1,8 +1,5 @@ import { discloseDispatchAfterSteps } from '@agent-device/kernel/errors'; -import type { - LinuxInputProvider, - LinuxToolProvider, -} from '@agent-device/contracts/linux-tool-provider'; +import type { LinuxInputProvider, LinuxToolProvider } from './tool-provider-types.ts'; import { DEFAULT_SCROLL_AMOUNT, type ScrollDirection, diff --git a/packages/platform-linux/src/interactor.ts b/packages/platform-linux/src/interactor.ts index f6166b1602..ddcd11d413 100644 --- a/packages/platform-linux/src/interactor.ts +++ b/packages/platform-linux/src/interactor.ts @@ -1,8 +1,7 @@ import { AppError } from '@agent-device/kernel/errors'; -import { withMethodScope } from '@agent-device/kernel/scoped-provider'; import { singlePointerPlanEndpoints } from '@agent-device/gestures/gesture-plan'; import type { Interactor } from '@agent-device/contracts/interactor-types'; -import type { LinuxToolProvider } from '@agent-device/contracts/linux-tool-provider'; +import type { LinuxToolProvider } from './tool-provider-types.ts'; import { backLinux, closeLinuxApp, homeLinux, openLinuxApp } from './app-lifecycle.ts'; import { readLinuxClipboard, writeLinuxClipboard } from './clipboard.ts'; import { @@ -20,49 +19,33 @@ import { import { readLinuxTextAtPoint } from './snapshot.ts'; import { captureLinuxSurfaceSnapshot } from './surface-snapshot.ts'; import { screenshotLinux } from './screenshot.ts'; -import { - hasScopedLinuxToolProvider, - resolveLinuxToolProvider, - withLinuxToolProvider, -} from './tool-provider.ts'; import type { LinuxToolbox } from './toolbox.ts'; /** * The Linux interactor, bound to the toolbox the plugin was set up with and to the provider built on * it: the display decision lives on that instance, never in module state, so another runtime's host - * cannot reach it (#3794). A request that scoped its own provider still wins — its scope is already - * entered when the daemon dispatches, so the interactor's provider enters only for a request that - * scoped none. Each method then resolves the provider in scope. + * cannot reach it (#3794). Every method uses that one provider — the family answers for its desktop + * only through the host it was set up with. */ export function createLinuxInteractor( toolbox: LinuxToolbox, provider: LinuxToolProvider, ): Interactor { - const body = createLinuxInteractorBody(toolbox, provider); - return withMethodScope(body, async (task) => - hasScopedLinuxToolProvider() ? await task() : await withLinuxToolProvider(provider, task), - ); -} - -function createLinuxInteractorBody(toolbox: LinuxToolbox, own: LinuxToolProvider): Interactor { - // Resolved per method rather than once at construction: the request scope is entered for the - // method, and its provider is the one that must answer. - const running = () => resolveLinuxToolProvider(own); return { - open: (app) => openLinuxApp(running(), app), + open: (app) => openLinuxApp(provider, app), openDevice: () => Promise.resolve(), - close: (app) => closeLinuxApp(running(), app), - tap: (x, y) => pressLinux(running(), x, y), + close: (app) => closeLinuxApp(provider, app), + tap: (x, y) => pressLinux(provider, x, y), alternateClick: async (point, button) => button === 'secondary' - ? await rightClickLinux(running(), point.x, point.y) - : await middleClickLinux(running(), point.x, point.y), - doubleTap: (x, y) => doubleClickLinux(running(), x, y), - longPress: (x, y, durationMs) => longPressLinux(running(), x, y, durationMs), - focus: (x, y) => focusLinux(running(), x, y), - type: (text, delayMs) => typeLinux(running(), text, delayMs), - fill: (x, y, text, delayMs) => fillLinux(running(), x, y, text, delayMs), - scroll: (direction, options) => scrollLinux(running(), direction, options), + ? await rightClickLinux(provider, point.x, point.y) + : await middleClickLinux(provider, point.x, point.y), + doubleTap: (x, y) => doubleClickLinux(provider, x, y), + longPress: (x, y, durationMs) => longPressLinux(provider, x, y, durationMs), + focus: (x, y) => focusLinux(provider, x, y), + type: (text, delayMs) => typeLinux(provider, text, delayMs), + fill: (x, y, text, delayMs) => fillLinux(provider, x, y, text, delayMs), + scroll: (direction, options) => scrollLinux(provider, direction, options), performGesture: async (plan) => { if (plan.topology !== 'single') { throw new AppError( @@ -71,33 +54,33 @@ function createLinuxInteractorBody(toolbox: LinuxToolbox, own: LinuxToolProvider ); } const { start, end } = singlePointerPlanEndpoints(plan); - await swipeLinux(running(), start.x, start.y, end.x, end.y, plan.durationMs); + await swipeLinux(provider, start.x, start.y, end.x, end.y, plan.durationMs); }, - screenshot: (outPath, options) => screenshotLinux(running(), outPath, options), + screenshot: (outPath, options) => screenshotLinux(provider, outPath, options), // The Linux read is value-first (AXValue/title/description) where the captured tree is // label-first, so this genuinely reads differently from its snapshot text. readTextAtPoint: async (point, options) => - await readLinuxTextAtPoint(toolbox, running(), point.x, point.y, options?.surface), + await readLinuxTextAtPoint(toolbox, provider, point.x, point.y, options?.surface), snapshot: async (options) => await toolbox.withDiagnosticTimer( 'snapshot_capture', - async () => await captureLinuxSurfaceSnapshot(toolbox, running(), options, options?.signal), + async () => await captureLinuxSurfaceSnapshot(toolbox, provider, options, options?.signal), { backend: 'linux-atspi' }, ), - back: () => backLinux(running()), - home: () => homeLinux(running()), - setOrientation: () => { + back: () => backLinux(provider), + home: () => homeLinux(provider), + setOrientation: async () => { throw new AppError('UNSUPPORTED_OPERATION', 'orientation not supported on Linux'); }, - appSwitcher: () => { + appSwitcher: async () => { throw new AppError('UNSUPPORTED_OPERATION', 'appSwitcher not yet supported on Linux'); }, - tvRemote: () => { + tvRemote: async () => { throw new AppError('UNSUPPORTED_OPERATION', 'tv-remote not supported on Linux'); }, - readClipboard: () => readLinuxClipboard(running()), - writeClipboard: (text) => writeLinuxClipboard(running(), text), - setSetting: () => { + readClipboard: () => readLinuxClipboard(provider), + writeClipboard: (text) => writeLinuxClipboard(provider, text), + setSetting: async () => { throw new AppError('UNSUPPORTED_OPERATION', 'setSetting not supported on Linux'); }, }; diff --git a/packages/platform-linux/src/linux-env.ts b/packages/platform-linux/src/linux-env.ts index ee5ccb4287..14a47cabde 100644 --- a/packages/platform-linux/src/linux-env.ts +++ b/packages/platform-linux/src/linux-env.ts @@ -7,10 +7,7 @@ */ import { AppError } from '@agent-device/kernel/errors'; -import type { - LinuxInputSelection, - LinuxToolProvider, -} from '@agent-device/contracts/linux-tool-provider'; +import type { LinuxInputSelection, LinuxToolProvider } from './tool-provider-types.ts'; export async function ensureInputTool(provider: LinuxToolProvider): Promise { const display = provider.display.detectDisplayServer(); diff --git a/packages/platform-linux/src/runtime.test.ts b/packages/platform-linux/src/runtime.test.ts index 4f1ab7e5f1..de48427c52 100644 --- a/packages/platform-linux/src/runtime.test.ts +++ b/packages/platform-linux/src/runtime.test.ts @@ -9,7 +9,7 @@ import type { DeviceInfo } from '@agent-device/kernel/device'; import { createLinuxHostStub, type LinuxHostStub } from './toolbox.fixtures.ts'; import { createLinuxToolProvider } from './tool-provider.ts'; import { createLinuxPlatformRuntime } from './runtime.ts'; -import type { LinuxSnapshotSurface } from '@agent-device/contracts/linux-tool-provider'; +import type { LinuxSnapshotSurface } from './tool-provider-types.ts'; type LegacyLifecycleCell = Readonly<{ openTarget: boolean; diff --git a/packages/platform-linux/src/runtime.ts b/packages/platform-linux/src/runtime.ts index 8e25019dc3..1de84b42f5 100644 --- a/packages/platform-linux/src/runtime.ts +++ b/packages/platform-linux/src/runtime.ts @@ -42,9 +42,8 @@ import { typeTextRuntimeOperationFacts } from '@agent-device/contracts/type-text import { touchRuntimeOperationFacts } from '@agent-device/contracts/touch-runtime'; import type { DeviceInfo } from '@agent-device/kernel/device'; import { AppError } from '@agent-device/kernel/errors'; -import type { LinuxToolProvider } from '@agent-device/contracts/linux-tool-provider'; +import type { LinuxToolProvider } from './tool-provider-types.ts'; import { captureLinuxSurfaceSnapshot } from './surface-snapshot.ts'; -import { resolveLinuxToolProvider } from './tool-provider.ts'; import type { LinuxToolbox } from './toolbox.ts'; const supported = Object.freeze({ available: true } as const); @@ -156,11 +155,6 @@ export function createLinuxPlatformRuntime( throw new AppError('UNSUPPORTED_PLATFORM', 'Linux runtime cannot bind this device'); } const facts = linuxFacts(request.device); - // The provider this binding answers with, resolved once: the request scope is already entered - // when the runtime gateway binds, so a request that scoped its own provider is the one that - // answers for every operation of this binding. Resolving here rather than per call is what keeps - // one binding from asking the same question twice. - const running = resolveLinuxToolProvider(provider); const lifecycle = bindLocalDirectApplicationLifecycle({ owner: 'Linux', openTargetIdentity: 'app-name', @@ -175,7 +169,7 @@ export function createLinuxPlatformRuntime( operations: Object.freeze({ ...availableApplicationLifecycleOperations(lifecycle, facts.operations), ...(facts.operations.captureSnapshot.available - ? linuxSnapshotOperations(toolbox, running, request) + ? linuxSnapshotOperations(toolbox, provider, request) : {}), ...linuxInteractionOperations(host, request, facts), }), diff --git a/packages/platform-linux/src/screenshot.ts b/packages/platform-linux/src/screenshot.ts index 5b1a3b77fa..42a4b37175 100644 --- a/packages/platform-linux/src/screenshot.ts +++ b/packages/platform-linux/src/screenshot.ts @@ -1,5 +1,5 @@ import type { ScreenshotOptions } from '@agent-device/contracts/interactor-types'; -import type { LinuxToolProvider } from '@agent-device/contracts/linux-tool-provider'; +import type { LinuxToolProvider } from './tool-provider-types.ts'; export async function screenshotLinux( provider: LinuxToolProvider, diff --git a/packages/platform-linux/src/snapshot.ts b/packages/platform-linux/src/snapshot.ts index 0712b3fa0a..6d79077a34 100644 --- a/packages/platform-linux/src/snapshot.ts +++ b/packages/platform-linux/src/snapshot.ts @@ -1,5 +1,5 @@ import type { RawSnapshotNode } from '@agent-device/kernel/snapshot'; -import type { LinuxToolProvider } from '@agent-device/contracts/linux-tool-provider'; +import type { LinuxToolProvider } from './tool-provider-types.ts'; import type { LinuxToolbox } from './toolbox.ts'; import type { SessionSurface } from '@agent-device/contracts/session'; diff --git a/packages/platform-linux/src/surface-snapshot.ts b/packages/platform-linux/src/surface-snapshot.ts index 7c73794642..788e84e95f 100644 --- a/packages/platform-linux/src/surface-snapshot.ts +++ b/packages/platform-linux/src/surface-snapshot.ts @@ -2,7 +2,7 @@ import { stampSnapshotIdentity } from '@agent-device/contracts/snapshot-producer import type { CaptureSnapshotInput } from '@agent-device/contracts/snapshot-runtime'; import { shapeDesktopSurfaceSnapshot } from '@agent-device/capture-kit/snapshot-desktop-projection'; import { snapshotLinux } from './snapshot.ts'; -import type { LinuxToolProvider } from '@agent-device/contracts/linux-tool-provider'; +import type { LinuxToolProvider } from './tool-provider-types.ts'; import type { LinuxToolbox } from './toolbox.ts'; /** diff --git a/packages/contracts/src/linux-tool-provider.ts b/packages/platform-linux/src/tool-provider-types.ts similarity index 71% rename from packages/contracts/src/linux-tool-provider.ts rename to packages/platform-linux/src/tool-provider-types.ts index e39cdbec80..79b20a5eeb 100644 --- a/packages/contracts/src/linux-tool-provider.ts +++ b/packages/platform-linux/src/tool-provider-types.ts @@ -1,18 +1,17 @@ /** - * The Linux host-tool surface a request scopes (ADR 0019 host execution). + * The Linux host-tool vocabulary the family drives its desktop with (ADR 0019 host execution). * - * The Linux family drives desktop tools — `xdotool`, `ydotool`, a clipboard tool, a screenshot - * tool, and the AT-SPI helper — through this vocabulary. Root composition passes a resolved - * provider back to the Linux plugin without naming its implementation, exactly as it does for the - * Vega family's CLI adapter, so a request that owns a display decision and a command route hands - * them to the family instead of the family reaching process globals of its own. + * The Linux family runs desktop tools — `xdotool`, `ydotool`, a clipboard tool, a screenshot tool, + * and the AT-SPI helper — through this shape. One instance answers one `PlatformHost`: the toolbox + * built from the host the plugin was set up with supplies the command route, and the display + * decision comes from that host's environment. Nothing outside this package builds or receives it. */ import type { RawSnapshotNode } from '@agent-device/kernel/snapshot'; -import type { DetachedCommandExit } from './platform-runtime-host.ts'; -import type { ClickButton } from './click-button.ts'; -import type { ScrollDirection } from './scroll-gesture.ts'; -import type { SessionSurface } from './session-surface.ts'; +import type { DetachedCommandExit } from '@agent-device/contracts/platform-runtime-host'; +import type { ClickButton } from '@agent-device/contracts/click-button'; +import type { ScrollDirection } from '@agent-device/contracts/scroll-gesture'; +import type { SessionSurface } from '@agent-device/contracts/session'; /** The Linux family's display-server vocabulary, from one detector. */ export type LinuxDisplayServer = 'wayland' | 'x11'; @@ -41,12 +40,10 @@ export type LinuxCommandOptions = Readonly<{ }>; /** - * The desktop-provider parts one request may supply. Each part answers one semantic intent of the - * Linux interactor, so a caller that owns a surface — a scripted desktop, a display server it - * drives directly — substitutes it for the family's own tool route without reimplementing the - * interactor. Only `input` is optional, and only because the family's own synthesis is a fallback for - * it. Every other part is mandatory: the interactor reads each one on a plain Linux request, so a - * caller that omits one is a type error rather than a `TypeError` at the first dereference. + * The Linux desktop surface one setup drives: the command primitives, read from the family's own + * host, and the semantic parts built on them. `input` is the only optional part because the + * family's own xdotool/ydotool synthesis is the fallback for it; every other part is mandatory, + * because the interactor reads each one on a plain Linux request. */ export type LinuxToolProvider = Readonly<{ /** The display decision every local tool selection in this provider shares (#3794). */ diff --git a/packages/platform-linux/src/tool-provider.ts b/packages/platform-linux/src/tool-provider.ts index a032c547a2..ed71aa672b 100644 --- a/packages/platform-linux/src/tool-provider.ts +++ b/packages/platform-linux/src/tool-provider.ts @@ -1,17 +1,14 @@ import { AppError } from '@agent-device/kernel/errors'; -import { createScopedProvider } from '@agent-device/kernel/scoped-provider'; import type { LinuxClipboardProvider, LinuxDesktopProvider, LinuxScreenshotProvider, LinuxToolProvider, -} from '@agent-device/contracts/linux-tool-provider'; +} from './tool-provider-types.ts'; import { createLinuxAccessibilityProvider } from './atspi-bridge.ts'; import type { LinuxToolbox } from './toolbox.ts'; import { createLinuxDisplayConfig } from './display.ts'; -export type { LinuxToolProvider } from '@agent-device/contracts/linux-tool-provider'; - /** The parts a caller may supply over the family's own tool route, each answering one intent. */ export type LinuxToolProviderOverrides = Partial>; @@ -60,34 +57,6 @@ function withCommandOverrides( }); } -/** - * The request scope the Linux family owns. Root composition resolves a provider for a request and - * hands it back to the plugin through the registration's `withRequestProvider`, which enters it for - * the request's work. The interactor and the runtime read the entered provider in preference to the - * one built from their own host, so a request that owns a display decision and a command route is the - * only one that answers for it. - */ -const linuxToolProviderScope = createScopedProvider< - LinuxToolProvider | undefined, - LinuxToolProvider ->(undefined); - -/** The provider this call should use: the one a request scoped, else the caller's own. */ -export function resolveLinuxToolProvider(own: LinuxToolProvider): LinuxToolProvider { - return linuxToolProviderScope.resolve() ?? own; -} - -export function hasScopedLinuxToolProvider(): boolean { - return linuxToolProviderScope.hasScope(); -} - -export async function withLinuxToolProvider( - provider: LinuxToolProvider | undefined, - fn: () => Promise, -): Promise { - return await linuxToolProviderScope.run(provider, fn); -} - function createLinuxDesktopProvider(commands: LinuxToolbox['commands']): LinuxDesktopProvider { return { async openTarget(target) { diff --git a/packages/platform-linux/src/toolbox.fixtures.ts b/packages/platform-linux/src/toolbox.fixtures.ts index 7f26d51b39..10148ab794 100644 --- a/packages/platform-linux/src/toolbox.fixtures.ts +++ b/packages/platform-linux/src/toolbox.fixtures.ts @@ -4,7 +4,7 @@ import { mkdtempForTestSync } from '@agent-device/test-kit'; import type { HostEnvironment } from '@agent-device/kernel/source-value'; import type { PlatformHost } from 'agent-device/plugins'; import type { DetachedCommandExit } from '@agent-device/contracts/platform-runtime-host'; -import type { LinuxCommandResult } from '@agent-device/contracts/linux-tool-provider'; +import type { LinuxCommandResult } from './tool-provider-types.ts'; import { createLinuxToolbox, type LinuxToolbox } from './toolbox.ts'; /** One command this stubbed host was asked to run, plus the environment it was handed. */ diff --git a/packages/plugins/src/platform.ts b/packages/plugins/src/platform.ts index 3f51507e61..8590e492de 100644 --- a/packages/plugins/src/platform.ts +++ b/packages/plugins/src/platform.ts @@ -12,7 +12,6 @@ import type { WebPlatformRegistration, } from '@agent-device/contracts/platform-plugin'; import type { PlatformRuntimeModule } from '@agent-device/contracts/platform-runtime-operations'; -import type { LinuxToolProvider } from '@agent-device/contracts/linux-tool-provider'; import type { MacOsPlatformLeafRegistration } from '@agent-device/contracts/macos-platform-leaf'; import type { DetachedCommandLaunch, @@ -274,13 +273,7 @@ export type PlatformSetup = Family extends P : Family extends 'harmonyos' ? Readonly<{ operations: HarmonyPlatformOperations }> : Family extends 'linux' - ? Readonly<{ - withRequestProvider( - provider: LinuxToolProvider, - task: () => Promise, - ): Promise; - operations: LinuxPlatformOperations; - }> + ? Readonly<{ operations: LinuxPlatformOperations }> : unknown) : never; diff --git a/packages/plugins/src/validate.ts b/packages/plugins/src/validate.ts index eeb5debd4e..a65e8a69ad 100644 --- a/packages/plugins/src/validate.ts +++ b/packages/plugins/src/validate.ts @@ -495,11 +495,10 @@ const PLATFORM_SETUP_CHECKS: Partial typeof operations[operation] !== 'function') ) { - throw invalidPlugin('Linux platform setup must supply request scoping and Linux operations'); + throw invalidPlugin('Linux platform setup must supply Linux operations'); } }, }; diff --git a/scripts/layering/contracts-exports.snapshot.json b/scripts/layering/contracts-exports.snapshot.json index db8536d2b9..dbeba6c94d 100644 --- a/scripts/layering/contracts-exports.snapshot.json +++ b/scripts/layering/contracts-exports.snapshot.json @@ -71,7 +71,6 @@ "@agent-device/contracts/keyboard", "@agent-device/contracts/keyboard-runtime", "@agent-device/contracts/lease-scope", - "@agent-device/contracts/linux-tool-provider", "@agent-device/contracts/local-interactor-operation-set", "@agent-device/contracts/logs-runtime-plan", "@agent-device/contracts/macos-platform-leaf", diff --git a/src/core/platform-plugin-registry-provider-routing.test.ts b/src/core/platform-plugin-registry-provider-routing.test.ts index 490825980c..1e7dc0ebcb 100644 --- a/src/core/platform-plugin-registry-provider-routing.test.ts +++ b/src/core/platform-plugin-registry-provider-routing.test.ts @@ -26,7 +26,6 @@ import { WEB_DESKTOP_DEVICE, } from '@agent-device/test-kit'; import { builtinPlatformPlugins } from './interactors/builtin-platform-plugin-set.ts'; -import { linuxSelectionFixture } from '../platform-runtime-linux-provider.fixtures.ts'; import { vegaSelectionFixture } from '../platform-runtime-vega-provider.fixtures.ts'; import { webSelectionFixture } from '../platform-runtime-web-provider.fixtures.ts'; import { @@ -39,7 +38,6 @@ const GATED_KEYS: PlatformGatedProviderResolverKey[] = [ 'appleRunnerProvider', 'appleToolProvider', 'vegaToolProvider', - 'linuxToolProvider', 'webProvider', ]; const UNGATED_KEYS = [ @@ -49,7 +47,7 @@ const UNGATED_KEYS = [ function gatedResolversByHand( device: DeviceInfo, - served: Partial> = {}, + served: Partial> = {}, ): Set { const applies = new Set(); if (device.platform === 'android') applies.add('androidAdbProvider'); @@ -60,7 +58,6 @@ function gatedResolversByHand( // An optional family this process does not serve is never asked for a provider: its selection is // absent, so there is no scope to enter and a resolver may otherwise open a session nothing closes. if (device.platform === 'vega' && served.vega === true) applies.add('vegaToolProvider'); - if (device.platform === 'linux' && served.linux === true) applies.add('linuxToolProvider'); // Web is the exception: its resolver has no session or process to open, so it runs for a web device // either way, and only the scope entry needs the selection. if (device.platform === 'web') applies.add('webProvider'); @@ -103,11 +100,7 @@ const SAMPLE_DEVICES: DeviceInfo[] = [ ...buildDeviceMatrix(), ]; -const PLUGIN_OWNED_KEYS: PlatformGatedProviderResolverKey[] = [ - 'linuxToolProvider', - 'vegaToolProvider', - 'webProvider', -]; +const PLUGIN_OWNED_KEYS: PlatformGatedProviderResolverKey[] = ['vegaToolProvider', 'webProvider']; const BUILT_IN_KEYS = GATED_KEYS.filter((key) => !PLUGIN_OWNED_KEYS.includes(key)); test('built-in provider facets retain the former routing', () => { @@ -148,7 +141,6 @@ test('root provider composition asks an optional family only when the process se // Served families are supplied here; a family the process does not serve is the same run with its // selection left out, and then its resolver must not run at all. const served = { - linux: linuxSelectionFixture(), vega: vegaSelectionFixture(), web: webSelectionFixture(), }; @@ -164,7 +156,6 @@ test('root provider composition asks an optional family only when the process se appleRunnerProvider: spy('appleRunnerProvider'), appleToolProvider: spy('appleToolProvider'), vegaToolProvider: spy('vegaToolProvider'), - linuxToolProvider: spy('linuxToolProvider'), webProvider: spy('webProvider'), appleRunnerScreenRecordingTransport: spy('appleRunnerScreenRecordingTransport'), appleSimulatorScreenRecordingTransport: spy('appleSimulatorScreenRecordingTransport'), @@ -179,15 +170,13 @@ test('root provider composition asks an optional family only when the process se }; await createRequestPlatformProviders({ providers, - ...(serves ? { linux: served.linux, vega: served.vega, web: served.web } : {}), + ...(serves ? { vega: served.vega, web: served.web } : {}), }).run(context, async () => {}); const gatedInvoked = new Set(GATED_KEYS.filter((key) => invoked.has(key))); assert.deepEqual( [...gatedInvoked].sort(), - [ - ...gatedResolversByHand(device, serves ? { linux: true, vega: true, web: true } : {}), - ].sort(), + [...gatedResolversByHand(device, serves ? { vega: true, web: true } : {})].sort(), `gated resolvers invoked for ${device.id}`, ); for (const key of UNGATED_KEYS) { diff --git a/src/daemon-composition.ts b/src/daemon-composition.ts index 01786196ea..85bef79f8d 100644 --- a/src/daemon-composition.ts +++ b/src/daemon-composition.ts @@ -163,7 +163,6 @@ export async function composeDaemonRuntimeDeps( }, web, vega, - linux, }); const deviceInventoryGateways = await createPlatformDeviceInventoryGateways( host, diff --git a/src/platform-runtime-linux-provider.fixtures.ts b/src/platform-runtime-linux-provider.fixtures.ts index a4e84e583e..4d6601086d 100644 --- a/src/platform-runtime-linux-provider.fixtures.ts +++ b/src/platform-runtime-linux-provider.fixtures.ts @@ -22,9 +22,18 @@ export function linuxSelectionFixture( host: HostEnvironment = createLiveTestHostEnvironment(), stateDir = '/test-linux-state', ): LinuxPlatformSelection { - const active = linuxPlatformPlugin().contributes[0].setup( - createPlatformPluginHost(host, stateDir), - ); + return linuxSelectionFromPlatformHost(createPlatformPluginHost(host, stateDir)); +} + +/** + * The Linux selection a caller installs for one `PlatformHost`. + * + * The family answers every desktop intent through the host its `setup` receives, so a test that wants + * to drive it names that host rather than a provider: the plugin's own inventory, runtime, interactor + * and tool plumbing are then the code under test. + */ +export function linuxSelectionFromPlatformHost(host: PlatformHost): LinuxPlatformSelection { + const active = linuxPlatformPlugin().contributes[0].setup(host); return { active, get: () => active }; } diff --git a/src/platform-runtime-provider-scope.test.ts b/src/platform-runtime-provider-scope.test.ts index a95cc1dff7..8f0527dd4c 100644 --- a/src/platform-runtime-provider-scope.test.ts +++ b/src/platform-runtime-provider-scope.test.ts @@ -54,9 +54,6 @@ test('Apple provider scope uses the request device for Apple tool calls', async }, }); }, - linuxToolProvider: () => { - throw new Error('Linux provider should not apply to an iOS session'); - }, }, async () => await runXcrun(buildSimctlArgsForDevice(IOS_SIMULATOR, ['list', 'devices', '-j'])), ); @@ -170,9 +167,6 @@ test('web provider scope uses the context device', async () => { calls.push(`${session?.name}:${device.id}`); return webProvider; }, - linuxToolProvider: () => { - throw new Error('Linux provider should not apply to a web session'); - }, }, async () => await (await scopedWebProvider()).open('https://example.test'), ); diff --git a/src/platform-runtime/request-providers.ts b/src/platform-runtime/request-providers.ts index 0bf12b800c..3cd5995da7 100644 --- a/src/platform-runtime/request-providers.ts +++ b/src/platform-runtime/request-providers.ts @@ -11,13 +11,11 @@ import type { import type { AppleRunnerCommandExecutor, AppleRunnerProvider } from '@agent-device/apple-runner'; import type { WebProvider } from '@agent-device/contracts/web-provider'; import type { - LinuxPlatformSelection, VegaPlatformSelection, WebPlatformSelection, } from '@agent-device/contracts/platform-plugin'; import type { VegaToolProvider } from '@agent-device/contracts/vega-tool-provider'; import type { AppleToolProvider } from '@agent-device/platform-apple/tool-provider'; -import type { LinuxToolProvider } from '@agent-device/contracts/linux-tool-provider'; import { webBackendKeyOf, type DeviceInfo } from '@agent-device/kernel/device'; import type { AppleSimulatorScreenRecordingTransport } from '../platform-runtime-screen-recording-apple-transport.ts'; import type { AppleRunnerScreenRecordingTransport } from '../platform-runtime-screen-recording-apple-runner-transport.ts'; @@ -38,8 +36,6 @@ export type AppleRunnerProviderResolver = PlatformProviderResolver< export type AppleToolProviderResolver = PlatformProviderResolver; -export type LinuxToolProviderResolver = PlatformProviderResolver; - export type VegaToolProviderResolver = PlatformProviderResolver; export type WebProviderResolver = PlatformProviderResolver; @@ -56,7 +52,6 @@ export type PlatformProviderResolvers = { androidAdbProvider?: AndroidAdbProviderResolver; appleRunnerProvider?: AppleRunnerProviderResolver; appleToolProvider?: AppleToolProviderResolver; - linuxToolProvider?: LinuxToolProviderResolver; vegaToolProvider?: VegaToolProviderResolver; webProvider?: WebProviderResolver; appleRunnerScreenRecordingTransport?: AppleRunnerScreenRecordingTransportResolver; @@ -67,7 +62,6 @@ export type RequestPlatformProviderOptions = Readonly<{ providers?: PlatformProviderResolvers; web?: WebPlatformSelection; vega?: VegaPlatformSelection; - linux?: LinuxPlatformSelection; }>; type ResolvedRequestPlatformProviders = { @@ -82,7 +76,6 @@ type ResolvedRequestPlatformProviders = { requestId?: string; }; appleTool?: { provider?: AppleToolProvider }; - linuxTool?: { provider?: LinuxToolProvider }; vegaTool?: { provider?: VegaToolProvider }; web?: { provider?: WebProvider }; appleSimulatorScreenRecording?: { provider?: AppleSimulatorScreenRecordingTransport }; @@ -95,7 +88,6 @@ type RequestPlatformProviderScopeWrapper = (task: () => Promise) => Promis type RequestPlatformSelections = Readonly<{ web?: WebPlatformSelection; vega?: VegaPlatformSelection; - linux?: LinuxPlatformSelection; }>; type RequestPlatformProviderDescriptor = { @@ -122,7 +114,7 @@ export function createComposedRequestPlatformProviders( ): RequestPlatformProviders { const providers = options.providers ?? {}; const hasConfiguredResolvers = hasPlatformProviderResolvers(providers); - const selections = { web: options.web, vega: options.vega, linux: options.linux }; + const selections = { web: options.web, vega: options.vega }; return Object.freeze({ hasConfiguredResolvers, run: async ( @@ -248,23 +240,6 @@ const REQUEST_PLATFORM_PROVIDER_DESCRIPTORS = [ appendRequestProviderWrapper(wrappers, scopedProviders.vegaTool, active.withRequestProvider); }, }, - { - resolverKey: 'linuxToolProvider', - resolve(providers, context, selections) { - // The selection gates before the resolver, as Vega's does: a request whose family this - // process does not serve has no scope to wrap the provider into, and a resolver may open a - // session or start a process per call with nothing to close what it returned. - if (!selections.linux?.active) return {}; - const resolver = providers.linuxToolProvider; - if (!resolver || context.device.platform !== 'linux') return {}; - return { linuxTool: { provider: resolver(context) } }; - }, - async appendWrapper(scopedProviders, wrappers, selections) { - const active = selections.linux?.active; - if (!scopedProviders.linuxTool?.provider || !active) return; - appendRequestProviderWrapper(wrappers, scopedProviders.linuxTool, active.withRequestProvider); - }, - }, { resolverKey: 'webProvider', resolve(providers, context) { diff --git a/test/integration/command-coverage/evidence.ts b/test/integration/command-coverage/evidence.ts index 756a91d6bb..2c41c21804 100644 --- a/test/integration/command-coverage/evidence.ts +++ b/test/integration/command-coverage/evidence.ts @@ -158,7 +158,7 @@ export const LINUX_COMMAND_EVIDENCE: RepositoryEvidence = { }; export const LINUX_PROVIDER_EVIDENCE: RepositoryEvidence = { path: 'test/integration/provider-scenarios/linux-desktop.test.ts', - test: 'Provider-backed integration Linux desktop flow uses semantic desktop and input providers', + test: 'Provider-backed integration Linux desktop flow drives the desktop tools through its host', }; export const LINUX_RUNTIME_EVIDENCE: RepositoryEvidence = { path: 'packages/platform-linux/src/runtime.test.ts', diff --git a/test/integration/provider-scenarios/harness.ts b/test/integration/provider-scenarios/harness.ts index ad60eec513..5aa25a87f6 100644 --- a/test/integration/provider-scenarios/harness.ts +++ b/test/integration/provider-scenarios/harness.ts @@ -1,6 +1,6 @@ import { webSelectionFixture } from '../../../src/platform-runtime-web-provider.fixtures.ts'; import { vegaSelectionFixture } from '../../../src/platform-runtime-vega-provider.fixtures.ts'; -import { linuxSelectionFixture } from '../../../src/platform-runtime-linux-provider.fixtures.ts'; +import { linuxSelectionFromPlatformHost } from '../../../src/platform-runtime-linux-provider.fixtures.ts'; import { macOsLeafSelectionFixture } from '../../../src/platform-runtime-macos-leaf.fixtures.ts'; import { bindPlatformLeaves, @@ -58,6 +58,7 @@ import { } from '@agent-device/device-selection/inventory-gateways-fixtures'; import type { PlatformRuntimeProviderRegistration } from '../../../src/platform-runtime-gateway.ts'; import { createProviderPlatformRuntimeRegistrations } from './provider-platform-registrations.ts'; +import type { PlatformHost } from '@agent-device/plugins/contract'; const PROVIDER_SCENARIO_TEMP_REMOVE_OPTIONS = { recursive: true, @@ -111,6 +112,12 @@ type ProviderScenarioDependencies = Partial>; + /** + * Host to set the Linux plugin up with, which serves the Linux family from it. The family answers + * every desktop intent through the host its `setup` receives, so this is the seam a Linux scenario + * has: the plugin's own inventory, runtime, interactor and tools run on the host named here. + */ + linuxPlatformHost?: PlatformHost; }; // The test the harness serves, so a scenario that needs the Swift cache can skip itself from inside a command. @@ -164,10 +171,10 @@ export async function createProviderScenarioHarness( appleRunnerProvider, appleRunnerScreenRecordingTransport, appleToolProvider, - linuxToolProvider, vegaToolProvider, webProvider, appleSimulatorScreenRecordingTransport, + linuxPlatformHost, ...dependencyOverrides } = deps; if (leaseTtlMs !== undefined) env.AGENT_DEVICE_LEASE_TTL_MS = String(leaseTtlMs); @@ -179,11 +186,11 @@ export async function createProviderScenarioHarness( const providerModules = platformRuntime?.providerModules ?? createProviderPlatformRuntimeRegistrations(configuredRuntimes); - // A scenario that resolves a Linux tool provider serves the Linux family through the installed - // plugin: the selection is what gives the family its runtime and interactor at all, and what - // lets a request scope a provider for it. - const linuxSelection = linuxToolProvider - ? linuxSelectionFixture(input.host, input.baseDir) + // A scenario that names a Linux host serves the Linux family through the installed plugin, set up + // with that host: the selection is what gives the family its runtime and interactor, and the host + // is what the family's desktop tools run through. + const linuxSelection = linuxPlatformHost + ? linuxSelectionFromPlatformHost(linuxPlatformHost) : undefined; const platforms = composePlatformPlugins( [ @@ -201,7 +208,7 @@ export async function createProviderScenarioHarness( [macOsLeafSelectionFixture(input.host, input.baseDir).get()], ); bindPlatformLeaves(platforms); - const { web, vega, linux } = platforms; + const { web, vega } = platforms; const defaultDeviceRuntimeGateway = createPlatformRuntimeGateway({ platforms, host: input.host, @@ -239,14 +246,12 @@ export async function createProviderScenarioHarness( appleRunnerProvider, appleRunnerScreenRecordingTransport, appleToolProvider: trackedAppleToolProvider, - linuxToolProvider, vegaToolProvider, webProvider, appleSimulatorScreenRecordingTransport, }, web, vega, - linux, }); return Object.freeze({ ...rootDeps, diff --git a/test/integration/provider-scenarios/linux-desktop.test.ts b/test/integration/provider-scenarios/linux-desktop.test.ts index 8328958abf..ea7143d96b 100644 --- a/test/integration/provider-scenarios/linux-desktop.test.ts +++ b/test/integration/provider-scenarios/linux-desktop.test.ts @@ -1,16 +1,23 @@ import assert from 'node:assert/strict'; import fs from 'node:fs'; import { test } from 'vitest'; -import { assertFlatToolCall, assertPngFile } from './assertions.ts'; +import { assertCommandCall, assertPngFile } from './assertions.ts'; import { PROVIDER_SCENARIO_LINUX } from './fixtures.ts'; import { createProviderScenarioTempPath, withProviderScenarioResource } from './harness.ts'; import { createLinuxDesktopWorld } from './linux-world.ts'; import { runProviderScenario } from './scenario.ts'; -test('Provider-backed integration Linux desktop flow uses semantic desktop and input providers', async () => { +/** + * The Linux desktop flow through the installed plugin, with a scripted desktop behind it. + * + * The scenario's evidence is what the family asked its host to run: each intent becomes the desktop + * tool argv the X11 session would see. Every step's response is asserted as before; the host record + * proves the request reached the desktop through the plugin's own route rather than a stand-in. + */ +test('Provider-backed integration Linux desktop flow drives the desktop tools through its host', async () => { await withProviderScenarioResource( createLinuxDesktopWorld, - async ({ daemon, desktopCalls, localLinuxDevices, semanticCalls, toolCalls }) => { + async ({ commands, daemon, launches, localLinuxDevices, probedPaths, toolCalls }) => { const screenshotPath = createProviderScenarioTempPath( 'agent-device-provider-scenario-linux', 'png', @@ -208,37 +215,88 @@ test('Provider-backed integration Linux desktop flow uses semantic desktop and i const close = await daemon.callCommand('close', ['gnome-calculator']); assert.equal(close.statusCode, 200, JSON.stringify(close.json)); - assert.deepEqual(desktopCalls, [ - ['open', 'gnome-calculator'], - ['close', 'gnome-calculator'], + + // The app the scenario opened and closed, as the desktop saw it: an app that outlives the + // request is launched detached, and a window is closed by name. + assert.deepEqual(launches, [['gnome-calculator']]); + assertCommandCall(toolCalls, ['wmctrl', '-c', 'gnome-calculator']); + + // Every capture reads the AT-SPI tree through the helper the package ships, for the surface + // the request named. The full argv carries the helper path and the traversal limits, so the + // surface is the part this scenario owns. + assert.deepEqual([...new Set(toolCalls.flatMap((call) => surfaceAsks(call)))].sort(), [ + 'frontmost-app', ]); - assertFlatToolCall(semanticCalls, ['accessibility', 'frontmost-app']); - assertFlatToolCall(semanticCalls, ['clipboard', 'write', 'linux otp 314159']); - assertFlatToolCall(semanticCalls, ['clipboard', 'read']); - assertFlatToolCall(semanticCalls, ['screenshot', screenshotPath, 'true', 'false', 'app']); - assertFlatToolCall(semanticCalls, ['input', 'click', '60', '100', 'primary']); - assertFlatToolCall(semanticCalls, ['input', 'click', '42', '84', 'primary']); - assertFlatToolCall(semanticCalls, ['input', 'click', '42', '84', 'secondary']); - assertFlatToolCall(semanticCalls, ['input', 'click', '42', '84', 'middle']); - assertFlatToolCall(semanticCalls, ['input', 'double-click', '42', '84']); - assertFlatToolCall(semanticCalls, ['input', 'long-press', '42', '84', '1']); - assertFlatToolCall(semanticCalls, ['input', 'drag', '10', '20', '30', '40', '16']); - assertFlatToolCall(semanticCalls, ['input', 'type', 'Seven', '1']); - assertFlatToolCall(semanticCalls, ['input', 'type', 'Eight', '1']); - assertFlatToolCall(semanticCalls, ['input', 'type', '5', '0']); - assertFlatToolCall(semanticCalls, ['input', 'key', 'ctrl+a']); - assertFlatToolCall(semanticCalls, ['input', 'key', 'alt+Left']); - assertFlatToolCall(semanticCalls, ['input', 'key', 'super+d']); - assertFlatToolCall(semanticCalls, ['input', 'scroll', 'down', '', '45']); - assertFlatToolCall(semanticCalls, ['input', 'scroll', 'up', '', '']); - assert.deepEqual( - toolCalls, - [], - 'Expected Linux Provider-backed integration input to stay semantic', + + // The helper is located through the host's own presence check before it runs, and the path + // that check settles on is the one the capture executes. + const helper = probedPaths.find((probed) => probed.endsWith('atspi-dump.py')); + assert.ok(helper, JSON.stringify(probedPaths)); + assert.ok( + toolCalls.some((call) => call[0] === 'python3' && call[1] === helper), + JSON.stringify(toolCalls.filter((call) => call[0] === 'python3')), + ); + + // The clipboard round-trips through the X11 selection tool: text in on stdin, read back. + const clipboardWrite = commands.find( + (call) => call.command === 'xclip' && call.stdin !== undefined, ); + assert.deepEqual(clipboardWrite?.args, ['-selection', 'clipboard']); + assert.equal(clipboardWrite?.stdin, 'linux otp 314159'); + assertCommandCall(toolCalls, ['xclip', '-selection', 'clipboard', '-o']); + + // Input synthesis is xdotool on this X11 session. The pointer is moved before every click + // because the scripted desktop never reports it as already being there. + assertCommandCall(toolCalls, ['xdotool', 'mousemove', '--sync', '60', '100']); + assertCommandCall(toolCalls, ['xdotool', 'mousemove', '--sync', '42', '84']); + assertCommandCall(toolCalls, ['xdotool', 'click', '1']); + assertCommandCall(toolCalls, ['xdotool', 'click', '3']); + assertCommandCall(toolCalls, ['xdotool', 'click', '2']); + assertCommandCall(toolCalls, ['xdotool', 'click', '--repeat', '2', '1']); + assertCommandCall(toolCalls, ['xdotool', 'mousedown', '1']); + assertCommandCall(toolCalls, ['xdotool', 'mouseup', '1']); + assertCommandCall(toolCalls, ['xdotool', 'mousemove', '--sync', '30', '40']); + // `fill` focuses the field, selects the old value, then types the replacement at the + // requested delay. Both fills use their own text; the ref fill moves to the ref's centre. + assertCommandCall(toolCalls, ['xdotool', 'key', '--clearmodifiers', 'ctrl+a']); + assertCommandCall(toolCalls, [ + 'xdotool', + 'type', + '--delay', + '1', + '--clearmodifiers', + '--', + 'Seven', + ]); + assertCommandCall(toolCalls, [ + 'xdotool', + 'type', + '--delay', + '1', + '--clearmodifiers', + '--', + 'Eight', + ]); + assertCommandCall(toolCalls, ['xdotool', 'type', '--clearmodifiers', '--', '5']); + // `--pixels 45` is three ~15px wheel clicks, dispatched as one paced batch; the plain scroll + // keeps the default five. + assertCommandCall(toolCalls, ['xdotool', 'click', '--repeat', '3', '5']); + assertCommandCall(toolCalls, ['xdotool', 'click', '--repeat', '5', '4']); + // The system buttons are their key combinations. + assertCommandCall(toolCalls, ['xdotool', 'key', '--clearmodifiers', 'alt+Left']); + assertCommandCall(toolCalls, ['xdotool', 'key', '--clearmodifiers', 'super+d']); + // The capture tool writes the destination the request named; the PNG check above is what + // proves the artifact, since the tool's own argv carries no full-screen or stabilization flag. + assertCommandCall(toolCalls, ['scrot', screenshotPath]); } finally { fs.rmSync(screenshotPath, { force: true }); } }, ); }); + +/** The `--surface` values one host command names, which only the AT-SPI helper call carries. */ +function surfaceAsks(call: readonly string[]): readonly string[] { + const surfaceAt = call.indexOf('--surface'); + return surfaceAt >= 0 && call[surfaceAt + 1] !== undefined ? [call[surfaceAt + 1]!] : []; +} diff --git a/test/integration/provider-scenarios/linux-host.fixtures.ts b/test/integration/provider-scenarios/linux-host.fixtures.ts new file mode 100644 index 0000000000..3b0c5bfb3e --- /dev/null +++ b/test/integration/provider-scenarios/linux-host.fixtures.ts @@ -0,0 +1,116 @@ +import fs from 'node:fs'; +import os from 'node:os'; +import path from 'node:path'; +import type { PlatformHost } from '@agent-device/plugins/contract'; +import { createPlatformPluginHost } from '../../../src/platform-runtime/plugin-host.ts'; + +/** One command the scripted desktop was asked to run, with everything the family asked for. */ +export type LinuxScenarioCommand = Readonly<{ + command: string; + args: readonly string[]; + stdin?: string; + allowFailure: boolean; +}>; + +/** What the scripted desktop answers one command with. */ +export type LinuxScenarioAnswer = Readonly<{ + stdout?: string; + stderr?: string; + exitCode?: number; +}>; + +/** + * The `PlatformHost` the Linux plugin is set up with, plus the record of what it was asked for. + * + * The Linux family answers every desktop intent through the host its `setup` received, so this is the + * only seam a Provider-backed integration scenario has for the family: the scenario installs it with + * the plugin's own `setup`, and the real inventory, runtime, interactor and tool plumbing run on it. + * Nothing here stands in for a family operation — it answers the four ports the family asks of a + * machine (command route, `PATH` probe, file probe, detached launch) and takes the rest from the + * core's own plugin host. + */ +export type LinuxScenarioHost = Readonly<{ + /** Pass to the Linux plugin's `setup`. */ + host: PlatformHost; + /** Every `runCommand` so far, with its argv and stdin, in order. */ + commands: LinuxScenarioCommand[]; + /** Every `runCommand` so far, as `[executable, ...argv]`, in order. */ + toolCalls: Array<[string, ...string[]]>; + /** Every detached launch so far, as `[executable, ...argv]`, in order. */ + launches: Array<[string, ...string[]]>; + /** Every path the family probed with `isFilePresent`, in order. */ + probedPaths: string[]; + /** The scratch directory this host names as its state dir; released by `dispose`. */ + stateDir: string; + dispose: () => Promise; +}>; + +export type LinuxScenarioHostOptions = Readonly<{ + /** Executables the `PATH` probe answers present for. */ + tools?: readonly string[]; + /** Environment the family reads its display decision from. */ + env?: Readonly>; + /** Answers one command; a command with no answer succeeds with empty streams. */ + respond?: (command: LinuxScenarioCommand) => LinuxScenarioAnswer; +}>; + +export function createLinuxScenarioHost(options: LinuxScenarioHostOptions = {}): LinuxScenarioHost { + const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-device-provider-scenario-linux-')); + const tools = new Set(options.tools ?? []); + const commands: LinuxScenarioCommand[] = []; + const toolCalls: Array<[string, ...string[]]> = []; + const launches: Array<[string, ...string[]]> = []; + const probedPaths: string[] = []; + const base = createPlatformPluginHost( + { env: { PATH: process.env.PATH, ...(options.env ?? {}) }, cwd: process.cwd() }, + stateDir, + ); + + const host: PlatformHost = Object.freeze({ + ...base, + // The scenario runs on a developer's macOS or Linux runner and still drives the Linux family, so + // the host names the machine the family is asked to drive. + hostOs: 'linux', + runCommand: async (command, args, commandOptions) => { + const entry: LinuxScenarioCommand = Object.freeze({ + command, + args: Object.freeze([...args]), + ...(commandOptions?.stdin === undefined ? {} : { stdin: commandOptions.stdin }), + allowFailure: commandOptions?.allowFailure === true, + }); + commands.push(entry); + toolCalls.push([command, ...args]); + const answer = options.respond?.(entry) ?? {}; + return { + stdout: answer.stdout ?? '', + stderr: answer.stderr ?? '', + exitCode: answer.exitCode ?? 0, + }; + }, + // The desktop's tool list stands in for the host's `PATH`, so a scenario names which desktop + // tools exist instead of writing executables. + isExecutableOnPath: async (executable) => tools.has(path.basename(executable)), + // The one shipped resource the family probes for is its AT-SPI helper; a scenario's host always + // carries it, which is what the family assumes of a correctly installed package. + isFilePresent: async (probed) => { + probedPaths.push(probed); + return true; + }, + launchDetached: async (command, args) => { + launches.push([command, ...args]); + return { pid: 4242, exited: Promise.resolve({ pid: 4242, exitCode: 0 }) }; + }, + }); + + return { + host, + commands, + toolCalls, + launches, + probedPaths, + stateDir, + dispose: async () => { + await fs.promises.rm(stateDir, { recursive: true, force: true }); + }, + }; +} diff --git a/test/integration/provider-scenarios/linux-world.ts b/test/integration/provider-scenarios/linux-world.ts index 0e3eabb071..4af713b1b2 100644 --- a/test/integration/provider-scenarios/linux-world.ts +++ b/test/integration/provider-scenarios/linux-world.ts @@ -4,7 +4,6 @@ import type { PlatformRequestScope } from '@agent-device/contracts/platform-runt import { createDeviceInventoryHost } from '../../../src/platform-runtime-host.ts'; import { linuxSelectionFixture } from '../../../src/platform-runtime-linux-provider.fixtures.ts'; import type { DeviceInfo } from '@agent-device/kernel/device'; -import type { LinuxToolProvider } from '@agent-device/contracts/linux-tool-provider'; import { validPng } from './assertions.ts'; import { PROVIDER_SCENARIO_LINUX } from './fixtures.ts'; import { @@ -12,29 +11,42 @@ import { restoreEnv, type ProviderScenarioHarness, } from './harness.ts'; -import type { FlatToolCall } from './providers.ts'; +import { + createLinuxScenarioHost, + type LinuxScenarioAnswer, + type LinuxScenarioCommand, + type LinuxScenarioHost, +} from './linux-host.fixtures.ts'; + +/** The desktop tools the scripted X11 session has installed. */ +const SCRIPTED_X11_TOOLS = ['xdotool', 'wmctrl', 'gnome-calculator', 'xclip', 'scrot', 'python3']; export type LinuxDesktopWorld = { daemon: ProviderScenarioHarness; localLinuxDevices: DeviceInfo[]; - toolCalls: Array<[string, string[]]>; - desktopCalls: Array<[string, string]>; - semanticCalls: FlatToolCall[]; + /** Every host command the family ran, with its argv and stdin. */ + commands: LinuxScenarioHost['commands']; + /** Every host command the family ran, as `[executable, ...argv]`. */ + toolCalls: Array<[string, ...string[]]>; + /** Every detached launch the family asked the host for, as `[executable, ...argv]`. */ + launches: Array<[string, ...string[]]>; + /** Every path the family asked the host to check before using it. */ + probedPaths: string[]; close: () => Promise; }; /** * The Linux family served by the installed plugin, with one scripted desktop in front of it. * - * The scenario hands the daemon a Linux tool provider, so every request runs against the provider it - * scoped rather than against a desktop. The provider is the contract's vocabulary, so this file names - * no Linux implementation: the plugin resolves it through its own selection, which is what registers - * the family's runtime and interactor here. + * The family runs every desktop intent through the `PlatformHost` its plugin was set up with, so the + * scenario scripts that host: which desktop tools exist, what each command answers, and what the + * session's clipboard holds. The real inventory, runtime, interactor and tool selection answer for + * the request, so the scenario proves the family's own route to the desktop, and its recorded argv is + * the evidence. */ export async function createLinuxDesktopWorld(): Promise { - const previousSessionType = process.env.XDG_SESSION_TYPE; - const previousWaylandDisplay = process.env.WAYLAND_DISPLAY; const previousAuthHook = process.env.AGENT_DEVICE_HTTP_AUTH_HOOK; + delete process.env.AGENT_DEVICE_HTTP_AUTH_HOOK; const previousPlatform = process.platform; // The plugin's inventory reports the local desktop only for a Linux host, so the scenario proves @@ -42,113 +54,18 @@ export async function createLinuxDesktopWorld(): Promise { Object.defineProperty(process, 'platform', { value: 'darwin', configurable: true }); assert.deepEqual(await discoverLocalLinuxInventory(), []); Object.defineProperty(process, 'platform', { value: 'linux', configurable: true }); - process.env.XDG_SESSION_TYPE = 'x11'; - delete process.env.WAYLAND_DISPLAY; - delete process.env.AGENT_DEVICE_HTTP_AUTH_HOOK; - const localLinuxDevices = await discoverLocalLinuxInventory(); - const toolCalls: Array<[string, string[]]> = []; - const desktopCalls: Array<[string, string]> = []; - const semanticCalls: FlatToolCall[] = []; - let clipboardText = ''; - const linuxToolProvider: LinuxToolProvider = { - // The display decision the scripted desktop stands for; the family selects its tools by it. - display: { detectDisplayServer: () => 'x11' }, - runCommand: async (cmd, args) => { - toolCalls.push([cmd, [...args]]); - return { stdout: '', stderr: '', exitCode: 0 }; - }, - whichCommand: async (cmd) => - cmd === 'gnome-calculator' || cmd === 'xdotool' || cmd === 'wmctrl', - // The scripted desktop owns app launches, so the detached launcher is never reached. - launchDetached: (cmd) => { - throw new Error(`the Linux world launches apps through its desktop: ${cmd}`); - }, - // Interaction pacing belongs to the scripted desktop too: the scenario asserts the intent, not - // the wall clock. - sleep: async () => {}, - desktop: { - openTarget: async (target) => { - desktopCalls.push(['open', target]); - }, - closeApp: async (app) => { - desktopCalls.push(['close', app]); - }, - }, - accessibility: { - captureTree: async (surface) => { - semanticCalls.push(['accessibility', surface]); - return { - nodes: linuxCalculatorSnapshotNodes(), - truncated: false, - surface, - }; - }, - }, - clipboard: { - readText: async () => { - semanticCalls.push(['clipboard', 'read']); - return clipboardText; - }, - writeText: async (text) => { - semanticCalls.push(['clipboard', 'write', text]); - clipboardText = text; - }, - }, - screenshot: { - capture: async (outPath, options) => { - semanticCalls.push([ - 'screenshot', - outPath, - String(options?.fullscreen ?? ''), - String(options?.stabilize ?? ''), - String(options?.surface ?? ''), - ]); - fs.writeFileSync(outPath, validPng()); - }, - }, - input: { - click: async (x, y, button) => { - semanticCalls.push(['input', 'click', String(x), String(y), button]); - }, - doubleClick: async (x, y) => { - semanticCalls.push(['input', 'double-click', String(x), String(y)]); - }, - longPress: async (x, y, durationMs) => { - semanticCalls.push(['input', 'long-press', String(x), String(y), String(durationMs)]); - }, - drag: async (x1, y1, x2, y2, durationMs) => { - semanticCalls.push([ - 'input', - 'drag', - String(x1), - String(y1), - String(x2), - String(y2), - String(durationMs), - ]); - }, - scroll: async (direction, options) => { - semanticCalls.push([ - 'input', - 'scroll', - direction, - String(options?.amount ?? ''), - String(options?.pixels ?? ''), - ]); - }, - typeText: async (text, options) => { - semanticCalls.push(['input', 'type', text, String(options?.delayMs ?? 0)]); - }, - key: async (combo) => { - semanticCalls.push(['input', 'key', combo]); - }, - }, - }; + // The desktop's own state: the text its selection holds, which the clipboard tools read back. + const desktop = { clipboard: '' }; + const host = createLinuxScenarioHost({ + tools: SCRIPTED_X11_TOOLS, + env: { PATH: '/usr/bin', XDG_SESSION_TYPE: 'x11' }, + respond: (command) => answerScriptedDesktop(command, desktop), + }); const daemon = await createProviderScenarioHarness({ - linuxToolProvider: () => linuxToolProvider, + linuxPlatformHost: host.host, deviceInventoryProvider: async () => [PROVIDER_SCENARIO_LINUX], }); @@ -156,21 +73,102 @@ export async function createLinuxDesktopWorld(): Promise { return { daemon, localLinuxDevices, - toolCalls, - desktopCalls, - semanticCalls, + commands: host.commands, + toolCalls: host.toolCalls, + launches: host.launches, + probedPaths: host.probedPaths, close: async () => { if (closed) return; closed = true; await daemon.close(); + await host.dispose(); Object.defineProperty(process, 'platform', { value: previousPlatform, configurable: true }); - restoreEnv('XDG_SESSION_TYPE', previousSessionType); - restoreEnv('WAYLAND_DISPLAY', previousWaylandDisplay); restoreEnv('AGENT_DEVICE_HTTP_AUTH_HOOK', previousAuthHook); }, }; } +/** + * Answers one command as the scripted X11 desktop would: the AT-SPI helper prints the calculator's + * tree, the clipboard tools read and write the session selection, and the capture tool writes a PNG. + * Every other command is a synthesized input event or a window action, which succeed silently. + */ +function answerScriptedDesktop( + command: LinuxScenarioCommand, + desktop: { clipboard: string }, +): LinuxScenarioAnswer { + switch (command.command) { + case 'python3': + return { stdout: scriptedAtspiTree(command.args), exitCode: 0 }; + case 'xclip': + // The tool's own selection model: `-o` reads it, and text on stdin replaces it. + if (command.args.includes('-o')) return { stdout: desktop.clipboard, exitCode: 0 }; + desktop.clipboard = command.stdin ?? ''; + return { stdout: '', exitCode: 0 }; + case 'scrot': + fs.writeFileSync(scriptedCapturePath(command), scriptedPng()); + return { stdout: '', exitCode: 0 }; + default: + return { stdout: '', exitCode: 0 }; + } +} + +/** The capture tool's output path: its last non-flag argument. */ +function scriptedCapturePath(command: LinuxScenarioCommand): string { + const destination = [...command.args].reverse().find((arg) => !arg.startsWith('-')); + assert.ok(destination, 'the scripted capture tool was called without a destination'); + return destination; +} + +/** A capture the request can publish: the same image every other scenario's fake desktop writes. */ +function scriptedPng(): Buffer { + return validPng(); +} + +/** + * The calculator window the AT-SPI helper reports: its frame and two buttons, in the helper's own + * vocabulary. `--surface` tells the helper — and therefore the scenario — which surface was asked for. + */ +function scriptedAtspiTree(args: readonly string[]): string { + const surfaceAt = args.indexOf('--surface'); + const surface = surfaceAt >= 0 ? args[surfaceAt + 1] : undefined; + return JSON.stringify({ + nodes: [ + { + index: 0, + role: 'frame', + label: 'Calculator', + rect: { x: 0, y: 0, width: 320, height: 480 }, + enabled: true, + hittable: true, + depth: 0, + }, + { + index: 1, + role: 'push button', + label: '5', + rect: { x: 40, y: 80, width: 40, height: 40 }, + enabled: true, + hittable: true, + depth: 1, + parentIndex: 0, + }, + { + index: 2, + role: 'push button', + label: 'Clear', + rect: { x: 90, y: 80, width: 70, height: 40 }, + enabled: true, + hittable: true, + depth: 1, + parentIndex: 0, + }, + ], + truncated: false, + surface, + }); +} + const inventoryScope: PlatformRequestScope = Object.freeze({ signal: new AbortController().signal, diagnostics: Object.freeze({ emit: () => {} }), @@ -185,46 +183,3 @@ async function discoverLocalLinuxInventory(): Promise { ); return [...(await source.discover({ platform: 'linux' }, inventoryScope))]; } - -function linuxCalculatorSnapshotNodes(): Array<{ - index: number; - role: string; - label: string; - rect: { x: number; y: number; width: number; height: number }; - enabled: boolean; - hittable: boolean; - depth: number; - parentIndex?: number; -}> { - return [ - { - index: 0, - role: 'frame', - label: 'Calculator', - rect: { x: 0, y: 0, width: 320, height: 480 }, - enabled: true, - hittable: true, - depth: 0, - }, - { - index: 1, - role: 'push button', - label: '5', - rect: { x: 40, y: 80, width: 40, height: 40 }, - enabled: true, - hittable: true, - depth: 1, - parentIndex: 0, - }, - { - index: 2, - role: 'push button', - label: 'Clear', - rect: { x: 90, y: 80, width: 70, height: 40 }, - enabled: true, - hittable: true, - depth: 1, - parentIndex: 0, - }, - ]; -}