@kibee/contracts 0.7.0 → 0.8.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.d.mts +42 -7
- package/dist/index.d.ts +42 -7
- package/dist/index.js +59 -9
- package/dist/index.mjs +54 -9
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -4,13 +4,31 @@ type WidgetDockPosition = WidgetDockPreset | {
|
|
|
4
4
|
offsetX?: number;
|
|
5
5
|
offsetY?: number;
|
|
6
6
|
};
|
|
7
|
-
type AvatarMode = "default" | "preset" | "custom";
|
|
7
|
+
type AvatarMode = "default" | "preset" | "custom" | "vector" | "lottie";
|
|
8
8
|
type AvatarPresetId = "orb" | "ring";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
type AvatarMotion = "breathe" | "pulse" | "spin" | "none";
|
|
10
|
+
/** Relative path — embed apps fetch via API with publishable key (bucket URLs are often private). */
|
|
11
|
+
declare const WIDGET_AVATAR_PROXY_PATH = "/widget-avatar";
|
|
12
|
+
/** Query appended to WIDGET_AVATAR_PROXY_PATH to fetch the tenant's Lottie JSON. */
|
|
13
|
+
declare const WIDGET_AVATAR_LOTTIE_PROXY_PATH = "/widget-avatar?type=lottie";
|
|
14
|
+
type WidgetAvatarConfig = {
|
|
15
|
+
mode: "default";
|
|
16
|
+
} | {
|
|
17
|
+
mode: "preset";
|
|
18
|
+
preset: AvatarPresetId;
|
|
19
|
+
} | {
|
|
20
|
+
mode: "custom";
|
|
21
|
+
assetUrl: string;
|
|
22
|
+
} | {
|
|
23
|
+
mode: "vector";
|
|
24
|
+
svg: string;
|
|
25
|
+
motion: AvatarMotion;
|
|
26
|
+
color?: string;
|
|
27
|
+
} | {
|
|
28
|
+
mode: "lottie";
|
|
29
|
+
assetUrl: string;
|
|
30
|
+
motion: AvatarMotion;
|
|
31
|
+
};
|
|
14
32
|
interface WidgetConfigResponse {
|
|
15
33
|
dockPosition: WidgetDockPosition;
|
|
16
34
|
dockSize: number;
|
|
@@ -32,10 +50,16 @@ interface WidgetSettingsRecord {
|
|
|
32
50
|
avatarPreset?: AvatarPresetId;
|
|
33
51
|
avatarAssetUrl?: string;
|
|
34
52
|
avatarAssetKey?: string;
|
|
53
|
+
avatarSvg?: string;
|
|
54
|
+
avatarColor?: string;
|
|
55
|
+
avatarLottieKey?: string;
|
|
56
|
+
avatarMotion?: AvatarMotion;
|
|
35
57
|
[key: string]: unknown;
|
|
36
58
|
}
|
|
37
59
|
declare function isAvatarMode(value: unknown): value is AvatarMode;
|
|
38
60
|
declare function isAvatarPresetId(value: unknown): value is AvatarPresetId;
|
|
61
|
+
declare function isAvatarMotion(value: unknown): value is AvatarMotion;
|
|
62
|
+
declare function isWidgetAvatarProxyUrl(url: string): boolean;
|
|
39
63
|
declare function parseWidgetAvatar(settings: WidgetSettingsRecord): WidgetAvatarConfig;
|
|
40
64
|
declare function buildWidgetConfigResponse(settings: WidgetSettingsRecord): WidgetConfigResponse;
|
|
41
65
|
/** Map widget avatar config to ThreeBeeRenderer constructor options. */
|
|
@@ -43,6 +67,17 @@ declare function resolveRendererAvatarOptions(avatar: WidgetAvatarConfig): {
|
|
|
43
67
|
avatarPreset: "bee" | AvatarPresetId;
|
|
44
68
|
assetUrl?: string;
|
|
45
69
|
};
|
|
70
|
+
type BeeVisualState = "idle" | "guiding" | "thinking" | "celebrating";
|
|
71
|
+
type AnimationSpec = {
|
|
72
|
+
kind: "css";
|
|
73
|
+
className: string | null;
|
|
74
|
+
} | {
|
|
75
|
+
kind: "lottie";
|
|
76
|
+
segment: string;
|
|
77
|
+
loop: boolean;
|
|
78
|
+
};
|
|
79
|
+
/** Per-state animation descriptor consumed by DomAvatarRenderer. */
|
|
80
|
+
declare function getAvatarStateAnimations(mode: "vector" | "lottie", motion: AvatarMotion): Record<BeeVisualState, AnimationSpec>;
|
|
46
81
|
|
|
47
82
|
/**
|
|
48
83
|
* Frozen Sprint 1 contract. Edits require joint sign-off from Track A
|
|
@@ -844,4 +879,4 @@ declare const SLO_THRESHOLDS: {
|
|
|
844
879
|
};
|
|
845
880
|
};
|
|
846
881
|
|
|
847
|
-
export { type AdminSessionSummary, type AllowedDomain, type AllowlistCheckResponse, type AnalyticsEvent, type AuditAction, type AuditEvent, type AvatarMode, type AvatarPresetId, BUDDY_TRANSITIONS, type BridgeClaims, type BridgeEnvelope, type BridgeEventType, type BuddyState, type CandidateGroup, type CaptureStatus, type CaptureSummary, type CaptureUploadEnvelope, type CaptureUploadPayload, type CaptureUploadResponse, type ChatMessage, type ChatMode, type ChatSender, type CrossSiteFlowQueueItem, type CrossSiteFlowStep, type DiffPreview, type DockInlineAnchor, type DockPositionConfig, type DockPositionPreset, type EventMetadata, type FeatureFlag, type FeatureFlagOverride, type FlowCommand, type FlowDefinition, type FlowMoveOptions, type FlowStep, type HighlightVariant, type IdentityRequest, type IdentityResponse, type IntentMatch, type KiBeePairAccept, type KiBeePairReject, type KiBeePairRequest, type MemoryRecallItem, type MemoryRecallResponse, type MemoryScope, type MessageTemplate, type PairingState, type PromoteCandidatePayload, type PushFlowRequest, type PushTargetsRequest, type RecoveryRequest, type RecoveryResponse, type RegisteredTarget, type ResolveIntentRequest, type ResolvedFlagSet, SLO_THRESHOLDS, type SessionState, type SloSnapshot, type SloWindow, type StartSessionRequest, type SurfaceId, type TargetRef, type TenantAttachPayload, type TenantFlowsResponse, type TrackEventRequest, type VisibleTarget, type VisitorIdentity, type VisitorPollResponse, type WidgetAvatarConfig, type WidgetConfig, type WidgetConfigResponse, type WidgetDockPosition, type WidgetDockPreset, type WidgetSettingsRecord, buildWidgetConfigResponse, canTransition, isAvatarMode, isAvatarPresetId, isBridgeEnvelope, parseWidgetAvatar, resolveRendererAvatarOptions };
|
|
882
|
+
export { type AdminSessionSummary, type AllowedDomain, type AllowlistCheckResponse, type AnalyticsEvent, type AnimationSpec, type AuditAction, type AuditEvent, type AvatarMode, type AvatarMotion, type AvatarPresetId, BUDDY_TRANSITIONS, type BeeVisualState, type BridgeClaims, type BridgeEnvelope, type BridgeEventType, type BuddyState, type CandidateGroup, type CaptureStatus, type CaptureSummary, type CaptureUploadEnvelope, type CaptureUploadPayload, type CaptureUploadResponse, type ChatMessage, type ChatMode, type ChatSender, type CrossSiteFlowQueueItem, type CrossSiteFlowStep, type DiffPreview, type DockInlineAnchor, type DockPositionConfig, type DockPositionPreset, type EventMetadata, type FeatureFlag, type FeatureFlagOverride, type FlowCommand, type FlowDefinition, type FlowMoveOptions, type FlowStep, type HighlightVariant, type IdentityRequest, type IdentityResponse, type IntentMatch, type KiBeePairAccept, type KiBeePairReject, type KiBeePairRequest, type MemoryRecallItem, type MemoryRecallResponse, type MemoryScope, type MessageTemplate, type PairingState, type PromoteCandidatePayload, type PushFlowRequest, type PushTargetsRequest, type RecoveryRequest, type RecoveryResponse, type RegisteredTarget, type ResolveIntentRequest, type ResolvedFlagSet, SLO_THRESHOLDS, type SessionState, type SloSnapshot, type SloWindow, type StartSessionRequest, type SurfaceId, type TargetRef, type TenantAttachPayload, type TenantFlowsResponse, type TrackEventRequest, type VisibleTarget, type VisitorIdentity, type VisitorPollResponse, WIDGET_AVATAR_LOTTIE_PROXY_PATH, WIDGET_AVATAR_PROXY_PATH, type WidgetAvatarConfig, type WidgetConfig, type WidgetConfigResponse, type WidgetDockPosition, type WidgetDockPreset, type WidgetSettingsRecord, buildWidgetConfigResponse, canTransition, getAvatarStateAnimations, isAvatarMode, isAvatarMotion, isAvatarPresetId, isBridgeEnvelope, isWidgetAvatarProxyUrl, parseWidgetAvatar, resolveRendererAvatarOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,13 +4,31 @@ type WidgetDockPosition = WidgetDockPreset | {
|
|
|
4
4
|
offsetX?: number;
|
|
5
5
|
offsetY?: number;
|
|
6
6
|
};
|
|
7
|
-
type AvatarMode = "default" | "preset" | "custom";
|
|
7
|
+
type AvatarMode = "default" | "preset" | "custom" | "vector" | "lottie";
|
|
8
8
|
type AvatarPresetId = "orb" | "ring";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
type AvatarMotion = "breathe" | "pulse" | "spin" | "none";
|
|
10
|
+
/** Relative path — embed apps fetch via API with publishable key (bucket URLs are often private). */
|
|
11
|
+
declare const WIDGET_AVATAR_PROXY_PATH = "/widget-avatar";
|
|
12
|
+
/** Query appended to WIDGET_AVATAR_PROXY_PATH to fetch the tenant's Lottie JSON. */
|
|
13
|
+
declare const WIDGET_AVATAR_LOTTIE_PROXY_PATH = "/widget-avatar?type=lottie";
|
|
14
|
+
type WidgetAvatarConfig = {
|
|
15
|
+
mode: "default";
|
|
16
|
+
} | {
|
|
17
|
+
mode: "preset";
|
|
18
|
+
preset: AvatarPresetId;
|
|
19
|
+
} | {
|
|
20
|
+
mode: "custom";
|
|
21
|
+
assetUrl: string;
|
|
22
|
+
} | {
|
|
23
|
+
mode: "vector";
|
|
24
|
+
svg: string;
|
|
25
|
+
motion: AvatarMotion;
|
|
26
|
+
color?: string;
|
|
27
|
+
} | {
|
|
28
|
+
mode: "lottie";
|
|
29
|
+
assetUrl: string;
|
|
30
|
+
motion: AvatarMotion;
|
|
31
|
+
};
|
|
14
32
|
interface WidgetConfigResponse {
|
|
15
33
|
dockPosition: WidgetDockPosition;
|
|
16
34
|
dockSize: number;
|
|
@@ -32,10 +50,16 @@ interface WidgetSettingsRecord {
|
|
|
32
50
|
avatarPreset?: AvatarPresetId;
|
|
33
51
|
avatarAssetUrl?: string;
|
|
34
52
|
avatarAssetKey?: string;
|
|
53
|
+
avatarSvg?: string;
|
|
54
|
+
avatarColor?: string;
|
|
55
|
+
avatarLottieKey?: string;
|
|
56
|
+
avatarMotion?: AvatarMotion;
|
|
35
57
|
[key: string]: unknown;
|
|
36
58
|
}
|
|
37
59
|
declare function isAvatarMode(value: unknown): value is AvatarMode;
|
|
38
60
|
declare function isAvatarPresetId(value: unknown): value is AvatarPresetId;
|
|
61
|
+
declare function isAvatarMotion(value: unknown): value is AvatarMotion;
|
|
62
|
+
declare function isWidgetAvatarProxyUrl(url: string): boolean;
|
|
39
63
|
declare function parseWidgetAvatar(settings: WidgetSettingsRecord): WidgetAvatarConfig;
|
|
40
64
|
declare function buildWidgetConfigResponse(settings: WidgetSettingsRecord): WidgetConfigResponse;
|
|
41
65
|
/** Map widget avatar config to ThreeBeeRenderer constructor options. */
|
|
@@ -43,6 +67,17 @@ declare function resolveRendererAvatarOptions(avatar: WidgetAvatarConfig): {
|
|
|
43
67
|
avatarPreset: "bee" | AvatarPresetId;
|
|
44
68
|
assetUrl?: string;
|
|
45
69
|
};
|
|
70
|
+
type BeeVisualState = "idle" | "guiding" | "thinking" | "celebrating";
|
|
71
|
+
type AnimationSpec = {
|
|
72
|
+
kind: "css";
|
|
73
|
+
className: string | null;
|
|
74
|
+
} | {
|
|
75
|
+
kind: "lottie";
|
|
76
|
+
segment: string;
|
|
77
|
+
loop: boolean;
|
|
78
|
+
};
|
|
79
|
+
/** Per-state animation descriptor consumed by DomAvatarRenderer. */
|
|
80
|
+
declare function getAvatarStateAnimations(mode: "vector" | "lottie", motion: AvatarMotion): Record<BeeVisualState, AnimationSpec>;
|
|
46
81
|
|
|
47
82
|
/**
|
|
48
83
|
* Frozen Sprint 1 contract. Edits require joint sign-off from Track A
|
|
@@ -844,4 +879,4 @@ declare const SLO_THRESHOLDS: {
|
|
|
844
879
|
};
|
|
845
880
|
};
|
|
846
881
|
|
|
847
|
-
export { type AdminSessionSummary, type AllowedDomain, type AllowlistCheckResponse, type AnalyticsEvent, type AuditAction, type AuditEvent, type AvatarMode, type AvatarPresetId, BUDDY_TRANSITIONS, type BridgeClaims, type BridgeEnvelope, type BridgeEventType, type BuddyState, type CandidateGroup, type CaptureStatus, type CaptureSummary, type CaptureUploadEnvelope, type CaptureUploadPayload, type CaptureUploadResponse, type ChatMessage, type ChatMode, type ChatSender, type CrossSiteFlowQueueItem, type CrossSiteFlowStep, type DiffPreview, type DockInlineAnchor, type DockPositionConfig, type DockPositionPreset, type EventMetadata, type FeatureFlag, type FeatureFlagOverride, type FlowCommand, type FlowDefinition, type FlowMoveOptions, type FlowStep, type HighlightVariant, type IdentityRequest, type IdentityResponse, type IntentMatch, type KiBeePairAccept, type KiBeePairReject, type KiBeePairRequest, type MemoryRecallItem, type MemoryRecallResponse, type MemoryScope, type MessageTemplate, type PairingState, type PromoteCandidatePayload, type PushFlowRequest, type PushTargetsRequest, type RecoveryRequest, type RecoveryResponse, type RegisteredTarget, type ResolveIntentRequest, type ResolvedFlagSet, SLO_THRESHOLDS, type SessionState, type SloSnapshot, type SloWindow, type StartSessionRequest, type SurfaceId, type TargetRef, type TenantAttachPayload, type TenantFlowsResponse, type TrackEventRequest, type VisibleTarget, type VisitorIdentity, type VisitorPollResponse, type WidgetAvatarConfig, type WidgetConfig, type WidgetConfigResponse, type WidgetDockPosition, type WidgetDockPreset, type WidgetSettingsRecord, buildWidgetConfigResponse, canTransition, isAvatarMode, isAvatarPresetId, isBridgeEnvelope, parseWidgetAvatar, resolveRendererAvatarOptions };
|
|
882
|
+
export { type AdminSessionSummary, type AllowedDomain, type AllowlistCheckResponse, type AnalyticsEvent, type AnimationSpec, type AuditAction, type AuditEvent, type AvatarMode, type AvatarMotion, type AvatarPresetId, BUDDY_TRANSITIONS, type BeeVisualState, type BridgeClaims, type BridgeEnvelope, type BridgeEventType, type BuddyState, type CandidateGroup, type CaptureStatus, type CaptureSummary, type CaptureUploadEnvelope, type CaptureUploadPayload, type CaptureUploadResponse, type ChatMessage, type ChatMode, type ChatSender, type CrossSiteFlowQueueItem, type CrossSiteFlowStep, type DiffPreview, type DockInlineAnchor, type DockPositionConfig, type DockPositionPreset, type EventMetadata, type FeatureFlag, type FeatureFlagOverride, type FlowCommand, type FlowDefinition, type FlowMoveOptions, type FlowStep, type HighlightVariant, type IdentityRequest, type IdentityResponse, type IntentMatch, type KiBeePairAccept, type KiBeePairReject, type KiBeePairRequest, type MemoryRecallItem, type MemoryRecallResponse, type MemoryScope, type MessageTemplate, type PairingState, type PromoteCandidatePayload, type PushFlowRequest, type PushTargetsRequest, type RecoveryRequest, type RecoveryResponse, type RegisteredTarget, type ResolveIntentRequest, type ResolvedFlagSet, SLO_THRESHOLDS, type SessionState, type SloSnapshot, type SloWindow, type StartSessionRequest, type SurfaceId, type TargetRef, type TenantAttachPayload, type TenantFlowsResponse, type TrackEventRequest, type VisibleTarget, type VisitorIdentity, type VisitorPollResponse, WIDGET_AVATAR_LOTTIE_PROXY_PATH, WIDGET_AVATAR_PROXY_PATH, type WidgetAvatarConfig, type WidgetConfig, type WidgetConfigResponse, type WidgetDockPosition, type WidgetDockPreset, type WidgetSettingsRecord, buildWidgetConfigResponse, canTransition, getAvatarStateAnimations, isAvatarMode, isAvatarMotion, isAvatarPresetId, isBridgeEnvelope, isWidgetAvatarProxyUrl, parseWidgetAvatar, resolveRendererAvatarOptions };
|
package/dist/index.js
CHANGED
|
@@ -22,33 +22,65 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
BUDDY_TRANSITIONS: () => BUDDY_TRANSITIONS,
|
|
24
24
|
SLO_THRESHOLDS: () => SLO_THRESHOLDS,
|
|
25
|
+
WIDGET_AVATAR_LOTTIE_PROXY_PATH: () => WIDGET_AVATAR_LOTTIE_PROXY_PATH,
|
|
26
|
+
WIDGET_AVATAR_PROXY_PATH: () => WIDGET_AVATAR_PROXY_PATH,
|
|
25
27
|
buildWidgetConfigResponse: () => buildWidgetConfigResponse,
|
|
26
28
|
canTransition: () => canTransition,
|
|
29
|
+
getAvatarStateAnimations: () => getAvatarStateAnimations,
|
|
27
30
|
isAvatarMode: () => isAvatarMode,
|
|
31
|
+
isAvatarMotion: () => isAvatarMotion,
|
|
28
32
|
isAvatarPresetId: () => isAvatarPresetId,
|
|
29
33
|
isBridgeEnvelope: () => isBridgeEnvelope,
|
|
34
|
+
isWidgetAvatarProxyUrl: () => isWidgetAvatarProxyUrl,
|
|
30
35
|
parseWidgetAvatar: () => parseWidgetAvatar,
|
|
31
36
|
resolveRendererAvatarOptions: () => resolveRendererAvatarOptions
|
|
32
37
|
});
|
|
33
38
|
module.exports = __toCommonJS(index_exports);
|
|
34
39
|
|
|
35
40
|
// src/widget.ts
|
|
36
|
-
var
|
|
41
|
+
var WIDGET_AVATAR_PROXY_PATH = "/widget-avatar";
|
|
42
|
+
var WIDGET_AVATAR_LOTTIE_PROXY_PATH = "/widget-avatar?type=lottie";
|
|
43
|
+
var AVATAR_MODES = ["default", "preset", "custom", "vector", "lottie"];
|
|
37
44
|
var AVATAR_PRESETS = ["orb", "ring"];
|
|
45
|
+
var AVATAR_MOTIONS = ["breathe", "pulse", "spin", "none"];
|
|
38
46
|
function isAvatarMode(value) {
|
|
39
47
|
return typeof value === "string" && AVATAR_MODES.includes(value);
|
|
40
48
|
}
|
|
41
49
|
function isAvatarPresetId(value) {
|
|
42
50
|
return typeof value === "string" && AVATAR_PRESETS.includes(value);
|
|
43
51
|
}
|
|
52
|
+
function isAvatarMotion(value) {
|
|
53
|
+
return typeof value === "string" && AVATAR_MOTIONS.includes(value);
|
|
54
|
+
}
|
|
55
|
+
function isWidgetAvatarProxyUrl(url) {
|
|
56
|
+
const trimmed = url.trim();
|
|
57
|
+
return trimmed === WIDGET_AVATAR_PROXY_PATH || trimmed.endsWith(WIDGET_AVATAR_PROXY_PATH);
|
|
58
|
+
}
|
|
44
59
|
function parseWidgetAvatar(settings) {
|
|
45
60
|
const mode = isAvatarMode(settings.avatarMode) ? settings.avatarMode : "default";
|
|
61
|
+
const motion = isAvatarMotion(settings.avatarMotion) ? settings.avatarMotion : "breathe";
|
|
46
62
|
if (mode === "preset") {
|
|
47
63
|
const preset = isAvatarPresetId(settings.avatarPreset) ? settings.avatarPreset : "orb";
|
|
48
64
|
return { mode, preset };
|
|
49
65
|
}
|
|
50
|
-
if (mode === "custom"
|
|
51
|
-
|
|
66
|
+
if (mode === "custom") {
|
|
67
|
+
const assetKey = typeof settings.avatarAssetKey === "string" ? settings.avatarAssetKey.trim() : "";
|
|
68
|
+
if (assetKey) return { mode, assetUrl: WIDGET_AVATAR_PROXY_PATH };
|
|
69
|
+
if (typeof settings.avatarAssetUrl === "string" && settings.avatarAssetUrl.trim()) {
|
|
70
|
+
return { mode, assetUrl: settings.avatarAssetUrl.trim() };
|
|
71
|
+
}
|
|
72
|
+
return { mode: "default" };
|
|
73
|
+
}
|
|
74
|
+
if (mode === "vector") {
|
|
75
|
+
const svg = typeof settings.avatarSvg === "string" ? settings.avatarSvg.trim() : "";
|
|
76
|
+
if (!svg) return { mode: "default" };
|
|
77
|
+
const color = typeof settings.avatarColor === "string" && settings.avatarColor.trim() ? settings.avatarColor.trim() : void 0;
|
|
78
|
+
return color ? { mode, svg, motion, color } : { mode, svg, motion };
|
|
79
|
+
}
|
|
80
|
+
if (mode === "lottie") {
|
|
81
|
+
const key = typeof settings.avatarLottieKey === "string" ? settings.avatarLottieKey.trim() : "";
|
|
82
|
+
if (!key) return { mode: "default" };
|
|
83
|
+
return { mode, assetUrl: WIDGET_AVATAR_LOTTIE_PROXY_PATH, motion };
|
|
52
84
|
}
|
|
53
85
|
return { mode: "default" };
|
|
54
86
|
}
|
|
@@ -67,14 +99,27 @@ function buildWidgetConfigResponse(settings) {
|
|
|
67
99
|
};
|
|
68
100
|
}
|
|
69
101
|
function resolveRendererAvatarOptions(avatar) {
|
|
70
|
-
if (avatar.mode === "preset"
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
if (avatar.mode === "custom" && avatar.assetUrl) {
|
|
74
|
-
return { avatarPreset: "bee", assetUrl: avatar.assetUrl };
|
|
75
|
-
}
|
|
102
|
+
if (avatar.mode === "preset") return { avatarPreset: avatar.preset };
|
|
103
|
+
if (avatar.mode === "custom") return { avatarPreset: "bee", assetUrl: avatar.assetUrl };
|
|
76
104
|
return { avatarPreset: "bee" };
|
|
77
105
|
}
|
|
106
|
+
function getAvatarStateAnimations(mode, motion) {
|
|
107
|
+
if (mode === "lottie") {
|
|
108
|
+
return {
|
|
109
|
+
idle: { kind: "lottie", segment: "idle", loop: true },
|
|
110
|
+
guiding: { kind: "lottie", segment: "idle", loop: true },
|
|
111
|
+
thinking: { kind: "lottie", segment: "thinking", loop: true },
|
|
112
|
+
celebrating: { kind: "lottie", segment: "celebrate", loop: false }
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
const idleClass = motion === "none" ? null : `kibee-2d-motion--${motion}`;
|
|
116
|
+
return {
|
|
117
|
+
idle: { kind: "css", className: idleClass },
|
|
118
|
+
guiding: { kind: "css", className: "kibee-2d-state--guiding" },
|
|
119
|
+
thinking: { kind: "css", className: "kibee-2d-state--thinking" },
|
|
120
|
+
celebrating: { kind: "css", className: "kibee-2d-state--celebrating" }
|
|
121
|
+
};
|
|
122
|
+
}
|
|
78
123
|
|
|
79
124
|
// src/bridge.ts
|
|
80
125
|
var SURFACE_IDS = /* @__PURE__ */ new Set(["web", "extension", "desktop"]);
|
|
@@ -130,11 +175,16 @@ var SLO_THRESHOLDS = {
|
|
|
130
175
|
0 && (module.exports = {
|
|
131
176
|
BUDDY_TRANSITIONS,
|
|
132
177
|
SLO_THRESHOLDS,
|
|
178
|
+
WIDGET_AVATAR_LOTTIE_PROXY_PATH,
|
|
179
|
+
WIDGET_AVATAR_PROXY_PATH,
|
|
133
180
|
buildWidgetConfigResponse,
|
|
134
181
|
canTransition,
|
|
182
|
+
getAvatarStateAnimations,
|
|
135
183
|
isAvatarMode,
|
|
184
|
+
isAvatarMotion,
|
|
136
185
|
isAvatarPresetId,
|
|
137
186
|
isBridgeEnvelope,
|
|
187
|
+
isWidgetAvatarProxyUrl,
|
|
138
188
|
parseWidgetAvatar,
|
|
139
189
|
resolveRendererAvatarOptions
|
|
140
190
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,20 +1,47 @@
|
|
|
1
1
|
// src/widget.ts
|
|
2
|
-
var
|
|
2
|
+
var WIDGET_AVATAR_PROXY_PATH = "/widget-avatar";
|
|
3
|
+
var WIDGET_AVATAR_LOTTIE_PROXY_PATH = "/widget-avatar?type=lottie";
|
|
4
|
+
var AVATAR_MODES = ["default", "preset", "custom", "vector", "lottie"];
|
|
3
5
|
var AVATAR_PRESETS = ["orb", "ring"];
|
|
6
|
+
var AVATAR_MOTIONS = ["breathe", "pulse", "spin", "none"];
|
|
4
7
|
function isAvatarMode(value) {
|
|
5
8
|
return typeof value === "string" && AVATAR_MODES.includes(value);
|
|
6
9
|
}
|
|
7
10
|
function isAvatarPresetId(value) {
|
|
8
11
|
return typeof value === "string" && AVATAR_PRESETS.includes(value);
|
|
9
12
|
}
|
|
13
|
+
function isAvatarMotion(value) {
|
|
14
|
+
return typeof value === "string" && AVATAR_MOTIONS.includes(value);
|
|
15
|
+
}
|
|
16
|
+
function isWidgetAvatarProxyUrl(url) {
|
|
17
|
+
const trimmed = url.trim();
|
|
18
|
+
return trimmed === WIDGET_AVATAR_PROXY_PATH || trimmed.endsWith(WIDGET_AVATAR_PROXY_PATH);
|
|
19
|
+
}
|
|
10
20
|
function parseWidgetAvatar(settings) {
|
|
11
21
|
const mode = isAvatarMode(settings.avatarMode) ? settings.avatarMode : "default";
|
|
22
|
+
const motion = isAvatarMotion(settings.avatarMotion) ? settings.avatarMotion : "breathe";
|
|
12
23
|
if (mode === "preset") {
|
|
13
24
|
const preset = isAvatarPresetId(settings.avatarPreset) ? settings.avatarPreset : "orb";
|
|
14
25
|
return { mode, preset };
|
|
15
26
|
}
|
|
16
|
-
if (mode === "custom"
|
|
17
|
-
|
|
27
|
+
if (mode === "custom") {
|
|
28
|
+
const assetKey = typeof settings.avatarAssetKey === "string" ? settings.avatarAssetKey.trim() : "";
|
|
29
|
+
if (assetKey) return { mode, assetUrl: WIDGET_AVATAR_PROXY_PATH };
|
|
30
|
+
if (typeof settings.avatarAssetUrl === "string" && settings.avatarAssetUrl.trim()) {
|
|
31
|
+
return { mode, assetUrl: settings.avatarAssetUrl.trim() };
|
|
32
|
+
}
|
|
33
|
+
return { mode: "default" };
|
|
34
|
+
}
|
|
35
|
+
if (mode === "vector") {
|
|
36
|
+
const svg = typeof settings.avatarSvg === "string" ? settings.avatarSvg.trim() : "";
|
|
37
|
+
if (!svg) return { mode: "default" };
|
|
38
|
+
const color = typeof settings.avatarColor === "string" && settings.avatarColor.trim() ? settings.avatarColor.trim() : void 0;
|
|
39
|
+
return color ? { mode, svg, motion, color } : { mode, svg, motion };
|
|
40
|
+
}
|
|
41
|
+
if (mode === "lottie") {
|
|
42
|
+
const key = typeof settings.avatarLottieKey === "string" ? settings.avatarLottieKey.trim() : "";
|
|
43
|
+
if (!key) return { mode: "default" };
|
|
44
|
+
return { mode, assetUrl: WIDGET_AVATAR_LOTTIE_PROXY_PATH, motion };
|
|
18
45
|
}
|
|
19
46
|
return { mode: "default" };
|
|
20
47
|
}
|
|
@@ -33,14 +60,27 @@ function buildWidgetConfigResponse(settings) {
|
|
|
33
60
|
};
|
|
34
61
|
}
|
|
35
62
|
function resolveRendererAvatarOptions(avatar) {
|
|
36
|
-
if (avatar.mode === "preset"
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
if (avatar.mode === "custom" && avatar.assetUrl) {
|
|
40
|
-
return { avatarPreset: "bee", assetUrl: avatar.assetUrl };
|
|
41
|
-
}
|
|
63
|
+
if (avatar.mode === "preset") return { avatarPreset: avatar.preset };
|
|
64
|
+
if (avatar.mode === "custom") return { avatarPreset: "bee", assetUrl: avatar.assetUrl };
|
|
42
65
|
return { avatarPreset: "bee" };
|
|
43
66
|
}
|
|
67
|
+
function getAvatarStateAnimations(mode, motion) {
|
|
68
|
+
if (mode === "lottie") {
|
|
69
|
+
return {
|
|
70
|
+
idle: { kind: "lottie", segment: "idle", loop: true },
|
|
71
|
+
guiding: { kind: "lottie", segment: "idle", loop: true },
|
|
72
|
+
thinking: { kind: "lottie", segment: "thinking", loop: true },
|
|
73
|
+
celebrating: { kind: "lottie", segment: "celebrate", loop: false }
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const idleClass = motion === "none" ? null : `kibee-2d-motion--${motion}`;
|
|
77
|
+
return {
|
|
78
|
+
idle: { kind: "css", className: idleClass },
|
|
79
|
+
guiding: { kind: "css", className: "kibee-2d-state--guiding" },
|
|
80
|
+
thinking: { kind: "css", className: "kibee-2d-state--thinking" },
|
|
81
|
+
celebrating: { kind: "css", className: "kibee-2d-state--celebrating" }
|
|
82
|
+
};
|
|
83
|
+
}
|
|
44
84
|
|
|
45
85
|
// src/bridge.ts
|
|
46
86
|
var SURFACE_IDS = /* @__PURE__ */ new Set(["web", "extension", "desktop"]);
|
|
@@ -95,11 +135,16 @@ var SLO_THRESHOLDS = {
|
|
|
95
135
|
export {
|
|
96
136
|
BUDDY_TRANSITIONS,
|
|
97
137
|
SLO_THRESHOLDS,
|
|
138
|
+
WIDGET_AVATAR_LOTTIE_PROXY_PATH,
|
|
139
|
+
WIDGET_AVATAR_PROXY_PATH,
|
|
98
140
|
buildWidgetConfigResponse,
|
|
99
141
|
canTransition,
|
|
142
|
+
getAvatarStateAnimations,
|
|
100
143
|
isAvatarMode,
|
|
144
|
+
isAvatarMotion,
|
|
101
145
|
isAvatarPresetId,
|
|
102
146
|
isBridgeEnvelope,
|
|
147
|
+
isWidgetAvatarProxyUrl,
|
|
103
148
|
parseWidgetAvatar,
|
|
104
149
|
resolveRendererAvatarOptions
|
|
105
150
|
};
|