انتقل إلى المحتوى
Busymate AI

هذا الدليل متوفر حالياً باللغة الإنجليزية فقط.

الأدلة

تثبيت حزمة SDK لـ Electron وإعدادها

ثبّت حزمة SDK لـ Electron بإصدار محدد، واضبط الهوية وإذن الميكروفون، ثم ابنِ التطبيق النموذجي.

في هذه الصفحة

Integrate Busymate AI in an Electron app using the official Electron SDK distribution 1.0.1: an npm package with a main-process helper that creates the chat window with secure defaults. Source, the configuration reference and a buildable demo live in the public repository, released as 1.0.1. Identity uses protocol v2 / bridge build 2.0.0; microphone uses protocol v1 / adapter 1.0.0. The release manifest pins the source hashes. Its CONTRACT-v2.md hash matches https://busymate.ai/sdk/v2/2.0.0/SHA256SUMS.

1. Install the pinned version

  1. Install the packed tarball attached to the 1.0.1 release: npm install https://github.com/serebano/busymate-ai-sdk-electron/releases/download/1.0.1/busymate-ai-electron-1.0.1.tgz. The package is not on the npm registry. Alternatively, clone tag 1.0.1, build it and install the local folder.
  2. The SDK requires Electron 30 or later (a peer dependency, for WebContentsView). It ships CommonJS and ESM with TypeScript types and has no runtime dependencies.
  3. Call the package's create-chat-window helper (or the WebContentsView variant) and then chat.load(). The helper uses contextIsolation, the Chromium sandbox, no nodeIntegration, no <webview> and a dedicated persistent session. Both bridges are installed before the first load. The frozen identity files are byte-identical to https://busymate.ai/sdk/v2/2.0.0/electron/.

Read the versioned installation instructions before wiring callbacks.

2. Load the chat as the window's page

Use the chat URL and assistant slug from your workspace, for example https://YOUR_ASSISTANT.busymate.ai/?channel=desktop_sdk&locale=en. Keep the URL's supported parameters and set channel=desktop_sdk. The chat is the window's top-level page: it uses the normal chat layout and shows your locale from the first frame. Do not use channel=embed, which needs an allowed parent web page and refuses to start as a window, or channel=desktop, which is reserved for the Busymate AI desktop app.

Allow only exact HTTPS origins, without wildcards. The assistant slug adds exactly https://<assistant>.busymate.ai. Add https://busymate.ai when you load a /support/<assistant> URL, and add your mapped support host if you have one.

3. Configure every supported callback

The options are:

SettingPurpose
urlRequired HTTPS chat URL with channel=desktop_sdk; its origin must be allowed.
assistantRequired assistant slug.
originsExtra exact HTTPS chat origins.
appIdRequired app id; salts the account hash.
accountCurrent account ID, or null when signed out.
mintRequired backend callback returning { token, nonce } or null, fresh for every request.
onActionOptional app action handler; return true only when handled.
onCloseOptional host dismissal callback, for example chat.window.close().
microphoneDefault true; false loads the identity-only preload.

Your backend must sign the supplied nonce with ES256, a unique jti and an expiry within 120 seconds. Never ship signing keys, cache launch tokens or log tokens. See backend signing and the complete configuration reference.

4. Wire the OS microphone callback

Call chat.accountChanged() after login, logout and account switches. When the renderer dies, the bridge reloads the chat and sends restored, and your onRenderProcessGone callback is told.

On macOS the OS is asked with systemPreferences.askForMediaAccess when the customer first taps. For a packaged macOS app, add NSMicrophoneUsageDescription to Info.plist and, with the hardened runtime, the com.apple.security.device.audio-input entitlement. Only an OS grant plus the session's allowed-origin, audio-only decision permits recording.

A mic or voice tap sends busymate.microphone.v1.request with id and source. The SDK obtains OS permission and returns { id, granted }. Chat waits for that reply before capture or voice token minting. Denial and timeout fail closed, and cancellation prevents a delayed grant from starting a cancelled session. Opening the chat never asks. See microphone lifecycle and troubleshooting.

5. Build and test the demo

Run npm ci && npm run build, then cd example-app && npm ci && npm start. Its settings window changes the chat URL, locale, origins, guest or identified mint, microphone and callbacks. Follow the example-app build instructions. Guest chat needs no fake identity, and authenticated tests use your own backend. The event log helps with integration troubleshooting without exposing credentials.

Knowledge, tools, handoff, branding and voice availability are workspace features. Locale and appearance follow the supported hosted chat parameters. The SDK does not invent native flags for these services.

Verify

  1. Build the example app and verify guest chat, loaded with channel=desktop_sdk.
  2. Load ?channel=desktop_sdk&locale=de: the first frame is in German and the chat fills the window with no extra title-bar inset.
  3. Use your backend to test sign-in, logout and account switching without history leakage.
  4. On a real machine, test the first mic/voice grant, denial, retry after changing the OS setting, and cancellation while the prompt is open.
  5. Test external links, close/action callbacks, window re-activation and renderer recovery.

الأسئلة

Which version should I install?

Electron SDK distribution 1.0.1, the tarball attached to the release. Its frozen kit files match https://busymate.ai/sdk/v2/2.0.0/SHA256SUMS.

Does the demo authenticate without my backend?

No. Guest mode works when your workspace allows it; authenticated mode requires your real backend and a current session.

Which updates require an app release?

SDK changes, OS permission declarations and native capabilities require an app release. Hosted chat changes arrive from the service.