@xpert-ai/chatkit-types 0.18.0 → 0.19.1

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.ts CHANGED
@@ -934,6 +934,12 @@ export declare type ChatKitPetFrameAnimation = {
934
934
  };
935
935
 
936
936
  export declare type ChatKitPetOptions = {
937
+ /** Base URL of the built-in pet directory (containing catalog.json and pet IDs).
938
+ * Defaults to /pets. Accepts HTTPS URLs or root-relative paths; custom character
939
+ * URLs are unaffected. Also applies to Assistant appearance sprites when
940
+ * enabled is false. Host offline assets separately from the UI npm package.
941
+ */
942
+ assetsBaseUrl?: string;
937
943
  enabled?: boolean;
938
944
  character?: ChatKitPetCharacter;
939
945
  position?: ChatKitPetPositionOptions;
@@ -1167,6 +1173,8 @@ export declare type ChatKitWorkbenchNavigation = {
1167
1173
  projectId: string | null;
1168
1174
  view: {
1169
1175
  viewKey: string;
1176
+ /** Apply after authorization and pending edits are saved; omit to preserve the user's layout. */
1177
+ layout?: 'split' | 'maximized';
1170
1178
  selectionId?: string;
1171
1179
  parameters?: Record<string, string | number | boolean | null | (string | number | boolean | null)[]>;
1172
1180
  } | null;
@@ -1183,6 +1191,8 @@ export declare type ChatKitWorkbenchNavigationSession = {
1183
1191
  };
1184
1192
 
1185
1193
  export declare type ChatKitWorkbenchOptions = {
1194
+ /** Public entry URL for resource links. May contain {projectId}; never include secrets or a private thread. */
1195
+ linkBaseUrl?: string;
1186
1196
  /**
1187
1197
  * Restore host URL state after the matching runtime scope has been authorized.
1188
1198
  * Omit to use ChatKit's own navigation history; view:null closes the routed View.
@@ -1803,6 +1813,12 @@ export declare function getMessageSkillUsages(message: {
1803
1813
  taskSummary?: unknown;
1804
1814
  }): ChatSkillUsage[];
1805
1815
 
1816
+ /** Resource configuration remains available when the floating pet is disabled. */
1817
+ export declare function getPetAssetsBaseUrl(pet: ChatKitOptions['pet']): string | undefined;
1818
+
1819
+ /** Resolve only built-in resources. Explicit custom character URLs stay untouched. */
1820
+ export declare function getPetAssetUrl(id: string, assetsBaseUrl?: string): string;
1821
+
1806
1822
  export declare function getPinnedPetPosition(pin: ChatKitPetPin, size: PetSize, viewport: PetViewport, padding: ChatKitPetBoundsPadding): PetPosition;
1807
1823
 
1808
1824
  export declare type GrayscaleOptions = {
@@ -3430,6 +3446,13 @@ export declare interface XpertAIChatKit extends HTMLElement {
3430
3446
  * **IMPORTANT**: New options are not merged with the existing options. You must provide a full set of options every time you call this method.
3431
3447
  */
3432
3448
  setOptions(options: ChatKitOptions): void;
3449
+ /**
3450
+ * Flush pending Workbench edits before replacing the runtime or removing ChatKit.
3451
+ * Await true before navigating; false or rejection requires keeping the client mounted.
3452
+ * Dirty state is internal and is not a substitute for this asynchronous leave check.
3453
+ * This checks editor persistence, not completion or cancellation of running AI tasks.
3454
+ */
3455
+ prepareLeave(): Promise<boolean>;
3433
3456
  /** Focuses the composer input field. */
3434
3457
  focusComposer(): Promise<void>;
3435
3458
  /** Changes the active thread. Pass `null` to switch to a new thread. */
package/dist/index.js CHANGED
@@ -752,7 +752,8 @@ const DEFAULT_PET_SIZE = {
752
752
  height: petSpriteAtlas.cellHeight
753
753
  };
754
754
  function petLookFrame(dx, dy, deadZone = 12) {
755
- if (!Number.isFinite(dx) || !Number.isFinite(dy) || Math.hypot(dx, dy) <= deadZone) return null;
755
+ if (!Number.isFinite(dx) || !Number.isFinite(dy) || Math.hypot(dx, dy) <= deadZone)
756
+ return null;
756
757
  const index = (Math.round(Math.atan2(dx, -dy) / (Math.PI / 8)) + 16) % 16;
757
758
  return { row: 9 + Math.floor(index / 8), column: index % 8 };
758
759
  }
@@ -763,6 +764,14 @@ const DEFAULT_PET_BOUNDS_PADDING = {
763
764
  left: 0
764
765
  };
765
766
  const DEFAULT_PET_STORAGE_KEY = "chatkit:pet:position:v1";
767
+ function getPetAssetsBaseUrl(pet) {
768
+ return pet && typeof pet === "object" ? pet.assetsBaseUrl : void 0;
769
+ }
770
+ function getPetAssetUrl(id, assetsBaseUrl) {
771
+ const base = ((assetsBaseUrl == null ? void 0 : assetsBaseUrl.trim()) || "/pets").replace(/\/+$/, "");
772
+ const resourceId = id === "lando" ? "lando-2" : id;
773
+ return `${base}/${encodeURIComponent(resourceId)}/spritesheet.webp`;
774
+ }
766
775
  const DEFAULT_PET_SPRITESHEET_URL = "/pets/boba/spritesheet.webp";
767
776
  const DEFAULT_PET_CHARACTER = {
768
777
  type: "sprite-atlas",
@@ -809,12 +818,16 @@ function normalizeCharacter(character) {
809
818
  return DEFAULT_PET_CHARACTER;
810
819
  }
811
820
  function normalizePetOptions(pet) {
821
+ var _a;
812
822
  if (!pet) {
813
823
  return null;
814
824
  }
815
825
  if (pet === true) {
816
826
  return {
817
- character: DEFAULT_PET_CHARACTER,
827
+ character: {
828
+ ...DEFAULT_PET_CHARACTER,
829
+ src: getPetAssetUrl("boba")
830
+ },
818
831
  position: DEFAULT_POSITION,
819
832
  behavior: "auto",
820
833
  ariaLabel: "Animated pet",
@@ -825,7 +838,10 @@ function normalizePetOptions(pet) {
825
838
  return null;
826
839
  }
827
840
  return {
828
- character: normalizeCharacter(pet.character),
841
+ character: ((_a = pet.character) == null ? void 0 : _a.src) ? normalizeCharacter(pet.character) : {
842
+ ...DEFAULT_PET_CHARACTER,
843
+ src: getPetAssetUrl("boba", pet.assetsBaseUrl)
844
+ },
829
845
  position: {
830
846
  ...DEFAULT_POSITION,
831
847
  ...pet.position
@@ -1247,6 +1263,8 @@ export {
1247
1263
  getFileActivityContribution,
1248
1264
  getLegacyFileActivityContribution,
1249
1265
  getMessageSkillUsages,
1266
+ getPetAssetUrl,
1267
+ getPetAssetsBaseUrl,
1250
1268
  getPinnedPetPosition,
1251
1269
  isApprovalHostReference,
1252
1270
  isCallEndedContent,