@asiyst/sdk 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -36,6 +36,8 @@ Do not pass a secret API key as `publicKey` or omit `projectId`.
36
36
 
37
37
  `avatarId` selects the avatar that the dashboard configured for this project. It is a public identifier, not an authorization credential. The SDK sends it as a selection hint while the Asiyst API still authenticates and authorizes the project with the public project key.
38
38
 
39
+ Knowledge sources, including optional GitHub repositories, are configured in Asiyst Web. The SDK does not receive GitHub credentials and does not copy Knowledge Base content into the website. It initializes the verified project/avatar and retrieves authorized knowledge through the Asiyst backend.
40
+
39
41
  ```ts
40
42
  await Asiyst.init({
41
43
  publicKey: "<PUBLIC_KEY>",
package/dist/index.cjs CHANGED
@@ -460,9 +460,10 @@ var HttpTransport = class {
460
460
 
461
461
  // src/communication/CloudClient.ts
462
462
  var CloudClient = class {
463
- constructor(transport, projectId) {
463
+ constructor(transport, projectId, publicKey = "") {
464
464
  this.transport = transport;
465
465
  this.projectId = projectId;
466
+ this.publicKey = publicKey;
466
467
  }
467
468
  async fetchConfig() {
468
469
  const response = await this.transport.request({
@@ -482,14 +483,22 @@ var CloudClient = class {
482
483
  path: "/sdk/heartbeat",
483
484
  method: "POST",
484
485
  body: {
485
- projectId: this.projectId,
486
- sdkVersion: SDK_VERSION,
487
- websiteOrigin: metadata.origin,
486
+ project_id: this.projectId,
487
+ public_key: this.publicKey,
488
+ sdk_version: SDK_VERSION,
489
+ origin: metadata.origin,
488
490
  environment: metadata.environment,
489
491
  timestamp: metadata.timestamp
490
492
  }
491
493
  });
492
- return { ok: response.ok, status: response.status };
494
+ const body = response.data && typeof response.data === "object" && !Array.isArray(response.data) ? response.data : void 0;
495
+ const rawStatus = body?.status ?? body?.connectionStatus ?? body?.verificationStatus;
496
+ const verificationStatus = rawStatus === "connected" || rawStatus === "inactive" || rawStatus === "not_detected" || rawStatus === "error" ? rawStatus : void 0;
497
+ return {
498
+ ok: response.ok && (verificationStatus === void 0 || verificationStatus === "connected"),
499
+ status: response.status,
500
+ verificationStatus
501
+ };
493
502
  }
494
503
  async requestTask(userText, pageUrl) {
495
504
  const response = await this.transport.request({
@@ -2363,6 +2372,7 @@ var AsiystRuntime = class {
2363
2372
  this.observer = new DomObserver(() => this.rescan());
2364
2373
  this.destroyed = false;
2365
2374
  this.connectionStatus = "disconnected";
2375
+ this.verificationStatus = "not_detected";
2366
2376
  this.rescanDebounced = debounce(() => this.rescan(), DOM_SCAN_DEBOUNCE_MS);
2367
2377
  if (!doc.body) {
2368
2378
  throw new InitializationError("document.body is not available");
@@ -2374,7 +2384,7 @@ var AsiystRuntime = class {
2374
2384
  publicKey: options.publicKey,
2375
2385
  avatarId: options.avatarId
2376
2386
  });
2377
- this.cloud = new CloudClient(transport, options.projectId);
2387
+ this.cloud = new CloudClient(transport, options.projectId, options.publicKey);
2378
2388
  this.config = new ConfigManager(options, this.cloud, this.events);
2379
2389
  this.analytics = new Analytics(options.projectId, this.cloud);
2380
2390
  this.host = new HostRoot(doc);
@@ -2432,6 +2442,7 @@ var AsiystRuntime = class {
2432
2442
  const domainCheck = validateWebsiteDomain(cfg, window.location.href);
2433
2443
  if (!domainCheck.allowed) {
2434
2444
  this.connectionStatus = "disconnected";
2445
+ this.verificationStatus = "not_detected";
2435
2446
  this.events.emit("asiyst:error", {
2436
2447
  code: "domain_not_authorized",
2437
2448
  message: "This website is not authorized for the current Asiyst project."
@@ -2447,14 +2458,19 @@ var AsiystRuntime = class {
2447
2458
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2448
2459
  });
2449
2460
  this.connectionStatus = heartbeat.ok ? "connected" : "disconnected";
2461
+ this.verificationStatus = heartbeat.verificationStatus ?? (heartbeat.ok ? "connected" : "not_detected");
2450
2462
  } catch {
2451
2463
  this.connectionStatus = "offline";
2464
+ this.verificationStatus = "error";
2452
2465
  }
2453
2466
  this.events.emit("asiyst:ready", { projectId: this.options.projectId, configVersion: cfg.version });
2454
2467
  }
2455
2468
  getConnectionStatus() {
2456
2469
  return this.connectionStatus;
2457
2470
  }
2471
+ getVerificationStatus() {
2472
+ return this.verificationStatus;
2473
+ }
2458
2474
  getConfig() {
2459
2475
  return this.config.get();
2460
2476
  }
@@ -2577,6 +2593,9 @@ var Asiyst = {
2577
2593
  getConnectionStatus() {
2578
2594
  return requireRuntime().getConnectionStatus();
2579
2595
  },
2596
+ getVerificationStatus() {
2597
+ return requireRuntime().getVerificationStatus();
2598
+ },
2580
2599
  avatar: {
2581
2600
  show() {
2582
2601
  withIsolation(() => requireRuntime().avatarApi().show());