@alxxsck/ai-assistant 3.0.0 → 3.1.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.
@@ -31,7 +31,8 @@ export type MessageDelivery = {
31
31
  export declare enum MessageStatus {
32
32
  Completed = "MESSAGE_STATUS_COMPLETED",
33
33
  Writing = "MESSAGE_STATUS_WRITING",
34
- Failed = "MESSAGE_STATUS_FAILED"
34
+ Failed = "MESSAGE_STATUS_FAILED",
35
+ Cancelled = "MESSAGE_STATUS_CANCELLED"
35
36
  }
36
37
  export type CustomerContent = {
37
38
  text: string;
@@ -1,4 +1,4 @@
1
- import { C as A, E as e, S as s, d as E, c } from "./index-DY_Y_QHI.js";
1
+ import { C as A, E as e, S as s, d as E, c } from "./index-DCsPGgIk.js";
2
2
  export {
3
3
  A as ChatWidgetInstance,
4
4
  e as EXTERNALLY_AVAILABLE_ACTIONS,
@@ -3,6 +3,7 @@ import type { Avatar } from "@/avatar/Avatar";
3
3
  import type { WidgetConfig } from "@/index.types";
4
4
  import type { CtaActionExecutionResult, CtaCommandContext } from "@/domain/command/command.types";
5
5
  import type { SurfaceTransitionContext } from "@/domain/scenario-interaction/scenario-interaction.types";
6
+ import type { SurfaceFocusDisposition } from "@/domain/scenario-interaction/scenario-interaction.types";
6
7
  import { CompactPreviewController } from "@/domain/compact-preview/CompactPreviewController";
7
8
  type ChatWidgetContextValue = {
8
9
  open: boolean;
@@ -10,6 +11,8 @@ type ChatWidgetContextValue = {
10
11
  transitionSurface: (open: boolean, context: SurfaceTransitionContext) => void;
11
12
  openCompactPreview: (context: SurfaceTransitionContext) => Promise<boolean> | null;
12
13
  surfaceEpisodeId: string | null;
14
+ closeFocusDisposition: SurfaceFocusDisposition;
15
+ uiActionHandoffPending: boolean;
13
16
  contentActivated: boolean;
14
17
  isAvatarCoveredByChatList: boolean;
15
18
  setAvatarCoveredByChatList: (covered: boolean) => void;
@@ -1,7 +1,12 @@
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 UiTarget } from "./command.types";
2
+ import { type CommandAck, type CommandEnvelope, type CommandEventDetail, type CtaActionExecutionResult, type CtaCommandContext, type HostCommandHandlerName, type HostCommandHandlers, type SpeakTextCommandContext, type StartVoiceConversationCommandContext, type UiCommandActionSnapshot, 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
+ type UiActionInvocation = "COMMAND" | "CTA";
6
+ type UiActionPresentationHandoff = {
7
+ complete: () => void;
8
+ cancel: () => void;
9
+ };
5
10
  type InternalHandlers = {
6
11
  setAssistantVisible?: (visible: boolean, commandId: string) => void;
7
12
  setChatOpen?: (open: boolean, commandId: string) => void | Promise<void>;
@@ -10,6 +15,7 @@ type InternalHandlers = {
10
15
  connectTelegram?: (context: CtaCommandContext) => CtaActionExecutionResult | Promise<CtaActionExecutionResult>;
11
16
  speakText?: (context: SpeakTextCommandContext) => void | Promise<void>;
12
17
  startVoiceConversation?: (context: StartVoiceConversationCommandContext) => void | Promise<void>;
18
+ prepareUiActionHandoff?: (action: Readonly<UiCommandActionSnapshot>, commandId: string, invocation: UiActionInvocation) => UiActionPresentationHandoff | undefined;
13
19
  };
14
20
  export declare class CommandRuntime {
15
21
  private readonly onStatus?;
@@ -32,7 +38,7 @@ export declare class CommandRuntime {
32
38
  private principalSessionId;
33
39
  private principalGeneration;
34
40
  private destroyed;
35
- constructor(targets?: Record<string, UiTarget>, handlers?: HostCommandHandlers, onStatus?: ((detail: CommandEventDetail) => void) | undefined, scenarioInteractions?: ScenarioInteractionRuntime | undefined);
41
+ constructor(targets?: Record<string, UiTarget>, handlers?: HostCommandHandlers, onStatus?: ((detail: CommandEventDetail) => void) | undefined, scenarioInteractions?: ScenarioInteractionRuntime | undefined, actionPolicies?: UiActionPolicies);
36
42
  registerTarget(code: string, target: UiTarget): () => void;
37
43
  registerHostHandler<K extends HostCommandHandlerName>(name: K, handler: NonNullable<HostCommandHandlers[K]>): () => void;
38
44
  setInternalHandlers(handlers: InternalHandlers): () => void;
@@ -40,6 +46,7 @@ export declare class CommandRuntime {
40
46
  updateSession(session: CustomerInteractionSession): void;
41
47
  executeCtaAction(context: CtaCommandContext): Promise<CtaActionExecutionResult>;
42
48
  private executeCtaActionOnce;
49
+ private executeUiAction;
43
50
  private retainCtaAction;
44
51
  destroy(): void;
45
52
  private executeOnce;
@@ -1,9 +1,10 @@
1
- import type { HostCommandHandlerName, HostCommandHandlers, UiCommandActionSnapshot, UiCommandTarget, UiTarget } from "./command.types";
1
+ import type { HostCommandHandlerName, HostCommandHandlers, UiCommandActionSnapshot, UiCommandTarget, UiActionPolicies, UiTarget } from "./command.types";
2
2
  type NavigationCommandType = "open_page" | "open_modal";
3
3
  export declare class UiCommandService {
4
+ private readonly actionPolicies;
4
5
  private readonly targets;
5
6
  private readonly handlers;
6
- constructor(targets?: Record<string, UiTarget>, handlers?: HostCommandHandlers);
7
+ constructor(targets?: Record<string, UiTarget>, handlers?: HostCommandHandlers, actionPolicies?: UiActionPolicies);
7
8
  registerTarget(code: string, target: UiTarget): () => void;
8
9
  getTarget(code: string): UiTarget | undefined;
9
10
  getHandler<K extends HostCommandHandlerName>(name: K): HostCommandHandlers[K];
@@ -16,6 +17,7 @@ export declare class UiCommandService {
16
17
  private resolveLegacyAction;
17
18
  private assertLegacyTarget;
18
19
  private targetUrl;
20
+ private mobileDisposition;
19
21
  private applyUrlFallback;
20
22
  private isSameOriginUrl;
21
23
  private requireNonEmptyString;
@@ -44,6 +44,12 @@ export type ElementCommandTarget = {
44
44
  };
45
45
  export type UiCommandTarget = PageCommandTarget | ModalCommandTarget | ElementCommandTarget;
46
46
  export type UiTargetKind = "button" | "element" | "modal" | "page";
47
+ export declare const MOBILE_ACTION_DISPOSITIONS: readonly ["keep", "collapseOnSuccess", "immersive"];
48
+ export type MobileActionDisposition = (typeof MOBILE_ACTION_DISPOSITIONS)[number];
49
+ export type UiActionPolicy = {
50
+ mobileDisposition: MobileActionDisposition;
51
+ };
52
+ export type UiActionPolicies = Readonly<Record<string, UiActionPolicy>>;
47
53
  export type UiTarget = {
48
54
  kind: UiTargetKind;
49
55
  /** Trusted selector supplied by the host application. */
@@ -79,10 +85,12 @@ export type UiCommandActionSnapshot = {
79
85
  kind: "page";
80
86
  code: string;
81
87
  route: string;
88
+ mobileDisposition: MobileActionDisposition;
82
89
  target?: PageCommandTarget;
83
90
  } | {
84
91
  kind: "modal";
85
92
  code: string;
93
+ mobileDisposition: MobileActionDisposition;
86
94
  modalName?: string;
87
95
  url?: string;
88
96
  selector?: string;
@@ -13,6 +13,7 @@ interface CableContextType {
13
13
  anycableService: AnyCableService | null;
14
14
  endUserTypingClient: EndUserTypingClient;
15
15
  networkStatus: NetworkStatus;
16
+ networkStatusChangedAt: number;
16
17
  scenarioChoiceSubmissionController: ScenarioChoiceSubmissionController;
17
18
  }
18
19
  export type CableServiceFactory = (url: string, onMessage?: (message: unknown) => void, onAuthenticationError?: () => void) => AnyCableService;
@@ -44,6 +44,7 @@ export type MessageStore = {
44
44
  threads: Map<string, MessageData[]>;
45
45
  threadsPreviews: ThreadSummary[];
46
46
  sendError: string | null;
47
+ sendErrorOccurredAt: number | null;
47
48
  config: WidgetConfig | null;
48
49
  api: AppApi | null;
49
50
  latestReadMessageDate: string | null;
@@ -57,6 +58,7 @@ export type MessageStore = {
57
58
  pendingCustomerMessage: PendingCustomerMessage | null;
58
59
  responsePhase: AgentResponsePhase;
59
60
  sendInFlight: boolean;
61
+ isCreatingConversation: boolean;
60
62
  typingByConversation: Map<string, ChatTypingState>;
61
63
  concealedConversationIds: Set<string>;
62
64
  concealedMessageIds: Set<string>;
@@ -130,10 +132,12 @@ export declare const useLatestMessageDate: () => string | null;
130
132
  export declare const useConversationNavigationRequest: () => ConversationNavigationRequest | null;
131
133
  export declare const useScenarioChoiceSubmissionResult: (clientEventId?: string) => ScenarioChoiceSubmissionResult | undefined;
132
134
  export declare const useSendError: () => string | null;
135
+ export declare const useSendErrorOccurredAt: () => number | null;
133
136
  export declare const selectIsCurrentThreadLoading: (state: MessageStore) => boolean;
134
137
  export declare const useIsCurrentThreadLoading: () => boolean;
135
138
  export declare const useIsAwaitingFirstToken: () => boolean;
136
139
  export declare const useIsResponseActive: () => boolean;
140
+ export declare const useIsCreatingConversation: () => boolean;
137
141
  export declare const selectCurrentThreadPendingCustomerMessage: (state: MessageStore) => PendingCustomerMessage | null;
138
142
  export declare const usePendingCustomerMessage: () => PendingCustomerMessage | null;
139
143
  export declare const useMessageStream: (messageId: string) => MessageStreamState | undefined;
@@ -59,10 +59,13 @@ export type SurfaceState = "OPEN" | "CLOSED";
59
59
  export type SurfaceTransitionActor = ScenarioInteractionActor | "SYSTEM";
60
60
  /** Exact SDK-local reasons; state-changing reasons are preserved on the wire. */
61
61
  export type SurfaceTransitionReason = "USER_LAUNCHER" | "USER_CLOSE_BUTTON" | "VOICE_SWITCH_TO_TEXT" | "HOST_SET_OPEN" | "SCENARIO_COMMAND" | "SYSTEM_RESTORE";
62
+ export type SurfaceFocusDisposition = "RETURN_TO_LAUNCHER" | "PRESERVE_HOST";
62
63
  export type SurfaceTransitionContext = {
63
64
  actor: SurfaceTransitionActor;
64
65
  reason: SurfaceTransitionReason;
65
66
  sourceCommandId?: string;
67
+ /** Local focus ownership; it is never serialized to interaction observations. */
68
+ focusDisposition?: SurfaceFocusDisposition;
66
69
  };
67
70
  export type SurfaceTransition = {
68
71
  changed: boolean;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Owns the optional visualization branch of the current microphone graph.
3
+ * Capture remains in the AudioWorklet; this object only reads the browser's
4
+ * native FFT into caller-owned buffers.
5
+ */
6
+ export declare class VoiceInputSpectrum {
7
+ private graph;
8
+ private cachedBandCount;
9
+ private bandStarts;
10
+ private bandEnds;
11
+ attach(context: AudioContext, source: AudioNode): void;
12
+ detach(context?: AudioContext): void;
13
+ readBands(target: Float32Array): void;
14
+ private invalidateBandGeometry;
15
+ private ensureBandGeometry;
16
+ }
17
+ export declare const voiceInputSpectrum: VoiceInputSpectrum;
@@ -47,6 +47,7 @@ declare const en: {
47
47
  readonly previousLoadFailed: "Couldn't load previous messages.";
48
48
  readonly loadingOlderMessages: "Loading older messages";
49
49
  readonly loadingMessages: "Loading messages";
50
+ readonly openingDestination: "Opening…";
50
51
  readonly switchToVoice: "Switch to voice chat";
51
52
  readonly talk: "Talk";
52
53
  readonly messageLabel: "Message";