@asiyst/sdk 0.1.30 → 0.1.31

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/dist/index.d.cts CHANGED
@@ -469,6 +469,7 @@ interface ParsedGlbMesh {
469
469
  interface LoadedGlbAsset {
470
470
  format: "glb";
471
471
  url: string;
472
+ buffer: ArrayBuffer;
472
473
  json: Record<string, unknown>;
473
474
  bin: Uint8Array;
474
475
  meshes: ParsedGlbMesh[];
@@ -631,6 +632,7 @@ declare class CssAvatarRenderer implements AvatarRenderer {
631
632
  loadAsset(config: ProjectConfig, metricsTracker?: AvatarMetricsTracker): Promise<boolean>;
632
633
  renderLoader(): void;
633
634
  private renderLoadedAsset;
635
+ private renderLoadingPlaceholder;
634
636
  private renderFallback;
635
637
  setPosition(x: number, y: number, animate: boolean): void;
636
638
  setFacing(direction: "left" | "right"): void;
package/dist/index.d.ts CHANGED
@@ -469,6 +469,7 @@ interface ParsedGlbMesh {
469
469
  interface LoadedGlbAsset {
470
470
  format: "glb";
471
471
  url: string;
472
+ buffer: ArrayBuffer;
472
473
  json: Record<string, unknown>;
473
474
  bin: Uint8Array;
474
475
  meshes: ParsedGlbMesh[];
@@ -631,6 +632,7 @@ declare class CssAvatarRenderer implements AvatarRenderer {
631
632
  loadAsset(config: ProjectConfig, metricsTracker?: AvatarMetricsTracker): Promise<boolean>;
632
633
  renderLoader(): void;
633
634
  private renderLoadedAsset;
635
+ private renderLoadingPlaceholder;
634
636
  private renderFallback;
635
637
  setPosition(x: number, y: number, animate: boolean): void;
636
638
  setFacing(direction: "left" | "right"): void;
package/dist/index.js CHANGED
@@ -75,7 +75,7 @@ var ALL_ACTION_KINDS = [
75
75
  // src/core/constants.ts
76
76
  function resolveSdkVersion() {
77
77
  {
78
- return "0.1.29";
78
+ return "0.1.31";
79
79
  }
80
80
  }
81
81
  var SDK_VERSION = resolveSdkVersion();
@@ -892,7 +892,22 @@ var CloudClient = class {
892
892
  const errorBody = errorRecord && typeof errorRecord === "object" ? errorRecord : void 0;
893
893
  const code = typeof errorBody?.code === "string" ? errorBody.code : typeof errorRecord === "string" ? errorRecord : `HTTP_${response.status}`;
894
894
  if (response.status === 401 || response.status === 403) {
895
- throw new AuthenticationError("Asiyst runtime authorization was rejected.");
895
+ const installationErrorCodes = {
896
+ INSTALLATION_NOT_FOUND: "Asiyst installation not found for this domain. Re-run `asiyst connect` and verify your project domain.",
897
+ INSTALLATION_INACTIVE: "Asiyst installation is inactive. Check your project status in the Asiyst dashboard.",
898
+ INSTALLATION_REVOKED: "Asiyst installation has been revoked. Re-run `asiyst connect` to register a new installation.",
899
+ INSTALLATION_PROJECT_MISMATCH: "Asiyst installation does not match the configured project.",
900
+ INSTALLATION_DOMAIN_MISMATCH: "Asiyst installation domain does not match the current website domain.",
901
+ RUNTIME_TOKEN_INVALID: "Asiyst runtime authorization token is invalid. The SDK will attempt to re-authorize.",
902
+ RUNTIME_TOKEN_EXPIRED: "Asiyst runtime authorization token has expired. The SDK will re-authorize."
903
+ };
904
+ const knownMessage = typeof code === "string" ? installationErrorCodes[code] : void 0;
905
+ if (knownMessage) {
906
+ throw new AuthenticationError(knownMessage);
907
+ }
908
+ throw new AuthenticationError(
909
+ typeof errorBody?.message === "string" ? `Asiyst runtime authorization rejected: ${errorBody.message}` : "Asiyst runtime authorization was rejected."
910
+ );
896
911
  }
897
912
  if (response.status === 429) {
898
913
  throw new NetworkError("The assistant is rate limited. Wait before sending another message.");
@@ -1967,6 +1982,7 @@ var AssetLoader = class {
1967
1982
  return {
1968
1983
  format: "glb",
1969
1984
  url: sanitizedUrl,
1985
+ buffer: arrayBuffer,
1970
1986
  json: parsedGlb.json,
1971
1987
  bin: parsedGlb.bin,
1972
1988
  meshes: parsedGlb.meshes,
@@ -2356,7 +2372,7 @@ var FbxRenderer = class {
2356
2372
  const loader = new GLTFLoader();
2357
2373
  try {
2358
2374
  const gltf = await new Promise((resolve, reject) => {
2359
- const glbBuffer = asset.bin.buffer.slice(asset.bin.byteOffset, asset.bin.byteOffset + asset.bin.byteLength);
2375
+ const glbBuffer = asset.buffer ? asset.buffer : asset.bin.buffer.slice(asset.bin.byteOffset, asset.bin.byteOffset + asset.bin.byteLength);
2360
2376
  loader.parse(glbBuffer, asset.url, resolve, reject);
2361
2377
  });
2362
2378
  rawObject = gltf.scene;
@@ -2550,7 +2566,7 @@ var FbxRenderer = class {
2550
2566
  } else if (loaded.format === "glb") {
2551
2567
  const loader = new GLTFLoader();
2552
2568
  const gltf = await new Promise((resolve, reject) => {
2553
- const glbBuffer = loaded.bin.buffer.slice(
2569
+ const glbBuffer = loaded.buffer ? loaded.buffer : loaded.bin.buffer.slice(
2554
2570
  loaded.bin.byteOffset,
2555
2571
  loaded.bin.byteOffset + loaded.bin.byteLength
2556
2572
  );
@@ -3178,6 +3194,8 @@ var CssAvatarRenderer = class {
3178
3194
  if (!this.isAssetLoadedFlag && this.viewport) {
3179
3195
  if (this.renderState === "error") {
3180
3196
  this.renderFallback(true);
3197
+ } else if (this.renderState === "loading") {
3198
+ this.renderLoadingPlaceholder();
3181
3199
  } else {
3182
3200
  this.viewport.replaceChildren();
3183
3201
  }
@@ -3366,6 +3384,16 @@ var CssAvatarRenderer = class {
3366
3384
  }
3367
3385
  }
3368
3386
  }
3387
+ renderLoadingPlaceholder() {
3388
+ if (!this.viewport) return;
3389
+ this.viewport.replaceChildren();
3390
+ const doc = this.viewport.ownerDocument;
3391
+ const placeholder = doc.createElement("div");
3392
+ placeholder.className = "asiyst-avatar-loader";
3393
+ placeholder.setAttribute("aria-hidden", "true");
3394
+ placeholder.setAttribute("data-state", "loading");
3395
+ this.viewport.appendChild(placeholder);
3396
+ }
3369
3397
  renderFallback(isError = false) {
3370
3398
  if (!this.viewport) return;
3371
3399
  this.viewport.replaceChildren();
@@ -4568,8 +4596,28 @@ var RuntimeAuth = class {
4568
4596
  body = void 0;
4569
4597
  }
4570
4598
  if (!response.ok) {
4571
- if (response.status === 403) {
4572
- throw new AuthenticationError("ASIYST runtime authorization was rejected.");
4599
+ if (response.status === 401 || response.status === 403) {
4600
+ const errorRecord = body && typeof body === "object" ? body.error : void 0;
4601
+ const errorBody = errorRecord && typeof errorRecord === "object" ? errorRecord : void 0;
4602
+ const code = typeof errorBody?.code === "string" ? errorBody.code : void 0;
4603
+ const installationErrorCodes = {
4604
+ INSTALLATION_NOT_FOUND: "Asiyst installation not found for this domain. Re-run `asiyst connect` and verify your project domain.",
4605
+ INSTALLATION_INACTIVE: "Asiyst installation is inactive. Check your project status in the Asiyst dashboard.",
4606
+ INSTALLATION_REVOKED: "Asiyst installation has been revoked. Re-run `asiyst connect` to register a new installation.",
4607
+ INSTALLATION_PROJECT_MISMATCH: "Asiyst installation does not match the configured project.",
4608
+ INSTALLATION_DOMAIN_MISMATCH: "Asiyst installation domain does not match the current website domain.",
4609
+ ORIGIN_MISMATCH: "Asiyst installation origin does not match the current website origin.",
4610
+ INSTALLATION_ENVIRONMENT_MISMATCH: "Asiyst installation environment does not match the current website environment.",
4611
+ RUNTIME_TOKEN_INVALID: "Asiyst runtime authorization token is invalid.",
4612
+ RUNTIME_TOKEN_EXPIRED: "Asiyst runtime authorization token has expired."
4613
+ };
4614
+ const knownMessage = code ? installationErrorCodes[code] : void 0;
4615
+ if (knownMessage) {
4616
+ throw new AuthenticationError(knownMessage);
4617
+ }
4618
+ throw new AuthenticationError(
4619
+ typeof errorBody?.message === "string" ? `ASIYST runtime authorization rejected: ${errorBody.message}` : "ASIYST runtime authorization was rejected."
4620
+ );
4573
4621
  }
4574
4622
  if (response.status === 429) {
4575
4623
  throw new NetworkError("ASIYST runtime authentication is rate limited.");
@@ -4580,7 +4628,7 @@ var RuntimeAuth = class {
4580
4628
  throw new NetworkError("ASIYST runtime authentication is unavailable.");
4581
4629
  }
4582
4630
  const data = body?.data;
4583
- if (body?.success !== true || !data || typeof data.token !== "string" || data.token.length < 20 || data.tokenType !== "Bearer" || data.audience !== "asiyst-sdk-runtime" || typeof data.expiresAt !== "string" || data.expiresIn !== 300 || !Array.isArray(data.capabilities) || !data.capabilities.includes("assistant:config") || !data.capabilities.includes("assistant:conversation") || !data.capabilities.includes("assistant:heartbeat")) {
4631
+ if (body?.success !== true || !data || typeof data.token !== "string" || data.token.length < 20 || data.tokenType !== "Bearer" || data.audience !== "asiyst-sdk-runtime" || typeof data.expiresAt !== "string" || typeof data.expiresIn !== "number" || data.expiresIn <= 0 || !Array.isArray(data.capabilities) || !data.capabilities.includes("assistant:config") || !data.capabilities.includes("assistant:conversation") || !data.capabilities.includes("assistant:heartbeat")) {
4584
4632
  throw new AuthenticationError("ASIYST returned an invalid runtime authorization response.");
4585
4633
  }
4586
4634
  const expiresAt = Date.parse(data.expiresAt);
@@ -4857,10 +4905,10 @@ var AsiystRuntime = class {
4857
4905
  this.connectionStatus = "offline";
4858
4906
  this.verificationStatus = "error";
4859
4907
  this.events.emit("asiyst:error", {
4860
- code: "runtime_connection_failed",
4908
+ // Safe diagnostic code — does not expose secrets or signing details.
4909
+ code: "installation_registration_failed",
4861
4910
  message: error instanceof Error ? error.message : "Asiyst runtime connection failed."
4862
4911
  });
4863
- return;
4864
4912
  }
4865
4913
  const cfg = await isolateAsync(() => this.config.refresh(), this.config.get());
4866
4914
  this.metricsTracker.record("configRetrieved");