@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.cjs CHANGED
@@ -97,7 +97,7 @@ var ALL_ACTION_KINDS = [
97
97
  // src/core/constants.ts
98
98
  function resolveSdkVersion() {
99
99
  {
100
- return "0.1.29";
100
+ return "0.1.31";
101
101
  }
102
102
  }
103
103
  var SDK_VERSION = resolveSdkVersion();
@@ -914,7 +914,22 @@ var CloudClient = class {
914
914
  const errorBody = errorRecord && typeof errorRecord === "object" ? errorRecord : void 0;
915
915
  const code = typeof errorBody?.code === "string" ? errorBody.code : typeof errorRecord === "string" ? errorRecord : `HTTP_${response.status}`;
916
916
  if (response.status === 401 || response.status === 403) {
917
- throw new AuthenticationError("Asiyst runtime authorization was rejected.");
917
+ const installationErrorCodes = {
918
+ INSTALLATION_NOT_FOUND: "Asiyst installation not found for this domain. Re-run `asiyst connect` and verify your project domain.",
919
+ INSTALLATION_INACTIVE: "Asiyst installation is inactive. Check your project status in the Asiyst dashboard.",
920
+ INSTALLATION_REVOKED: "Asiyst installation has been revoked. Re-run `asiyst connect` to register a new installation.",
921
+ INSTALLATION_PROJECT_MISMATCH: "Asiyst installation does not match the configured project.",
922
+ INSTALLATION_DOMAIN_MISMATCH: "Asiyst installation domain does not match the current website domain.",
923
+ RUNTIME_TOKEN_INVALID: "Asiyst runtime authorization token is invalid. The SDK will attempt to re-authorize.",
924
+ RUNTIME_TOKEN_EXPIRED: "Asiyst runtime authorization token has expired. The SDK will re-authorize."
925
+ };
926
+ const knownMessage = typeof code === "string" ? installationErrorCodes[code] : void 0;
927
+ if (knownMessage) {
928
+ throw new AuthenticationError(knownMessage);
929
+ }
930
+ throw new AuthenticationError(
931
+ typeof errorBody?.message === "string" ? `Asiyst runtime authorization rejected: ${errorBody.message}` : "Asiyst runtime authorization was rejected."
932
+ );
918
933
  }
919
934
  if (response.status === 429) {
920
935
  throw new NetworkError("The assistant is rate limited. Wait before sending another message.");
@@ -1989,6 +2004,7 @@ var AssetLoader = class {
1989
2004
  return {
1990
2005
  format: "glb",
1991
2006
  url: sanitizedUrl,
2007
+ buffer: arrayBuffer,
1992
2008
  json: parsedGlb.json,
1993
2009
  bin: parsedGlb.bin,
1994
2010
  meshes: parsedGlb.meshes,
@@ -2378,7 +2394,7 @@ var FbxRenderer = class {
2378
2394
  const loader = new GLTFLoader_js.GLTFLoader();
2379
2395
  try {
2380
2396
  const gltf = await new Promise((resolve, reject) => {
2381
- const glbBuffer = asset.bin.buffer.slice(asset.bin.byteOffset, asset.bin.byteOffset + asset.bin.byteLength);
2397
+ const glbBuffer = asset.buffer ? asset.buffer : asset.bin.buffer.slice(asset.bin.byteOffset, asset.bin.byteOffset + asset.bin.byteLength);
2382
2398
  loader.parse(glbBuffer, asset.url, resolve, reject);
2383
2399
  });
2384
2400
  rawObject = gltf.scene;
@@ -2572,7 +2588,7 @@ var FbxRenderer = class {
2572
2588
  } else if (loaded.format === "glb") {
2573
2589
  const loader = new GLTFLoader_js.GLTFLoader();
2574
2590
  const gltf = await new Promise((resolve, reject) => {
2575
- const glbBuffer = loaded.bin.buffer.slice(
2591
+ const glbBuffer = loaded.buffer ? loaded.buffer : loaded.bin.buffer.slice(
2576
2592
  loaded.bin.byteOffset,
2577
2593
  loaded.bin.byteOffset + loaded.bin.byteLength
2578
2594
  );
@@ -3200,6 +3216,8 @@ var CssAvatarRenderer = class {
3200
3216
  if (!this.isAssetLoadedFlag && this.viewport) {
3201
3217
  if (this.renderState === "error") {
3202
3218
  this.renderFallback(true);
3219
+ } else if (this.renderState === "loading") {
3220
+ this.renderLoadingPlaceholder();
3203
3221
  } else {
3204
3222
  this.viewport.replaceChildren();
3205
3223
  }
@@ -3388,6 +3406,16 @@ var CssAvatarRenderer = class {
3388
3406
  }
3389
3407
  }
3390
3408
  }
3409
+ renderLoadingPlaceholder() {
3410
+ if (!this.viewport) return;
3411
+ this.viewport.replaceChildren();
3412
+ const doc = this.viewport.ownerDocument;
3413
+ const placeholder = doc.createElement("div");
3414
+ placeholder.className = "asiyst-avatar-loader";
3415
+ placeholder.setAttribute("aria-hidden", "true");
3416
+ placeholder.setAttribute("data-state", "loading");
3417
+ this.viewport.appendChild(placeholder);
3418
+ }
3391
3419
  renderFallback(isError = false) {
3392
3420
  if (!this.viewport) return;
3393
3421
  this.viewport.replaceChildren();
@@ -4590,8 +4618,28 @@ var RuntimeAuth = class {
4590
4618
  body = void 0;
4591
4619
  }
4592
4620
  if (!response.ok) {
4593
- if (response.status === 403) {
4594
- throw new AuthenticationError("ASIYST runtime authorization was rejected.");
4621
+ if (response.status === 401 || response.status === 403) {
4622
+ const errorRecord = body && typeof body === "object" ? body.error : void 0;
4623
+ const errorBody = errorRecord && typeof errorRecord === "object" ? errorRecord : void 0;
4624
+ const code = typeof errorBody?.code === "string" ? errorBody.code : void 0;
4625
+ const installationErrorCodes = {
4626
+ INSTALLATION_NOT_FOUND: "Asiyst installation not found for this domain. Re-run `asiyst connect` and verify your project domain.",
4627
+ INSTALLATION_INACTIVE: "Asiyst installation is inactive. Check your project status in the Asiyst dashboard.",
4628
+ INSTALLATION_REVOKED: "Asiyst installation has been revoked. Re-run `asiyst connect` to register a new installation.",
4629
+ INSTALLATION_PROJECT_MISMATCH: "Asiyst installation does not match the configured project.",
4630
+ INSTALLATION_DOMAIN_MISMATCH: "Asiyst installation domain does not match the current website domain.",
4631
+ ORIGIN_MISMATCH: "Asiyst installation origin does not match the current website origin.",
4632
+ INSTALLATION_ENVIRONMENT_MISMATCH: "Asiyst installation environment does not match the current website environment.",
4633
+ RUNTIME_TOKEN_INVALID: "Asiyst runtime authorization token is invalid.",
4634
+ RUNTIME_TOKEN_EXPIRED: "Asiyst runtime authorization token has expired."
4635
+ };
4636
+ const knownMessage = code ? installationErrorCodes[code] : void 0;
4637
+ if (knownMessage) {
4638
+ throw new AuthenticationError(knownMessage);
4639
+ }
4640
+ throw new AuthenticationError(
4641
+ typeof errorBody?.message === "string" ? `ASIYST runtime authorization rejected: ${errorBody.message}` : "ASIYST runtime authorization was rejected."
4642
+ );
4595
4643
  }
4596
4644
  if (response.status === 429) {
4597
4645
  throw new NetworkError("ASIYST runtime authentication is rate limited.");
@@ -4602,7 +4650,7 @@ var RuntimeAuth = class {
4602
4650
  throw new NetworkError("ASIYST runtime authentication is unavailable.");
4603
4651
  }
4604
4652
  const data = body?.data;
4605
- 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")) {
4653
+ 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")) {
4606
4654
  throw new AuthenticationError("ASIYST returned an invalid runtime authorization response.");
4607
4655
  }
4608
4656
  const expiresAt = Date.parse(data.expiresAt);
@@ -4879,10 +4927,10 @@ var AsiystRuntime = class {
4879
4927
  this.connectionStatus = "offline";
4880
4928
  this.verificationStatus = "error";
4881
4929
  this.events.emit("asiyst:error", {
4882
- code: "runtime_connection_failed",
4930
+ // Safe diagnostic code — does not expose secrets or signing details.
4931
+ code: "installation_registration_failed",
4883
4932
  message: error instanceof Error ? error.message : "Asiyst runtime connection failed."
4884
4933
  });
4885
- return;
4886
4934
  }
4887
4935
  const cfg = await isolateAsync(() => this.config.refresh(), this.config.get());
4888
4936
  this.metricsTracker.record("configRetrieved");