@alxxsck/ai-assistant 3.2.0 → 3.3.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/README.md +11 -9
- package/dist/{Avatar-xR6pNtqs.js → Avatar-5O8HyYPY.js} +7 -2
- package/dist/ChatWidgetContent-CPYrjWPG.js +4772 -0
- package/dist/avatar/Avatar.d.ts +1 -1
- package/dist/bridge-ai-chat-widget.es.js +1 -1
- package/dist/context/ChatWidgetContext.d.ts +7 -0
- package/dist/domain/command/CommandRuntime.d.ts +3 -2
- package/dist/domain/command/UiCommandService.d.ts +2 -1
- package/dist/domain/command/command.types.d.ts +10 -0
- package/dist/domain/ui/assistant-surface.d.ts +32 -0
- package/dist/domain/ui/widget-geometry.d.ts +10 -0
- package/dist/i18n/messages.d.ts +1 -0
- package/dist/{index-C_7vxlzf.js → index-C6_FMpJa.js} +49 -27
- package/dist/{mount-B0T35SHn.js → mount-B4JOSFpY.js} +7287 -6109
- package/dist/ui/components/ChatWidgetFrame.d.ts +5 -1
- package/dist/ui/components/CompactAssistantSurface.d.ts +6 -0
- package/dist/ui/components/CompactScenarioPreview.d.ts +1 -0
- package/dist/ui/components/VoiceMicOrb.d.ts +18 -0
- package/dist/ui/hooks/useVoiceInputAura.d.ts +22 -0
- package/package.json +1 -1
- package/dist/ChatWidgetContent-sbqtMuIT.js +0 -5379
package/dist/avatar/Avatar.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ type CameraParams = {
|
|
|
9
9
|
lookAt: Vector3;
|
|
10
10
|
fov: number;
|
|
11
11
|
};
|
|
12
|
-
export type AvatarFramingMode = "default" | "chat-surface";
|
|
12
|
+
export type AvatarFramingMode = "default" | "compact-assistant" | "chat-surface";
|
|
13
13
|
export declare class Avatar extends EventTarget {
|
|
14
14
|
private canvas;
|
|
15
15
|
private videoContainer;
|
|
@@ -5,10 +5,17 @@ import type { CtaActionExecutionResult, CtaCommandContext } from "@/domain/comma
|
|
|
5
5
|
import type { SurfaceTransitionContext } from "@/domain/scenario-interaction/scenario-interaction.types";
|
|
6
6
|
import type { SurfaceFocusDisposition } from "@/domain/scenario-interaction/scenario-interaction.types";
|
|
7
7
|
import { CompactPreviewController } from "@/domain/compact-preview/CompactPreviewController";
|
|
8
|
+
import { type AssistantSurfaceMode, type AssistantOpenSurfaceMode } from "@/domain/ui/assistant-surface";
|
|
8
9
|
type ChatWidgetContextValue = {
|
|
9
10
|
open: boolean;
|
|
11
|
+
assistantSurfaceMode: AssistantSurfaceMode;
|
|
12
|
+
assistantLastOpenMode: AssistantOpenSurfaceMode;
|
|
10
13
|
setOpen: (v: boolean) => void;
|
|
11
14
|
transitionSurface: (open: boolean, context: SurfaceTransitionContext) => void;
|
|
15
|
+
restoreAssistant: (context: SurfaceTransitionContext) => void;
|
|
16
|
+
openFullAssistant: (context: SurfaceTransitionContext) => void;
|
|
17
|
+
minimizeAssistant: (context: SurfaceTransitionContext) => void;
|
|
18
|
+
closeAssistant: (context: SurfaceTransitionContext) => void;
|
|
12
19
|
openCompactPreview: (context: SurfaceTransitionContext) => Promise<boolean> | null;
|
|
13
20
|
surfaceEpisodeId: string | null;
|
|
14
21
|
closeFocusDisposition: SurfaceFocusDisposition;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CustomerInteractionSession } from "@/types";
|
|
2
|
-
import { type CommandAck, type CommandEnvelope, type CommandEventDetail, type CtaActionExecutionResult, type CtaCommandContext, type HostCommandHandlerName, type HostCommandHandlers, type SpeakTextCommandContext, type StartVoiceConversationCommandContext, type
|
|
2
|
+
import { type CommandAck, type CommandEnvelope, type CommandEventDetail, type CtaActionExecutionResult, type CtaCommandContext, type HostCommandHandlerName, type HostCommandHandlers, type SpeakTextCommandContext, type StartVoiceConversationCommandContext, type UiActionPresentationSnapshot, type UiActionPolicies, type UiTarget } from "./command.types";
|
|
3
3
|
import type { ScenarioInteractionRuntime } from "@/domain/scenario-interaction/ScenarioInteractionRuntime";
|
|
4
4
|
type AckSender = (ack: CommandAck) => Promise<unknown>;
|
|
5
5
|
type UiActionInvocation = "COMMAND" | "CTA";
|
|
@@ -15,7 +15,7 @@ type InternalHandlers = {
|
|
|
15
15
|
connectTelegram?: (context: CtaCommandContext) => CtaActionExecutionResult | Promise<CtaActionExecutionResult>;
|
|
16
16
|
speakText?: (context: SpeakTextCommandContext) => void | Promise<void>;
|
|
17
17
|
startVoiceConversation?: (context: StartVoiceConversationCommandContext) => void | Promise<void>;
|
|
18
|
-
prepareUiActionHandoff?: (action: Readonly<
|
|
18
|
+
prepareUiActionHandoff?: (action: Readonly<UiActionPresentationSnapshot>, commandId: string, invocation: UiActionInvocation) => UiActionPresentationHandoff | undefined;
|
|
19
19
|
};
|
|
20
20
|
export declare class CommandRuntime {
|
|
21
21
|
private readonly onStatus?;
|
|
@@ -47,6 +47,7 @@ export declare class CommandRuntime {
|
|
|
47
47
|
executeCtaAction(context: CtaCommandContext): Promise<CtaActionExecutionResult>;
|
|
48
48
|
private executeCtaActionOnce;
|
|
49
49
|
private executeUiAction;
|
|
50
|
+
private executeWithUiActionHandoff;
|
|
50
51
|
private retainCtaAction;
|
|
51
52
|
destroy(): void;
|
|
52
53
|
private executeOnce;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HostCommandHandlerName, HostCommandHandlers, UiCommandActionSnapshot, UiCommandTarget, UiActionPolicies, UiTarget } from "./command.types";
|
|
1
|
+
import type { HighlightActionPresentationSnapshot, HostCommandHandlerName, HostCommandHandlers, UiCommandActionSnapshot, UiCommandTarget, UiActionPolicies, UiTarget } from "./command.types";
|
|
2
2
|
type NavigationCommandType = "open_page" | "open_modal";
|
|
3
3
|
export declare class UiCommandService {
|
|
4
4
|
private readonly actionPolicies;
|
|
@@ -10,6 +10,7 @@ export declare class UiCommandService {
|
|
|
10
10
|
getHandler<K extends HostCommandHandlerName>(name: K): HostCommandHandlers[K];
|
|
11
11
|
registerHandler<K extends HostCommandHandlerName>(name: K, handler: NonNullable<HostCommandHandlers[K]>): () => void;
|
|
12
12
|
resolveAction(commandType: NavigationCommandType, payload: Readonly<Record<string, unknown>>, target?: UiCommandTarget): Readonly<UiCommandActionSnapshot>;
|
|
13
|
+
resolveHighlightPresentation(code: string): Readonly<HighlightActionPresentationSnapshot>;
|
|
13
14
|
execute(commandType: NavigationCommandType, commandId: string, payload: Readonly<Record<string, unknown>>, target?: UiCommandTarget): Promise<void>;
|
|
14
15
|
executeAction(action: Readonly<UiCommandActionSnapshot>, commandId: string, payload: Readonly<Record<string, unknown>>): Promise<void>;
|
|
15
16
|
canExecute(action: Readonly<UiCommandActionSnapshot>): boolean;
|
|
@@ -47,6 +47,10 @@ export type UiTargetKind = "button" | "element" | "modal" | "page";
|
|
|
47
47
|
export declare const MOBILE_ACTION_DISPOSITIONS: readonly ["keep", "collapseOnSuccess", "immersive"];
|
|
48
48
|
export type MobileActionDisposition = (typeof MOBILE_ACTION_DISPOSITIONS)[number];
|
|
49
49
|
export type UiActionPolicy = {
|
|
50
|
+
/**
|
|
51
|
+
* Compatibility field name. The disposition is applied to the assistant
|
|
52
|
+
* surface after a successful UI action at every viewport size.
|
|
53
|
+
*/
|
|
50
54
|
mobileDisposition: MobileActionDisposition;
|
|
51
55
|
};
|
|
52
56
|
export type UiActionPolicies = Readonly<Record<string, UiActionPolicy>>;
|
|
@@ -96,6 +100,12 @@ export type UiCommandActionSnapshot = {
|
|
|
96
100
|
selector?: string;
|
|
97
101
|
target?: ModalCommandTarget;
|
|
98
102
|
};
|
|
103
|
+
export type HighlightActionPresentationSnapshot = {
|
|
104
|
+
kind: "element";
|
|
105
|
+
code: string;
|
|
106
|
+
mobileDisposition: MobileActionDisposition;
|
|
107
|
+
};
|
|
108
|
+
export type UiActionPresentationSnapshot = UiCommandActionSnapshot | HighlightActionPresentationSnapshot;
|
|
99
109
|
export type HighlightCommandContext = HostCommandContext & {
|
|
100
110
|
active: boolean;
|
|
101
111
|
element?: Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type AssistantSurfaceMode = "CLOSED" | "COMPACT" | "FULL";
|
|
2
|
+
export type AssistantOpenSurfaceMode = Exclude<AssistantSurfaceMode, "CLOSED">;
|
|
3
|
+
export type AssistantSurfaceState = Readonly<{
|
|
4
|
+
mode: AssistantSurfaceMode;
|
|
5
|
+
lastOpenMode: AssistantOpenSurfaceMode;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const assistantSurfaceActions: {
|
|
8
|
+
restore: () => {
|
|
9
|
+
readonly type: "RESTORE";
|
|
10
|
+
};
|
|
11
|
+
openCompact: () => {
|
|
12
|
+
readonly type: "OPEN_COMPACT";
|
|
13
|
+
};
|
|
14
|
+
openFull: () => {
|
|
15
|
+
readonly type: "OPEN_FULL";
|
|
16
|
+
};
|
|
17
|
+
minimize: () => {
|
|
18
|
+
readonly type: "MINIMIZE";
|
|
19
|
+
};
|
|
20
|
+
close: () => {
|
|
21
|
+
readonly type: "CLOSE";
|
|
22
|
+
};
|
|
23
|
+
setLegacyOpen: (open: boolean) => {
|
|
24
|
+
readonly type: "SET_LEGACY_OPEN";
|
|
25
|
+
readonly open: boolean;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export type AssistantSurfaceAction = ReturnType<(typeof assistantSurfaceActions)[keyof typeof assistantSurfaceActions]>;
|
|
29
|
+
export declare function createAssistantSurfaceState(lastOpenMode?: AssistantOpenSurfaceMode): AssistantSurfaceState;
|
|
30
|
+
export declare function assistantSurfaceReducer(state: AssistantSurfaceState, action: AssistantSurfaceAction): AssistantSurfaceState;
|
|
31
|
+
/** Compatibility selector for consumers where `open` means the full chat UI. */
|
|
32
|
+
export declare function isLegacyAssistantSurfaceOpen(state: AssistantSurfaceState): boolean;
|
|
@@ -39,12 +39,22 @@ export declare const DEFAULT_WIDGET_WIDTH: number;
|
|
|
39
39
|
export declare const COMPACT_PREVIEW_MAX_WIDTH = 320;
|
|
40
40
|
export declare const COMPACT_PREVIEW_MARGIN = 12;
|
|
41
41
|
export declare const COMPACT_PREVIEW_GAP = 12;
|
|
42
|
+
export declare const COMPACT_ASSISTANT_WIDTH = 164;
|
|
43
|
+
export declare const COMPACT_ASSISTANT_HEIGHT = 220;
|
|
42
44
|
export declare function getViewport(): Viewport;
|
|
43
45
|
export declare function insetViewport(viewport: Viewport, insets: ViewportInsets): Viewport;
|
|
44
46
|
export declare function getDefaultLauncherPosition(viewport: Viewport): Point;
|
|
45
47
|
export declare function dockLauncherPosition(point: Point, viewport: Viewport): DockedLauncher;
|
|
46
48
|
export declare function launcherPointFromDock(launcher: DockedLauncher, viewport: Viewport): Point;
|
|
47
49
|
export declare function clampLauncherPosition(point: Point, viewport: Viewport): Point;
|
|
50
|
+
/**
|
|
51
|
+
* Resolves the compact assistant from the same side/y docking preference as
|
|
52
|
+
* the launcher. This lets both surfaces share one persisted position without
|
|
53
|
+
* leaking the compact surface's fixed dimensions into the full chat panel.
|
|
54
|
+
*/
|
|
55
|
+
export declare function compactAssistantRectFromDock(dock: DockedLauncher, viewport: Viewport): Rect;
|
|
56
|
+
export declare function clampCompactAssistantRect(rect: Rect, viewport: Viewport): Rect;
|
|
57
|
+
export declare function dockCompactAssistantRect(rect: Rect, viewport: Viewport): DockedLauncher;
|
|
48
58
|
export declare function clampPanelRect(rect: Rect, viewport: Viewport): Rect;
|
|
49
59
|
export declare function dockPanelRect(rect: Rect, viewport: Viewport): Rect;
|
|
50
60
|
export declare function dockPanelRectToSide(rect: Rect, viewport: Viewport, side: LauncherSide): Rect;
|
package/dist/i18n/messages.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ declare const en: {
|
|
|
78
78
|
readonly decline: "Decline";
|
|
79
79
|
readonly muteMicrophone: "Mute microphone";
|
|
80
80
|
readonly unmuteMicrophone: "Unmute microphone";
|
|
81
|
+
readonly endConversation: "End voice chat";
|
|
81
82
|
readonly switchToText: "Switch to text chat";
|
|
82
83
|
readonly audioPlaybackFailed: "Couldn't play the assistant's voice.";
|
|
83
84
|
readonly sessionFailed: "Voice conversation failed.";
|