@xpert-ai/chatkit-types 0.17.0 → 0.19.0
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 +21 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +39 -0
- package/dist/index.js +21 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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;
|
|
@@ -1162,6 +1168,16 @@ export declare type ChatKitWorkbenchFileResource = {
|
|
|
1162
1168
|
targetId?: string;
|
|
1163
1169
|
};
|
|
1164
1170
|
|
|
1171
|
+
/** Public view state owned by a routed embedder. Never carries credentials. */
|
|
1172
|
+
export declare type ChatKitWorkbenchNavigation = {
|
|
1173
|
+
projectId: string | null;
|
|
1174
|
+
view: {
|
|
1175
|
+
viewKey: string;
|
|
1176
|
+
selectionId?: string;
|
|
1177
|
+
parameters?: Record<string, string | number | boolean | null | (string | number | boolean | null)[]>;
|
|
1178
|
+
} | null;
|
|
1179
|
+
};
|
|
1180
|
+
|
|
1165
1181
|
/** Authenticated host response consumed only by ChatKit, never forwarded to a plugin. */
|
|
1166
1182
|
export declare type ChatKitWorkbenchNavigationSession = {
|
|
1167
1183
|
assistantId: string;
|
|
@@ -1173,6 +1189,16 @@ export declare type ChatKitWorkbenchNavigationSession = {
|
|
|
1173
1189
|
};
|
|
1174
1190
|
|
|
1175
1191
|
export declare type ChatKitWorkbenchOptions = {
|
|
1192
|
+
/** Public entry URL for resource links. May contain {projectId}; never include secrets or a private thread. */
|
|
1193
|
+
linkBaseUrl?: string;
|
|
1194
|
+
/**
|
|
1195
|
+
* Restore host URL state after the matching runtime scope has been authorized.
|
|
1196
|
+
* Omit to use ChatKit's own navigation history; view:null closes the routed View.
|
|
1197
|
+
* The embedder must update its authorized API Project scope independently.
|
|
1198
|
+
*/
|
|
1199
|
+
navigation?: ChatKitWorkbenchNavigation;
|
|
1200
|
+
/** Persist successful view selections in the host URL. Replayed state does not emit this callback. */
|
|
1201
|
+
onNavigationChange?: (navigation: ChatKitWorkbenchNavigation) => void | Promise<void>;
|
|
1176
1202
|
/** Show external Assistant executions in a native workbench tab. Enabled by default. */
|
|
1177
1203
|
externalAssistants?: {
|
|
1178
1204
|
enabled?: boolean;
|
|
@@ -1785,6 +1811,12 @@ export declare function getMessageSkillUsages(message: {
|
|
|
1785
1811
|
taskSummary?: unknown;
|
|
1786
1812
|
}): ChatSkillUsage[];
|
|
1787
1813
|
|
|
1814
|
+
/** Resource configuration remains available when the floating pet is disabled. */
|
|
1815
|
+
export declare function getPetAssetsBaseUrl(pet: ChatKitOptions['pet']): string | undefined;
|
|
1816
|
+
|
|
1817
|
+
/** Resolve only built-in resources. Explicit custom character URLs stay untouched. */
|
|
1818
|
+
export declare function getPetAssetUrl(id: string, assetsBaseUrl?: string): string;
|
|
1819
|
+
|
|
1788
1820
|
export declare function getPinnedPetPosition(pin: ChatKitPetPin, size: PetSize, viewport: PetViewport, padding: ChatKitPetBoundsPadding): PetPosition;
|
|
1789
1821
|
|
|
1790
1822
|
export declare type GrayscaleOptions = {
|
|
@@ -3412,6 +3444,13 @@ export declare interface XpertAIChatKit extends HTMLElement {
|
|
|
3412
3444
|
* **IMPORTANT**: New options are not merged with the existing options. You must provide a full set of options every time you call this method.
|
|
3413
3445
|
*/
|
|
3414
3446
|
setOptions(options: ChatKitOptions): void;
|
|
3447
|
+
/**
|
|
3448
|
+
* Flush pending Workbench edits before replacing the runtime or removing ChatKit.
|
|
3449
|
+
* Await true before navigating; false or rejection requires keeping the client mounted.
|
|
3450
|
+
* Dirty state is internal and is not a substitute for this asynchronous leave check.
|
|
3451
|
+
* This checks editor persistence, not completion or cancellation of running AI tasks.
|
|
3452
|
+
*/
|
|
3453
|
+
prepareLeave(): Promise<boolean>;
|
|
3415
3454
|
/** Focuses the composer input field. */
|
|
3416
3455
|
focusComposer(): Promise<void>;
|
|
3417
3456
|
/** 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)
|
|
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:
|
|
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,
|