Explain bugs with app state

Preserve Cordova/Capacitor app state as diagnostic exports so a session includes the internal context behind visible behavior.

Artifacts let you capture the state that screenshots cannot show, such as a JavaScript store or navigation snapshot. Expose selected app data as a named export that the local player and agents can request during a session.

Register a JavaScript provider:

const registration = Ansight.registerArtifactProvider({
  descriptor: { id: "app.exports", name: "App exports" },
  query: async () => [
    {
      id: "state",
      name: "State JSON",
      kind: "snapshot",
      category: "app",
      mimeType: "application/json",
    },
  ],
  create: async () => ({
    metadata: {
      artifactId: "state",
      providerId: "app.exports",
      name: "State JSON",
      kind: "snapshot",
      mimeType: "application/json",
      fileName: "state.json",
    },
    payload: { text: JSON.stringify({ ready: true }) },
  }),
});

await registration.ready;

Providers are exposed through artifacts.query and artifacts.request. Binary Uint8Array, ArrayBuffer, and byte-array payloads use the native live-session transfer channel.

Publish from the App

Publish an artifact when your app produces it—for example after loading a model or finishing a report. No provider registration or remote tool request is needed. This API requires SDK and host releases containing artifact publication; hybrid apps must rebuild their native bridge as well.

const result = await Ansight.publishArtifact({
  metadata: {
    providerId: "scene", artifactId: "loaded-model",
    name: "Loaded model", kind: "model",
    mimeType: "model/gltf-binary", fileName: "model.glb",
  },
  payload: modelBytes, // Uint8Array; text and base64 payloads also work.
});
if (!result.success) console.warn(result.message);

The call returns success only after the connected host acknowledges retaining the file as a session artifact. Read it with ansight session artifacts <session-id> --json or in the player. Repeated calls create separate snapshots, even with the same app artifact id. providerId is a grouping label for publication and does not need a registered provider.

A live connection is required. Disconnected or rejected uploads return a failure and are not queued for later delivery. Publications are limited to 512 MiB each and four pending uploads per session. Choose explicit metadata and app-selected payloads; app-initiated publishing does not enable remote tool access. A lost connection after host persistence can leave the outcome uncertain; retrying can create another snapshot.

The .NET payload API streams files and readable streams in chunks. Native Android and Apple use their existing byte/data payloads; JavaScript and Dart bridge bytes through base64 before chunked transport. Keep large exports within the app’s memory budget.