Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

1.8 KB
Raw Blame
// SPDX-License-Identifier: FSL-1.1-MIT
// Copyright (c) 2026 Cua AI, Inc.

// The first run on this host (`onboarding.get`, `onboarding.complete`, as
// the SwiftUI host answers them: both shells show the web UI's onboarding).
// The page runs the app core's flow (`routes/onboarding`) and asks here
// whether it is due; finishing saves `onboarding.json` as the Swift app's
// OnboardingModel.finish does, asks for Local Network access while someone
// is here (macOS), and applies Done's "Launch at login" checkbox.
import type { BridgeContext } from "./context";
import { Failure, type Handlers } from "./host";
import { hostParts } from "./host-parts";

export function onboardingMethods(ctx: BridgeContext): Handlers {
  const parts = () => hostParts(ctx);
  return {
    "onboarding.get": () => parts().onboarding.read(),
    "onboarding.complete": (args) => {
      const mode = args.mode;
      if (mode !== "client" && mode !== "host") throw Failure.badArgs("mode: client | host");
      parts().onboarding.finish(mode);
      // Done is past Welcome and its usage notice.
      ctx.model.telemetry?.acknowledgeNotice();
      // Every machine, host or not: its own macOS Spaces live on the local
      // network (vmnet), so ask while someone is here.
      ctx.model.host.requestLocalNetwork();
      if (typeof args.launchAtLogin === "boolean") parts().loginItem.set(args.launchAtLogin);
      ctx.model.changed("settings");
      return parts().onboarding.read();
    },
    // Settings, About, "Reset & Show": the first run is forgotten (`onboarding.json`);
    // the page clears its own state (`bridge/onboarding-reset.ts`).
    "onboarding.reset": () => {
      parts().onboarding.reset();
      ctx.model.changed("settings");
      return parts().onboarding.read();
    },
  };
}