Workspace App Tool API
When to use each app-tool method in repository tasks and triggers, and how live app results and actions differ.
app exposes tools registered by the connected app SDK. In a task, await app.<suite>.<method>(args) executes a tool and returns an AppToolCallResult. In a trigger, the same call shape builds an action; return exactly one action from the trigger function without awaiting it. The host pins both to the matched session and the app applies its normal tool guard and grants.
The arguments for most suites are app-tool JSON objects. Consult the connected app’s tool catalog for the exact schema, limits, and availability; the TypeScript method name alone cannot guarantee that the app registered that tool. app.available in tasks tells you whether an SDK provider exists. For a required tool, declare its ID in requires.appTools so an unavailable app fails before task or trigger execution.
// In a task: execute, inspect the envelope, then make a named assertion.
const response = await app.data.listDatabases({});
if (response.responseType === "tool.error") {
throw new Error(`${response.payload.code}: ${response.payload.message}`);
}
expect(response.payload.success, { id: "databases-readable" }).toBe(true);
The tables below describe what to use each method for. Read methods normally require a Read tool policy; mutations need Write or Critical as declared by the app. Use the live tool catalog to check a particular installation.
Platform and framework support
All app.* calls in tasks require SDK execution mode. They can run on
virtual or physical devices when the selected SDK/platform supplies the tool.
app.available confirms the provider connection, not registration or permission
for every suite. Declare exact IDs in requires.appTools when a tool is essential.
| Suite | Platform | Framework/provider requirement | Device kinds |
|---|---|---|---|
app.artifacts, ui, files, preferences, clipboard, secureStorage, data | iOS or Android implementations | Corresponding suite/provider registered and permitted in the app | Virtual or physical |
app.fileDescriptors | Native iOS or Android | Native SDKs and wrapper native bridges; unavailable in the .NET SDK | Virtual or physical |
app.jniReferences | Android only | Registered JNI-reference diagnostic tool | Virtual or physical |
app.reflection | iOS or Android implementation | Registered reflection roots; native bridge semantics apply to wrapper SDKs | Virtual or physical |
app.maui | iOS or Android | .NET MAUI adapter (dotnet-maui); plain .NET iOS/Android is not MAUI | Virtual or physical |
app.react | iOS or Android | React Native adapter (react-native) | Virtual or physical |
app.flutter | iOS or Android | Flutter adapter (flutter) | Virtual or physical |
app.capacitor | iOS or Android | Capacitor DOM adapter (capacitor) | Virtual or physical |
app.callTool | Tool-specific | Exact custom tool ID, argument schema, grants, and runtime guard | Tool-specific |
These are compatibility boundaries, not a promise that every SDK build enables
every tool. Check ansight.appTools.list() for executable IDs and schemas and
the SDK feature matrix for package coverage.
In device mode, use the host’s UI APIs or supported external file APIs. Framework internals, app preference stores, reflection roots, and custom tools need their SDK provider even if the host can capture the visible screen.
Artifacts and general UI
| Method | Use |
|---|---|
app.artifacts.query(args?) | Discover app-defined artifacts and provider IDs before requesting one. |
app.artifacts.request(args) | Ask a provider to create a particular artifact at the current session point; supply its providerId and artifactId. |
app.ui.getVisualTree(args?) | Read the SDK’s current native visual hierarchy when you need app-owned UI structure. |
app.ui.getScreenshot(args?) | Capture a current frame through the app SDK. For host-owned capture or retained frames, use ansight.screenshots. |
app.ui.inspectNode(args?) | Inspect one node after finding its ID in a visual tree. |
app.ui.showOverlay(args?) | Add a diagnostic overlay to highlight an app location or state. |
app.ui.getOverlay(args?) | Inspect one known overlay and its current settings. |
app.ui.queryOverlays(args?) | Find overlays before updating or removing them. |
app.ui.updateOverlay(args?) | Change an existing overlay rather than creating another. |
app.ui.removeOverlay(args?) | Remove one overlay when its diagnostic use is finished. |
app.ui.clearOverlays(args?) | Remove all app diagnostic overlays for a clean view. |
Files and runtime resources
app.files operates through the SDK inside the app sandbox. The host’s external ansight.files API has different capabilities and works without an SDK provider on supported sessions.
| Method | Use |
|---|---|
app.files.listDirectory(args?) | Discover sandbox entries before choosing a path. |
app.files.readFile(args?) | Read a small file through the app’s guarded file tool. |
app.files.getChecksum(args?) | Compare file content by hash without retrieving the full file. |
app.files.download(args?) | Request a file through the app tool’s normal download response. |
app.files.beginBinaryDownload(args?) | Start a binary transfer to the host; use for files that should be retained as session artifacts. |
app.files.push(args?) | Write supplied content into an allowed app sandbox location. |
app.files.copy(args?) | Duplicate an allowed sandbox file while keeping the original. |
app.files.move(args?) | Relocate or rename an allowed sandbox file. |
app.files.delete(args?) | Remove an allowed sandbox file after confirming the target. |
app.fileDescriptors.listOpen(args?) | List open descriptors when investigating leaks. |
app.fileDescriptors.countOpen(args?) | Get a lightweight open-descriptor count for comparison across steps. |
app.fileDescriptors.inspect(args?) | Examine one descriptor or related diagnostic value. |
app.fileDescriptors.getUsage(args?) | Read descriptor usage and limits to judge whether a count is concerning. |
app.jniReferences.captureGraph(args?) | Capture an Android JNI reference graph for leak diagnosis. |
App stores and reflection
| Method | Use |
|---|---|
app.preferences.listKeys(args?) | Discover keys in an app preferences store. |
app.preferences.get(args?) | Read selected preference values. |
app.preferences.set(args?) | Set a selected preference for a controlled test. |
app.preferences.remove(args?) | Remove a selected preference to test default behavior. |
app.clipboard.getText() | Read plain text from the native system clipboard; iOS may show a paste prompt. |
app.clipboard.hasText() | Check whether plain text is present without reading it. |
app.clipboard.setText({ text }) | Replace clipboard contents with test text. |
app.clipboard.clear() | Clear clipboard contents during cleanup. |
app.secureStorage.get(args?) | Inspect a selected secure-storage value when the app registers and permits this suite. |
app.secureStorage.set(args?) | Write a controlled secure-storage value for a test. |
app.secureStorage.remove(args?) | Remove a selected secure-storage value. |
app.data.listDatabases(args?) | Discover databases exposed by the app SDK. |
app.data.describeSchema(args?) | Inspect tables and columns before writing a read-only query. |
app.data.query(args?) | Run the app’s guarded database query to inspect domain state. |
app.reflection.listRoots(args?) | Discover roots that the app deliberately exposes for reflection. |
app.reflection.inspectObject(args?) | Read members of a selected exposed object. |
app.reflection.describeType(args?) | Inspect type members and signatures before invoking or setting one. |
app.reflection.setMemberValue(args?) | Change a member in a controlled development workflow. |
app.reflection.invokeMethod(args?) | Call an exposed method when a narrow app-specific tool is unavailable. |
Clipboard text is limited to 65,536 UTF-8 bytes. See Clipboard Tools. Secure storage and reflection can expose sensitive state; use the app’s guard and a narrowly selected target.
Framework inspection
These suites exist only when the matching framework adapter is registered in the app. Their argument shapes are defined by the app tools for that SDK version.
| Method | Use |
|---|---|
app.maui.getCurrentPage(args?) | Identify the active .NET MAUI page before inspecting its elements. |
app.maui.getVisualTree(args?) | Read the current MAUI element hierarchy. |
app.maui.findElements(args?) | Search MAUI elements by supported selectors. |
app.maui.getElement(args?) | Inspect a known MAUI element in detail. |
app.maui.getBindableProperty(args?) | Read one bindable property’s effective value. |
app.maui.setBindableProperty(args?) | Set a bindable property for a controlled UI test. |
app.maui.clearBindableProperty(args?) | Clear a local bindable value so its normal source applies. |
app.maui.inflateXaml(args?) | Create an element from supplied XAML for development diagnosis. |
app.maui.addElement(args?) | Insert an element into a selected MAUI container. |
app.maui.removeElement(args?) | Remove a selected inserted element. |
app.maui.setAppTheme(args?) | Switch app theme to reproduce a theme-specific issue. |
app.maui.getBindingContext(args?) | Inspect the view model bound to a selected element. |
app.maui.getBindings(args?) | Inspect binding expressions and sources for a selected element. |
app.maui.getResourceState(args?) | Inspect resolved resources and styles. |
app.maui.getNavigationState(args?) | Read the MAUI navigation stack or shell state. |
app.maui.invokeElementAction(args?) | Invoke an action on a selected MAUI element. |
app.maui.waitForUi(args?) | Poll MAUI UI state for a framework-specific condition. |
app.maui.getLayoutDiagnostics(args?) | Inspect layout measurements when a view is misplaced. |
app.maui.getHandlerDiagnostics(args?) | Inspect the native handler backing a MAUI view. |
app.maui.invokeBindingContextCommand(args?) | Invoke an exposed view-model command. |
app.maui.setBindingContextProperty(args?) | Change an exposed view-model property for a controlled test. |
app.react.getComponentTree(args?) | Read the React component hierarchy. |
app.react.getShadowTree(args?) | Read React Native’s layout/shadow hierarchy when geometry matters. |
app.react.findComponents(args?) | Search components before inspecting one. |
app.react.getComponent(args?) | Inspect a selected component and its exposed properties. |
app.react.getNavigationState(args?) | Read React Navigation state when a screen breadcrumb is insufficient. |
app.react.invokeComponentAction(args?) | Invoke an exposed React component action. |
app.flutter.getWidgetTree(args?) | Read the Flutter widget hierarchy. |
app.flutter.inspectWidget(args?) | Inspect a selected widget’s details. |
app.flutter.findWidgets(args?) | Search widgets before inspecting one. |
app.flutter.getNavigationState(args?) | Read Flutter route or navigation state. |
app.capacitor.getDocument(args?) | Read the current WebView DOM document. |
app.capacitor.inspectNode(args?) | Inspect a selected DOM node. |
app.capacitor.querySelector(args?) | Find DOM nodes with the adapter’s selector support. |
app.capacitor.invokeAction(args?) | Perform an allowed action on a selected DOM control. |
Custom tools and result handling
| Method | Use |
|---|---|
app.callTool<TResult>(toolId, args?) | Execute an exact registered tool without a typed wrapper, including custom app tools. |
app.callTool<TResult>(toolId, args?) calls a registered tool that is not exposed by a typed suite. This includes custom app tools and SDK tools such as purchases.get_state. Discover the exact ID, schema, policy, and availability with ansight.appTools.list() in a task or the CLI’s tool catalog. Pass a type parameter only for the expected inner payload.result; the outer response is still an envelope that can report tool.error.
In a trigger, return app.callTool("app.capture_state", { reason: event.kind }) constructs one action. Do not await it or read a result inside the trigger function. The action runs later under the event’s session and correlation identity. See the Trigger API for timeout and retry behavior.
AppToolCallResult<TResult>
App results use a discriminated envelope:
type AppToolCallResult<TResult> =
| {
responseType: "tool.result";
sessionId: string;
appId: string;
toolId: string;
payload: {
success: true;
toolId: string;
result: TResult;
message?: string | null;
};
}
| {
responseType: "tool.error";
sessionId: string;
appId: string;
toolId: string;
payload: {
success?: false;
code: string;
message: string;
retryable: boolean;
details?: JsonValue | null;
};
};
The full envelope can also contain host-applied defaults, associated
artifacts, and persisted-visual-tree metadata. Narrow on responseType before
reading the typed success result.