Artifacts
Register JavaScript-backed artifact providers so paired hosts can discover and request React Native diagnostic exports such as network traces, map state, runtime snapshots, and support bundles.
React Native artifact providers are registered from JavaScript and served through artifacts.query and artifacts.request. Use artifacts when the output should become a named file, JSON snapshot, ZIP, or binary/text payload that Studio and agents can keep with the session.
Artifacts are for app-owned ground truth. Screenshots show what rendered, logs show what the app said, and touches show what the user did. Artifacts explain what the JavaScript and native layers knew internally at the same moment.
Good artifact candidates include:
| Artifact | Useful contents | Why use an artifact |
|---|---|---|
network-request.json | fetch, Axios, Apollo, Relay, or React Query operation name, route, sanitized URL, status, timing, retry count, cache hit, request/response snippets, correlation ids, redacted headers. | Connects a failed screen or toast to the exact request or GraphQL operation that caused it. |
map-state.json | react-native-maps or Mapbox camera, visible region, zoom/bearing/pitch, loaded sources/layers, selected markers/features, cluster state, last map error. | Lets an agent compare the map’s internal state with screenshots and gestures. |
store-state.json | Redux, Zustand, Jotai, MobX, Apollo cache, React Query cache, selected ids, loading/error flags, dirty fields. | Captures state that is too nested for logs and too broad for a one-line tool result. |
navigation-state.json | React Navigation route tree, params, selected tab, modal stack, pending deep link, last failed navigation. | Makes a replayable checkpoint for UI-flow bugs. |
support-bundle.zip | Recent JS/native logs, sanitized config, AsyncStorage or SQLite summaries, cache summaries, domain snapshots. | Keeps related evidence together as one downloadable session artifact. |
Use a custom tool instead when the host needs a small JSON answer or a narrow action. Use an artifact when the evidence should be durable, downloadable, and correlated with screenshots, logs, telemetry, visual trees, touches, and annotations.
Project runtime objects into safe plain objects, redact tokens and secrets, trim large bodies, and register providers only for approved local development or QA workflows.
Register A Provider
const registration = Ansight.registerArtifactProvider({
descriptor: {
id: "app.reports",
name: "Reports",
description: "Exports app report artifacts.",
category: "reports",
tags: ["reports", "support"],
},
async query() {
return [
{
id: "current-report",
name: "Current Report",
description: "Exports the current report as CSV.",
kind: "report",
category: "reports",
content: {
supportedMimeTypes: ["text/csv"],
defaultMimeType: "text/csv",
suggestedFileName: "current-report.csv",
supportsText: true,
},
tags: ["csv", "current"],
},
];
},
async create(request) {
if (request.artifactId !== "current-report") {
throw new Error("Unknown artifact.");
}
const text = "id,total\n1,42\n";
return {
metadata: {
artifactId: request.artifactId,
providerId: request.providerId,
name: "Current Report",
kind: "report",
mimeType: "text/csv",
fileName: "current-report.csv",
sizeBytes: text.length,
tags: ["csv", "current"],
},
payload: { text },
};
},
});
await registration.ready;
Payloads can be text, base64, byte arrays, ArrayBuffer, or Uint8Array.
Artifact payloads can contain sensitive app data even though the request tools are read-scoped. Treat every provider as an explicit export surface with stable ids, clear descriptions, and narrowly shaped payloads.
Management
const providers = Ansight.listRegisteredArtifactProviders();
await Ansight.unregisterArtifactProvider("app.reports");
await Ansight.clearArtifactProviders();
Choosing Artifacts
Choose artifacts for outputs that should leave the app as files or durable session evidence:
- attach a sanitized network request/response or GraphQL operation bundle to a failed checkout, login, sync, or search flow
- export a map-state snapshot when a map is blank, centered incorrectly, or missing expected markers
- export Redux, Zustand, Apollo, React Query, navigation, or native-module state that is too nested for a short tool result
- package a support bundle that should stay attached to the captured session
Use Custom Tools for small reads or controlled actions that do not need file materialization.