Inspect and test your app's clipboard

Check copied text and prepare clipboard contents on the connected app device when testing copy and paste behavior.

Verify what your app copied or provide text for a paste workflow without leaving the investigation. Clipboard tools let people and agents read, check, set, and clear text through guarded remote tools.

They operate on the connected app device’s system clipboard through the Ansight remote-tool transport. They do not access the developer workstation clipboard and do not depend on simctl, ADB, or an emulator service.

Tool Contract

Tool IDArgumentsSuccessful resultPolicy
clipboard.get_text{}{ "text": string or null, "hasText": boolean }Read
clipboard.has_text{}{ "hasText": boolean }Read
clipboard.set_text{ "text": string }{ "updated": true }Write
clipboard.clear{}{ "cleared": true }Write

Text is preserved exactly, including whitespace, Unicode, and empty strings. Reads and writes reject values larger than 65,536 UTF-8 bytes with clipboard_text_too_large; content is never truncated. An empty string is text and is distinct from clearing every clipboard item. Rich content, images, and URI coercion are outside this API.

Registration

The all-in-one SDK remote-tool suites include Clipboard. Existing tool guards still apply: read-only access can inspect the clipboard but cannot set or clear it.

SDKStandalone registrationAll-in-one behavior
.NET / MAUIAdd Ansight.Tools.Clipboard, then call WithClipboardTools()Included by WithAnsightSdk() and WithAnsightMaui()
AndroidAdd ai.ansight:ansight-tools-clipboard-android, then call withClipboardTools()Included by ai.ansight:ansight-android
iOS / SwiftAdd AnsightToolsClipboard, then call registerClipboardTools()Included by Ansight; omit with AnsightRemoteToolOptions(clipboard: false)
React NativeNative bridge registration; use withClipboardTools(false) to omitIncluded by native remote tools
FlutterConfigure AnsightRemoteToolsOptions(clipboard: false) to omitIncluded by native remote tools
Cordova / CapacitorSet remoteTools: { clipboard: false } to omitIncluded by native remote tools

.NET

dotnet add package Ansight.Tools.Clipboard
using Ansight.Tools.Clipboard;

var options = Options.CreateBuilder()
    .WithClipboardTools()
    .WithReadWriteToolAccess()
    .Build();

Android

dependencies {
    debugImplementation("ai.ansight:ansight-tools-clipboard-android:latest.release")
}
val options = AnsightOptions.createBuilder()
    .withClipboardTools()
    .withReadWriteToolAccess()
    .build()

iOS

import AnsightCore
import AnsightToolsClipboard

try AnsightRuntime.shared.registerClipboardTools()

Install the latest AnsightToolsClipboard release through SwiftPM or CocoaPods.

Calling from the CLI

Start by reading text from a connected app’s clipboard:

ansight app call <session-id> clipboard.get_text --arguments-json '{}'

To set or clear text, use the write tools. They depend on the app’s configured tool guard. Add --json when a script needs structured output:

ansight app call <session-id> clipboard.set_text \
  --arguments-json '{"text":"Hello from Ansight"}' --json
ansight app call <session-id> clipboard.clear --arguments-json '{}' --json

Tasks and Triggers

Workspace tasks expose the suite as app.clipboard:

await app.clipboard.setText({ text: "  Hello 世界\n" });
const response = await app.clipboard.getText();

if (response.responseType === "tool.result") {
  expect(response.payload.result.text, { id: "clipboard.text" })
    .toBe("  Hello 世界\n");
}

await app.clipboard.clear();

Task methods return the normal AppToolCallResult<T> envelope. Trigger methods construct a declarative AppToolAction. The host and app SDK must both contain Clipboard support; updating the host does not add the tools to an older app.

Platform Behavior

  • Android uses ClipboardManager. The app window must have input focus. True clearing requires Android API 28 or later.
  • iOS and Mac Catalyst use UIPasteboard on the main thread. The app must be active, and a read can invoke the operating system’s paste-permission flow.
  • Native macOS Swift uses NSPasteboard on the main thread.
  • Generic .NET can compile against the package but returns clipboard_platform_unsupported at runtime.

Clipboard operations are explicit: the SDK does not monitor, synchronize, or retain clipboard history. Host diagnostics redact text read or written by these tools, but task authors should still avoid persisting sensitive values in assertions or task output.