@customer-agent/sdk 0.5.6-test.g260612164307

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.
Files changed (103) hide show
  1. package/assets/emoji/en-emojibase-data.json +1 -0
  2. package/chunks/App-DTjTPofP.js +2 -0
  3. package/chunks/DockNavigation-CI9i1n3W.js +1 -0
  4. package/chunks/InterviewChatScreen-IQAQHn-E.js +2 -0
  5. package/chunks/InterviewInvitePrompt-DaJfNLz_.js +1 -0
  6. package/chunks/MarkdownText-CXKW_2Ol.js +29 -0
  7. package/chunks/MobileDockDrawer-ZIdezZML.js +1 -0
  8. package/chunks/Panel-Cfjcp7iD.js +7 -0
  9. package/chunks/WidgetComposer-CJtPQVbr.js +92 -0
  10. package/chunks/WidgetGlobalLoading-B_z-6_yk.js +1 -0
  11. package/chunks/classNames-3q0x02_x.js +1 -0
  12. package/chunks/client-duvjg9sB.js +9 -0
  13. package/chunks/constants-BVd2SKDq.js +1 -0
  14. package/chunks/controller-D2LKL4eu.js +1 -0
  15. package/chunks/conversationRegistry-Y5Ouo35n.js +1 -0
  16. package/chunks/createLucideIcon-B1BLVEeA.js +1 -0
  17. package/chunks/dist-dzGCY2H5.js +41 -0
  18. package/chunks/dist-gFPJclVl.js +1 -0
  19. package/chunks/emoji-picker-element-H87_ifwm.js +4 -0
  20. package/chunks/floating-ui.dom-Cs9alM6A.js +1 -0
  21. package/chunks/i18n-Q8u2wtW4.js +1 -0
  22. package/chunks/interviewTypes-Ch2NsXKB.js +1 -0
  23. package/chunks/jsx-runtime-S2ZBQkZm.js +1 -0
  24. package/chunks/launcherAnchorStore-JMTZZGKC.js +1 -0
  25. package/chunks/navigationState-LdqG_Osx.js +1 -0
  26. package/chunks/panel-DEg2n0VX.js +2 -0
  27. package/chunks/react-CKmEJ8Ba.js +1 -0
  28. package/chunks/routes-Dh46ka4-.js +1 -0
  29. package/chunks/useSmooth-CYGvfMVe.js +3 -0
  30. package/chunks/x-CcuT5rCV.js +1 -0
  31. package/index.js +1 -0
  32. package/messages/de.json +28 -0
  33. package/messages/en.json +28 -0
  34. package/messages/es.json +28 -0
  35. package/messages/fr.json +28 -0
  36. package/messages/it.json +28 -0
  37. package/messages/ja.json +28 -0
  38. package/messages/ko.json +28 -0
  39. package/messages/pt-BR.json +28 -0
  40. package/messages/zh-TW.json +28 -0
  41. package/messages/zh.json +28 -0
  42. package/package.json +36 -0
  43. package/react.js +1 -0
  44. package/runtime.es.js +1 -0
  45. package/sdk.js +1 -0
  46. package/types/main.d.ts +0 -0
  47. package/types/messages/en.json.d.ts +31 -0
  48. package/types/messages/index.d.ts +53 -0
  49. package/types/runtime/interview/interviewApiClient.d.ts +2 -0
  50. package/types/runtime/interview/interviewSessionCache.d.ts +5 -0
  51. package/types/runtime/interview/interviewSessionService.d.ts +93 -0
  52. package/types/runtime/interview/interviewTypes.d.ts +115 -0
  53. package/types/runtime/support/supportApiClient.d.ts +2 -0
  54. package/types/runtime/support/supportSessionCache.d.ts +4 -0
  55. package/types/runtime/support/supportSessionService.d.ts +43 -0
  56. package/types/runtime/support/supportTypes.d.ts +35 -0
  57. package/types/sdk/apiClient.d.ts +103 -0
  58. package/types/sdk/config.d.ts +4 -0
  59. package/types/sdk/constants.d.ts +28 -0
  60. package/types/sdk/controller.d.ts +36 -0
  61. package/types/sdk/conversation.d.ts +56 -0
  62. package/types/sdk/events.d.ts +106 -0
  63. package/types/sdk/hooks.d.ts +37 -0
  64. package/types/sdk/i18n.d.ts +9 -0
  65. package/types/sdk/index.d.ts +8 -0
  66. package/types/sdk/launcherAnchorStore.d.ts +7 -0
  67. package/types/sdk/launcherState.d.ts +21 -0
  68. package/types/sdk/navigationState.d.ts +25 -0
  69. package/types/sdk/public-types.d.ts +152 -0
  70. package/types/sdk/runtime.d.ts +37 -0
  71. package/types/sdk/script.d.ts +16 -0
  72. package/types/sdk/version.d.ts +7 -0
  73. package/types/sdk/viewport.d.ts +3 -0
  74. package/types/types.d.ts +64 -0
  75. package/types/ui/App.d.ts +55 -0
  76. package/types/ui/Iframe.d.ts +16 -0
  77. package/types/ui/Launcher.d.ts +12 -0
  78. package/types/ui/MarkdownText.d.ts +1 -0
  79. package/types/ui/Panel.d.ts +52 -0
  80. package/types/ui/WidgetComposer.d.ts +40 -0
  81. package/types/ui/WidgetGlobalLoading.d.ts +4 -0
  82. package/types/ui/WidgetPanelCloseButton.d.ts +4 -0
  83. package/types/ui/classNames.d.ts +1 -0
  84. package/types/ui/hostStyle.d.ts +7 -0
  85. package/types/ui/panel/DockNavigation.d.ts +14 -0
  86. package/types/ui/panel/MobileDockDrawer.d.ts +13 -0
  87. package/types/ui/panel/PanelShell.d.ts +26 -0
  88. package/types/ui/panel/RouteTransition.d.ts +7 -0
  89. package/types/ui/panel/agentSessionState.d.ts +21 -0
  90. package/types/ui/registry/conversationRegistry.d.ts +73 -0
  91. package/types/ui/router/reducer.d.ts +24 -0
  92. package/types/ui/router/routeNames.d.ts +9 -0
  93. package/types/ui/router/routeStorage.d.ts +6 -0
  94. package/types/ui/router/routes.d.ts +32 -0
  95. package/types/ui/router/targetRoute.d.ts +3 -0
  96. package/types/ui/screens/interview/InterviewChatScreen.d.ts +18 -0
  97. package/types/ui/screens/interview/InterviewInvitePrompt.d.ts +13 -0
  98. package/types/ui/screens/interview/interviewSessionCache.d.ts +10 -0
  99. package/types/ui/screens/interview/interviewSessionController.d.ts +89 -0
  100. package/types/ui/screens/interview/interviewUiAdapter.d.ts +3 -0
  101. package/types/ui/screens/interview/interviewWidgetClient.d.ts +2 -0
  102. package/types/ui/transcript.d.ts +17 -0
  103. package/types/ui/useWidgetEmojiPicker.d.ts +20 -0
@@ -0,0 +1,106 @@
1
+ import { CUSTOMER_AGENT_INTERVIEW_STATUS, CustomerAgentInterviewState } from '../runtime/interview/interviewTypes';
2
+ import { CustomerAgentSupportState } from '../runtime/support/supportTypes';
3
+ import { CUSTOMER_AGENT_EVENTS } from './constants';
4
+ type CustomerAgentEventBase<TType extends string> = {
5
+ appId: string;
6
+ timestamp: string;
7
+ type: TType;
8
+ widgetId: string;
9
+ };
10
+ type MessageRole = "assistant" | "user";
11
+ type AssistantAuthor = "human" | "llm";
12
+ export type CustomerAgentConversationType = "interview" | "support" | (string & {});
13
+ type CustomerAgentConversationMeta = {
14
+ conversationId: string;
15
+ conversationType: CustomerAgentConversationType;
16
+ entryId: string;
17
+ interviewSessionId?: string;
18
+ supportConversationId?: string;
19
+ };
20
+ type OptionalCustomerAgentConversationMeta = Partial<CustomerAgentConversationMeta> & {
21
+ conversationType?: CustomerAgentConversationType;
22
+ };
23
+ type InterviewInvitationEvent = CustomerAgentEventBase<string> & {
24
+ campaignId: string;
25
+ entryId: string;
26
+ invitationId: string;
27
+ };
28
+ export type CustomerAgentEventMap = {
29
+ [CUSTOMER_AGENT_EVENTS.BUG_REPORTED]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.BUG_REPORTED> & OptionalCustomerAgentConversationMeta;
30
+ [CUSTOMER_AGENT_EVENTS.CONVERSATION_CREATED]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.CONVERSATION_CREATED> & CustomerAgentConversationMeta;
31
+ [CUSTOMER_AGENT_EVENTS.ERROR]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.ERROR> & {
32
+ message: string;
33
+ };
34
+ [CUSTOMER_AGENT_EVENTS.FEEDBACK_SUBMITTED]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.FEEDBACK_SUBMITTED> & OptionalCustomerAgentConversationMeta & {
35
+ messageId?: string;
36
+ };
37
+ [CUSTOMER_AGENT_EVENTS.HANDOFF_REQUESTED]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.HANDOFF_REQUESTED> & OptionalCustomerAgentConversationMeta;
38
+ [CUSTOMER_AGENT_EVENTS.INTERVIEW_INVITATION_CLOSED]: InterviewInvitationEvent;
39
+ [CUSTOMER_AGENT_EVENTS.INTERVIEW_INVITATION_LATER]: InterviewInvitationEvent;
40
+ [CUSTOMER_AGENT_EVENTS.INTERVIEW_INVITATION_SHOWN]: InterviewInvitationEvent;
41
+ [CUSTOMER_AGENT_EVENTS.INTERVIEW_AVAILABLE]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.INTERVIEW_AVAILABLE> & Extract<CustomerAgentInterviewState, {
42
+ status: typeof CUSTOMER_AGENT_INTERVIEW_STATUS.AVAILABLE;
43
+ }>;
44
+ [CUSTOMER_AGENT_EVENTS.INTERVIEW_REWARD_UPDATED]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.INTERVIEW_REWARD_UPDATED> & Partial<CustomerAgentConversationMeta> & {
45
+ reward?: unknown;
46
+ };
47
+ [CUSTOMER_AGENT_EVENTS.INTERVIEW_STATE_CHANGED]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.INTERVIEW_STATE_CHANGED> & {
48
+ interview: CustomerAgentInterviewState;
49
+ };
50
+ [CUSTOMER_AGENT_EVENTS.INTERVIEW_SESSION_COMPLETED]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.INTERVIEW_SESSION_COMPLETED> & CustomerAgentConversationMeta & {
51
+ status?: string;
52
+ };
53
+ [CUSTOMER_AGENT_EVENTS.INTERVIEW_SESSION_STARTED]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.INTERVIEW_SESSION_STARTED> & CustomerAgentConversationMeta;
54
+ [CUSTOMER_AGENT_EVENTS.MESSAGE_COMPLETED]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.MESSAGE_COMPLETED> & CustomerAgentConversationMeta & {
55
+ assistantAuthor?: AssistantAuthor;
56
+ messageId: string;
57
+ role: MessageRole;
58
+ };
59
+ [CUSTOMER_AGENT_EVENTS.MESSAGE_FAILED]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.MESSAGE_FAILED> & OptionalCustomerAgentConversationMeta & {
60
+ messageId?: string;
61
+ role: MessageRole;
62
+ };
63
+ [CUSTOMER_AGENT_EVENTS.MESSAGE_RETRY]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.MESSAGE_RETRY> & OptionalCustomerAgentConversationMeta & {
64
+ messageId?: string;
65
+ role: MessageRole;
66
+ };
67
+ [CUSTOMER_AGENT_EVENTS.MESSAGE_SEND_FAILED]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.MESSAGE_SEND_FAILED> & OptionalCustomerAgentConversationMeta & {
68
+ messageId?: string;
69
+ role: MessageRole;
70
+ };
71
+ [CUSTOMER_AGENT_EVENTS.MESSAGE_SENT]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.MESSAGE_SENT> & OptionalCustomerAgentConversationMeta & {
72
+ messageId: string;
73
+ role: MessageRole;
74
+ };
75
+ [CUSTOMER_AGENT_EVENTS.MESSAGE_STARTED]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.MESSAGE_STARTED> & CustomerAgentConversationMeta & {
76
+ messageId?: string;
77
+ role: MessageRole;
78
+ };
79
+ [CUSTOMER_AGENT_EVENTS.SUPPORT_STATE_CHANGED]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.SUPPORT_STATE_CHANGED> & {
80
+ support: CustomerAgentSupportState;
81
+ };
82
+ [CUSTOMER_AGENT_EVENTS.TRANSCRIPT_DOWNLOADED]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.TRANSCRIPT_DOWNLOADED> & OptionalCustomerAgentConversationMeta & {
83
+ conversationType: CustomerAgentConversationType;
84
+ messageCount: number;
85
+ };
86
+ [CUSTOMER_AGENT_EVENTS.WIDGET_CLOSED]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.WIDGET_CLOSED>;
87
+ [CUSTOMER_AGENT_EVENTS.WIDGET_COLLAPSED]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.WIDGET_COLLAPSED>;
88
+ [CUSTOMER_AGENT_EVENTS.WIDGET_EXPANDED]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.WIDGET_EXPANDED>;
89
+ [CUSTOMER_AGENT_EVENTS.WIDGET_OPENED]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.WIDGET_OPENED>;
90
+ [CUSTOMER_AGENT_EVENTS.WIDGET_READY]: CustomerAgentEventBase<typeof CUSTOMER_AGENT_EVENTS.WIDGET_READY>;
91
+ };
92
+ export type CustomerAgentEventName = keyof CustomerAgentEventMap;
93
+ export type CustomerAgentEventPayload<TEventName extends CustomerAgentEventName> = Omit<CustomerAgentEventMap[TEventName], "appId" | "timestamp" | "type" | "widgetId">;
94
+ type OptionalEventName = {
95
+ [TEventName in CustomerAgentEventName]: keyof CustomerAgentEventPayload<TEventName> extends never ? TEventName : never;
96
+ }[CustomerAgentEventName];
97
+ type EmitEventArgs<TEventName extends CustomerAgentEventName> = TEventName extends OptionalEventName ? [eventName: TEventName, detail?: CustomerAgentEventPayload<TEventName>] : [eventName: TEventName, detail: CustomerAgentEventPayload<TEventName>];
98
+ export type CustomerAgentEventBus = ReturnType<typeof createCustomerAgentEventBus>;
99
+ export declare function createCustomerAgentEventBus(getBaseFields: () => {
100
+ appId: string;
101
+ widgetId: string;
102
+ }): {
103
+ emit<TEventName extends CustomerAgentEventName>(...args: EmitEventArgs<TEventName>): void;
104
+ on<TEventName extends CustomerAgentEventName>(eventName: TEventName, handler: (event: CustomerAgentEventMap[TEventName]) => void): () => void;
105
+ };
106
+ export {};
@@ -0,0 +1,37 @@
1
+ import { RefObject } from 'react';
2
+ import { CustomerAgentEventMap, CustomerAgentEventName } from './events';
3
+ import { CustomerAgentGlobal, CustomerAgentState } from './public-types';
4
+ type CustomerAgentHookController = {
5
+ CustomerAgent: CustomerAgentGlobal;
6
+ boot: CustomerAgentGlobal["boot"];
7
+ chooseInvitation: CustomerAgentGlobal["chooseInvitation"];
8
+ ensureInvitation: CustomerAgentGlobal["ensureInvitation"];
9
+ getInterviewSession: CustomerAgentGlobal["getInterviewSession"];
10
+ getInterviewState: CustomerAgentGlobal["getInterviewState"];
11
+ getSession: CustomerAgentGlobal["getSession"];
12
+ getState: CustomerAgentGlobal["getState"];
13
+ getSupportState: CustomerAgentGlobal["getSupportState"];
14
+ hide: CustomerAgentGlobal["hide"];
15
+ identify: CustomerAgentGlobal["identify"];
16
+ isOpen: boolean;
17
+ isReady: boolean;
18
+ launcher: CustomerAgentState["launcher"] | null;
19
+ launcherAnchor: HTMLElement | null;
20
+ launcherAnchorRef: RefObject<HTMLElement | null>;
21
+ loadInterviewReward: CustomerAgentGlobal["loadInterviewReward"];
22
+ on: CustomerAgentGlobal["on"];
23
+ openEntry: CustomerAgentGlobal["openEntry"];
24
+ sendInterviewMessage: CustomerAgentGlobal["sendInterviewMessage"];
25
+ setContext: CustomerAgentGlobal["setContext"];
26
+ show: CustomerAgentGlobal["show"];
27
+ shutdown: CustomerAgentGlobal["shutdown"];
28
+ startInterview: CustomerAgentGlobal["startInterview"];
29
+ startInvitation: CustomerAgentGlobal["startInvitation"];
30
+ state: CustomerAgentState | null;
31
+ toggle: CustomerAgentGlobal["toggle"];
32
+ update: CustomerAgentGlobal["update"];
33
+ };
34
+ export declare function useCustomerAgentState(): CustomerAgentState | null;
35
+ export declare function useCustomerAgent(): CustomerAgentHookController;
36
+ export declare function useCustomerAgentEvent<TEventName extends CustomerAgentEventName>(eventName: TEventName, handler: (event: CustomerAgentEventMap[TEventName]) => void): void;
37
+ export {};
@@ -0,0 +1,9 @@
1
+ import { WidgetLocaleMessages } from '../types';
2
+ export type ResolvedWidgetLocale = {
3
+ dir: "ltr" | "rtl";
4
+ locale: string;
5
+ messages: Required<WidgetLocaleMessages>;
6
+ };
7
+ export declare function resolveWidgetLocale(locale?: string, messageOverrides?: WidgetLocaleMessages): ResolvedWidgetLocale;
8
+ export declare function loadWidgetLocale(locale?: string, messageOverrides?: WidgetLocaleMessages): Promise<ResolvedWidgetLocale>;
9
+ export declare function formatWidgetMessage(message: string, values: Record<string, string>): string;
@@ -0,0 +1,8 @@
1
+ import { CustomerAgent } from './controller';
2
+ export { boot, chooseInvitation, CustomerAgent, ensureInvitation, getInterviewState, getInterviewSession, getSession, getState, getSupportState, hide, identify, loadInterviewReward, on, openEntry, sendInterviewMessage, setContext, show, shutdown, startInterview, startInvitation, toggle, update } from './controller';
3
+ export { CUSTOMER_AGENT_EVENTS } from './constants';
4
+ export { INTERVIEW_INVITATION_ACTION } from '../runtime/interview/interviewTypes';
5
+ export type { CustomerAgentEventMap, CustomerAgentEventName } from './events';
6
+ export type { CustomerAgentGlobal, CustomerAgentInterviewInvitationAction, CustomerAgentInterviewInvitationChoice, CustomerAgentInterviewSession, CustomerAgentInterviewState, CustomerAgentOptions, CustomerAgentState, CustomerAgentSupportState, CustomerAgentTarget, CustomerAgentWidget, SetContextOptions } from './public-types';
7
+ export type { WidgetContextJson } from '../types';
8
+ export default CustomerAgent;
@@ -0,0 +1,7 @@
1
+ type LauncherAnchorListener = () => void;
2
+ export declare function getLauncherAnchorSnapshot(): HTMLElement | null;
3
+ export declare function getServerLauncherAnchorSnapshot(): null;
4
+ export declare function subscribeLauncherAnchor(listener: LauncherAnchorListener): () => void;
5
+ export declare function setLauncherAnchor(element: HTMLElement | null): void;
6
+ export declare function clearLauncherAnchor(element?: HTMLElement | null): void;
7
+ export {};
@@ -0,0 +1,21 @@
1
+ import { WidgetViewport } from '../types';
2
+ export type LauncherSyncState = {
3
+ activeEntryId?: string;
4
+ activeKind?: string;
5
+ hasInvitation?: boolean;
6
+ hasUnread?: boolean;
7
+ isOpen: boolean;
8
+ targetConnected: boolean;
9
+ targetConfigured: boolean;
10
+ viewport?: WidgetViewport["mode"] | WidgetViewport["presentation"];
11
+ };
12
+ export type ResolveLauncherElementOptions = {
13
+ createDefaultElement(): HTMLElement;
14
+ target?: HTMLElement | string | null;
15
+ };
16
+ export declare function resolveLauncherElement({ createDefaultElement, target }: ResolveLauncherElementOptions): {
17
+ launcherElement: HTMLElement;
18
+ targetConnected: boolean;
19
+ targetConfigured: boolean;
20
+ };
21
+ export declare function syncLauncherState(element: HTMLElement, state: LauncherSyncState): void;
@@ -0,0 +1,25 @@
1
+ import { WidgetOptions } from '../types';
2
+ import { CustomerAgentTarget } from './public-types';
3
+ export declare const CUSTOMER_AGENT_MEMORY_ROUTE_TYPE: Readonly<{
4
+ CHAT: "chat";
5
+ SUPPORT: "support";
6
+ }>;
7
+ export type CustomerAgentMemoryRoute = {
8
+ entryId: string;
9
+ type: typeof CUSTOMER_AGENT_MEMORY_ROUTE_TYPE.CHAT;
10
+ } | {
11
+ type: typeof CUSTOMER_AGENT_MEMORY_ROUTE_TYPE.SUPPORT;
12
+ };
13
+ export type CustomerAgentNavigationState = {
14
+ memoryRoute: CustomerAgentMemoryRoute;
15
+ requestedTarget?: CustomerAgentTarget;
16
+ };
17
+ export declare function getNavigationMemoryStorageKey(options: WidgetOptions): string;
18
+ export declare function getDefaultMemoryRoute(): CustomerAgentMemoryRoute;
19
+ export declare function isValidPublicEntryTargetId(entryId: string): boolean;
20
+ export declare function createInitialNavigationState(options: WidgetOptions): CustomerAgentNavigationState;
21
+ export declare function getEntryIdForMemoryRoute(route: CustomerAgentMemoryRoute): string | undefined;
22
+ export declare function getMemoryRouteForTarget(target: CustomerAgentTarget): CustomerAgentMemoryRoute | null;
23
+ export declare function setNavigationTarget(options: WidgetOptions, state: CustomerAgentNavigationState, target: CustomerAgentTarget | undefined): CustomerAgentNavigationState;
24
+ export declare function commitMemoryRoute(options: WidgetOptions, state: CustomerAgentNavigationState, route: CustomerAgentMemoryRoute): CustomerAgentNavigationState;
25
+ export declare function clearNavigationTarget(state: CustomerAgentNavigationState): CustomerAgentNavigationState;
@@ -0,0 +1,152 @@
1
+ import { CustomerAgentInterviewState, InterviewInvitationChoice, InterviewSessionResponse } from '../runtime/interview/interviewTypes';
2
+ import { CustomerAgentSupportState } from '../runtime/support/supportTypes';
3
+ import { WidgetContextJson, WidgetLauncherOptions, WidgetLauncherTarget, WidgetLocaleMessages, WidgetMobileOptions, WidgetTheme, WidgetUser } from '../types';
4
+ import { CustomerAgentEventMap, CustomerAgentEventName } from './events';
5
+ export type { CustomerAgentInterviewState } from '../runtime/interview/interviewTypes';
6
+ export type { InterviewInvitationAction as CustomerAgentInterviewInvitationAction, InterviewInvitationChoice as CustomerAgentInterviewInvitationChoice } from '../runtime/interview/interviewTypes';
7
+ export type { InterviewSessionResponse as CustomerAgentInterviewSession } from '../runtime/interview/interviewTypes';
8
+ export type { CustomerAgentSupportState } from '../runtime/support/supportTypes';
9
+ export type CustomerAgentOptions = {
10
+ app_id: string;
11
+ anonymous_id?: string;
12
+ brand?: {
13
+ name?: string;
14
+ };
15
+ context?: WidgetContextJson;
16
+ context_ready?: boolean;
17
+ launcher?: WidgetLauncherOptions & {
18
+ target?: WidgetLauncherTarget;
19
+ };
20
+ locale?: string;
21
+ messages?: WidgetLocaleMessages;
22
+ mobile?: WidgetMobileOptions;
23
+ mount?: HTMLElement | string;
24
+ open_on_init?: boolean;
25
+ position?: "bottom-right" | "bottom-left";
26
+ theme?: WidgetTheme;
27
+ user?: WidgetUser;
28
+ };
29
+ export type SetContextOptions = {
30
+ merge?: boolean;
31
+ ready?: boolean;
32
+ };
33
+ export type CustomerAgentState = {
34
+ activeEntryId?: string;
35
+ activeTarget?: CustomerAgentTarget;
36
+ appId: string;
37
+ isOpen: boolean;
38
+ isReady: boolean;
39
+ interview: CustomerAgentInterviewState;
40
+ launcher: {
41
+ targetConfigured: boolean;
42
+ targetConnected: boolean;
43
+ };
44
+ support: CustomerAgentSupportState;
45
+ widgetId: string;
46
+ };
47
+ export type CustomerAgentTarget = {
48
+ type: "entry";
49
+ entryId: string;
50
+ } | {
51
+ type: "home";
52
+ } | {
53
+ type: "interview";
54
+ campaignId?: string;
55
+ sessionId?: string;
56
+ } | {
57
+ type: "support";
58
+ };
59
+ export type CustomerAgentWidget = {
60
+ chooseInvitation(invitationId: string, choice: InterviewInvitationChoice): Promise<void>;
61
+ ensureInvitation(): Promise<{
62
+ invitationId: string;
63
+ }>;
64
+ getInterviewState(): CustomerAgentInterviewState;
65
+ getInterviewSession(): InterviewSessionResponse | null;
66
+ getSession(): Promise<{
67
+ conversationId: string;
68
+ }>;
69
+ getState(): CustomerAgentState;
70
+ getSupportState(): CustomerAgentSupportState;
71
+ hide(): void;
72
+ identify(user: WidgetUser): void;
73
+ on<TEventName extends CustomerAgentEventName>(eventName: TEventName, handler: (event: CustomerAgentEventMap[TEventName]) => void): () => void;
74
+ openEntry(entryId: string): void;
75
+ loadInterviewReward(sessionId?: string): Promise<unknown>;
76
+ sendInterviewMessage(content: string): Promise<void>;
77
+ setContext(context: WidgetContextJson, options?: SetContextOptions): void;
78
+ show(target?: CustomerAgentTarget): void;
79
+ shutdown(): void;
80
+ startInterview(): Promise<{
81
+ entryId: string;
82
+ sessionId: string;
83
+ }>;
84
+ startInvitation(invitationId: string): Promise<{
85
+ entryId: string;
86
+ sessionId: string;
87
+ }>;
88
+ toggle(target?: CustomerAgentTarget): void;
89
+ update(options: Partial<CustomerAgentOptions>): void;
90
+ };
91
+ export type CustomerAgentGlobal = {
92
+ (command: "boot", options: CustomerAgentOptions): CustomerAgentWidget;
93
+ (command: "getSession"): Promise<{
94
+ conversationId: string;
95
+ } | null>;
96
+ (command: "getState"): CustomerAgentState | null;
97
+ (command: "getSupportState"): CustomerAgentSupportState | null;
98
+ (command: "getInterviewState"): CustomerAgentInterviewState | null;
99
+ (command: "getInterviewSession"): InterviewSessionResponse | null;
100
+ (command: "ensureInvitation"): Promise<{
101
+ invitationId: string;
102
+ } | null>;
103
+ (command: "startInvitation", invitationId: string): Promise<{
104
+ entryId: string;
105
+ sessionId: string;
106
+ } | null>;
107
+ (command: "startInterview"): Promise<{
108
+ entryId: string;
109
+ sessionId: string;
110
+ } | null>;
111
+ (command: "chooseInvitation", invitationId: string, choice: InterviewInvitationChoice): Promise<void>;
112
+ (command: "loadInterviewReward", sessionId?: string): Promise<unknown>;
113
+ (command: "sendInterviewMessage", content: string): Promise<void>;
114
+ (command: "identify", user: WidgetUser): void;
115
+ (command: "openEntry", entryId: string): void;
116
+ <TEventName extends CustomerAgentEventName>(command: "on", eventName: TEventName, handler: (event: CustomerAgentEventMap[TEventName]) => void): () => void;
117
+ (command: "setContext", context: WidgetContextJson, options?: SetContextOptions): void;
118
+ (command: "show" | "toggle", target?: CustomerAgentTarget): void;
119
+ (command: "update", options: Partial<CustomerAgentOptions>): void;
120
+ (command: "hide" | "shutdown"): void;
121
+ boot(options: CustomerAgentOptions): CustomerAgentWidget;
122
+ chooseInvitation(invitationId: string, choice: InterviewInvitationChoice): Promise<void>;
123
+ ensureInvitation(): Promise<{
124
+ invitationId: string;
125
+ } | null>;
126
+ getInterviewState(): CustomerAgentInterviewState | null;
127
+ getInterviewSession(): InterviewSessionResponse | null;
128
+ getSession(): Promise<{
129
+ conversationId: string;
130
+ } | null>;
131
+ getState(): CustomerAgentState | null;
132
+ getSupportState(): CustomerAgentSupportState | null;
133
+ hide(): void;
134
+ identify(user: WidgetUser): void;
135
+ on<TEventName extends CustomerAgentEventName>(eventName: TEventName, handler: (event: CustomerAgentEventMap[TEventName]) => void): () => void;
136
+ openEntry(entryId: string): void;
137
+ loadInterviewReward(sessionId?: string): Promise<unknown>;
138
+ sendInterviewMessage(content: string): Promise<void>;
139
+ setContext(context: WidgetContextJson, options?: SetContextOptions): void;
140
+ show(target?: CustomerAgentTarget): void;
141
+ shutdown(): void;
142
+ startInterview(): Promise<{
143
+ entryId: string;
144
+ sessionId: string;
145
+ } | null>;
146
+ startInvitation(invitationId: string): Promise<{
147
+ entryId: string;
148
+ sessionId: string;
149
+ } | null>;
150
+ toggle(target?: CustomerAgentTarget): void;
151
+ update(options: Partial<CustomerAgentOptions>): void;
152
+ };
@@ -0,0 +1,37 @@
1
+ import { WidgetContextJson, WidgetUser } from '../types';
2
+ import { CustomerAgentEventMap, CustomerAgentEventName } from './events';
3
+ import { CustomerAgentGlobal, CustomerAgentInterviewInvitationChoice, CustomerAgentOptions, CustomerAgentState, CustomerAgentTarget, CustomerAgentWidget, SetContextOptions } from './public-types';
4
+ export type { CustomerAgentGlobal, CustomerAgentWidget } from './public-types';
5
+ declare function boot(options: CustomerAgentOptions): CustomerAgentWidget;
6
+ export declare const CustomerAgent: CustomerAgentGlobal;
7
+ export declare const chooseInvitation: (invitationId: string, choice: CustomerAgentInterviewInvitationChoice) => Promise<void>;
8
+ export declare const ensureInvitation: () => Promise<{
9
+ invitationId: string;
10
+ } | null>;
11
+ export declare const getInterviewState: () => import('./public-types').CustomerAgentInterviewState | null;
12
+ export declare const getInterviewSession: () => import('./public-types').CustomerAgentInterviewSession | null;
13
+ export declare const getSession: () => Promise<{
14
+ conversationId: string;
15
+ } | null>;
16
+ export declare const getState: () => CustomerAgentState | null;
17
+ export declare const getSupportState: () => import('./public-types').CustomerAgentSupportState | null;
18
+ export declare const hide: () => void;
19
+ export declare const identify: (user: WidgetUser) => void;
20
+ export declare const on: <TEventName extends CustomerAgentEventName>(eventName: TEventName, handler: (event: CustomerAgentEventMap[TEventName]) => void) => () => void;
21
+ export declare const openEntry: (entryId: string) => void;
22
+ export declare const loadInterviewReward: (sessionId?: string) => Promise<unknown>;
23
+ export declare const sendInterviewMessage: (content: string) => Promise<void>;
24
+ export declare const setContext: (context: WidgetContextJson, options?: SetContextOptions) => void;
25
+ export declare const show: (target?: CustomerAgentTarget) => void;
26
+ export declare const shutdown: () => void;
27
+ export declare const startInvitation: (invitationId: string) => Promise<{
28
+ entryId: string;
29
+ sessionId: string;
30
+ } | null>;
31
+ export declare const startInterview: () => Promise<{
32
+ entryId: string;
33
+ sessionId: string;
34
+ } | null>;
35
+ export declare const toggle: (target?: CustomerAgentTarget) => void;
36
+ export declare const update: (options: Partial<CustomerAgentOptions>) => void;
37
+ export { boot };
@@ -0,0 +1,16 @@
1
+ import { CustomerAgentGlobal } from './public-types';
2
+ type QueuedCustomerAgentGlobal = {
3
+ q?: Array<ArrayLike<unknown>>;
4
+ };
5
+ type RuntimeGlobal = CustomerAgentGlobal & {
6
+ __customerAgentRuntime?: true;
7
+ };
8
+ type ScriptGlobal = CustomerAgentGlobal & {
9
+ __customerAgentScript?: true;
10
+ };
11
+ declare global {
12
+ interface Window {
13
+ CustomerAgent?: RuntimeGlobal | ScriptGlobal | QueuedCustomerAgentGlobal;
14
+ }
15
+ }
16
+ export {};
@@ -0,0 +1,7 @@
1
+ export declare const CUSTOMER_AGENT_VERSION: string;
2
+ export declare function publishCustomerAgentVersion(): void;
3
+ declare global {
4
+ interface Window {
5
+ __customerAgentVersion?: string;
6
+ }
7
+ }
@@ -0,0 +1,3 @@
1
+ import { WidgetMobileOptions, WidgetViewport } from '../types';
2
+ export declare function getSafeAreaBottom(): number;
3
+ export declare function resolveViewport(mobile?: WidgetMobileOptions): WidgetViewport;
@@ -0,0 +1,64 @@
1
+ import { default as defaultLocaleMessages } from './messages/en.json';
2
+ export type WidgetUser = {
3
+ id?: string;
4
+ email?: string;
5
+ name?: string;
6
+ [key: string]: unknown;
7
+ };
8
+ export type WidgetContextJson = Record<string, unknown>;
9
+ export type WidgetLocaleMessages = Partial<Record<keyof typeof defaultLocaleMessages, string>>;
10
+ export type WidgetMobileOptions = {
11
+ mode?: "auto" | "fullscreen" | "bottom-sheet";
12
+ };
13
+ export type WidgetMobilePresentation = "desktop" | "fullscreen" | "bottom-sheet";
14
+ export type WidgetLauncherPlacement = "bottom" | "left" | "right" | "top";
15
+ export type WidgetLauncherStyle = Record<string, number | string | undefined>;
16
+ export type WidgetLauncherVariableName = "bg-color" | "border-color" | "border-radius" | "border-style" | "border-width" | "box-shadow" | "color" | "hover-bg-color" | "hover-border-color" | "hover-border-radius" | "hover-border-style" | "hover-border-width" | "hover-box-shadow" | "hover-color";
17
+ export type WidgetLauncherVariables = Partial<Record<WidgetLauncherVariableName, number | string | undefined>>;
18
+ export type WidgetLauncherOptions = {
19
+ offset?: number;
20
+ placement?: WidgetLauncherPlacement;
21
+ style?: WidgetLauncherStyle;
22
+ variables?: WidgetLauncherVariables;
23
+ };
24
+ export type WidgetLauncherTarget = HTMLElement | string;
25
+ export type WidgetLauncherAnchor = {
26
+ panelHeight: number;
27
+ panelLeft: number;
28
+ panelTop: number;
29
+ panelWidth: number;
30
+ placement: WidgetLauncherPlacement;
31
+ };
32
+ export type WidgetTheme = {
33
+ colorScheme?: "light" | "dark" | "system";
34
+ primaryColor?: string;
35
+ radius?: number;
36
+ };
37
+ export type WidgetViewport = {
38
+ height: number;
39
+ isMobile: boolean;
40
+ keyboardInset: number;
41
+ mode: "desktop" | "mobile";
42
+ offsetTop: number;
43
+ presentation: WidgetMobilePresentation;
44
+ safeAreaBottom: number;
45
+ visualHeight: number;
46
+ width: number;
47
+ };
48
+ export type WidgetOptions = {
49
+ app_id: string;
50
+ widgetId: string;
51
+ anonymous_id?: string;
52
+ brand?: {
53
+ name?: string;
54
+ };
55
+ context?: WidgetContextJson;
56
+ context_ready?: boolean;
57
+ locale?: string;
58
+ launcher?: WidgetLauncherOptions;
59
+ messages?: WidgetLocaleMessages;
60
+ mobile?: WidgetMobileOptions;
61
+ open_on_init?: boolean;
62
+ theme?: WidgetTheme;
63
+ user?: WidgetUser;
64
+ };
@@ -0,0 +1,55 @@
1
+ import { InterviewInvitationChoice, InterviewSessionResponse } from '../runtime/interview/interviewTypes';
2
+ import { CustomerAgentApiMessage } from '../sdk/apiClient';
3
+ import { CurrentCustomerAgentOptions } from '../sdk/config';
4
+ import { CustomerAgentEventBus } from '../sdk/events';
5
+ import { ResolvedWidgetLocale } from '../sdk/i18n';
6
+ import { CustomerAgentMemoryRoute } from '../sdk/navigationState';
7
+ import { CustomerAgentInterviewState, CustomerAgentSupportState, CustomerAgentTarget } from '../sdk/public-types';
8
+ import { WidgetViewport } from '../types';
9
+ export declare function preloadWidgetPanelShell(): Promise<void>;
10
+ export declare function createStableLauncherReference(element: HTMLElement): {
11
+ contextElement: HTMLElement;
12
+ getBoundingClientRect(): DOMRect;
13
+ };
14
+ export type WidgetAppProps = {
15
+ eventBus?: CustomerAgentEventBus;
16
+ activeTarget?: CustomerAgentTarget;
17
+ hasPanel: boolean;
18
+ hasCustomLauncher: boolean;
19
+ isOpen: boolean;
20
+ isViewportSettling?: boolean;
21
+ memoryRoute?: CustomerAgentMemoryRoute;
22
+ interviewRuntime?: {
23
+ chooseInvitation(id: string, choice: InterviewInvitationChoice): Promise<void>;
24
+ ensureInvitation(): Promise<string>;
25
+ getActiveSession(): InterviewSessionResponse | null;
26
+ startInvitation(id: string): Promise<{
27
+ entryId: string;
28
+ session: InterviewSessionResponse;
29
+ sessionId: string;
30
+ }>;
31
+ };
32
+ launcherTargetElement: HTMLElement | null;
33
+ onMemoryRouteChange?(route: CustomerAgentMemoryRoute): void;
34
+ onOpenChange(open: boolean): void;
35
+ options: CurrentCustomerAgentOptions;
36
+ resolvedLocale: ResolvedWidgetLocale;
37
+ runtimeState?: {
38
+ interview: CustomerAgentInterviewState;
39
+ support: CustomerAgentSupportState;
40
+ };
41
+ supportRuntime?: {
42
+ ensureSession(): Promise<{
43
+ conversationId: string;
44
+ messages: CustomerAgentApiMessage[];
45
+ }>;
46
+ getSessionSnapshot(): {
47
+ conversationId: string;
48
+ messages: CustomerAgentApiMessage[];
49
+ } | null;
50
+ invalidateSession?(): void;
51
+ };
52
+ viewport: WidgetViewport;
53
+ widgetId: string;
54
+ };
55
+ export declare function WidgetApp({ activeTarget, eventBus, hasPanel, hasCustomLauncher, isOpen, isViewportSettling, memoryRoute, interviewRuntime, launcherTargetElement, onMemoryRouteChange, onOpenChange, options, resolvedLocale, runtimeState, supportRuntime, viewport, widgetId }: WidgetAppProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { ReactNode } from 'react';
2
+ import { WidgetFrameAction, WidgetFrameState, WidgetSurface } from '../messages';
3
+ export type WidgetIframeRenderProps = {
4
+ dispatch(action: WidgetFrameAction): void;
5
+ state: WidgetFrameState;
6
+ };
7
+ export type WidgetIframeProps = {
8
+ children(props: WidgetIframeRenderProps): ReactNode;
9
+ loadingFallback?(props: WidgetIframeRenderProps): ReactNode;
10
+ state: WidgetFrameState;
11
+ surface: WidgetSurface;
12
+ title: string;
13
+ widgetId: string;
14
+ };
15
+ export declare function preloadWidgetPanelStylesheet(): Promise<string>;
16
+ export declare function WidgetIframe({ children, loadingFallback, state, surface, title, widgetId }: WidgetIframeProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { CSSProperties } from 'react';
2
+ import { ResolvedWidgetLocale } from '../sdk/i18n';
3
+ import { WidgetOptions } from '../types';
4
+ export type WidgetLauncherProps = {
5
+ bootOptions?: Partial<WidgetOptions> | null;
6
+ isOpen: boolean;
7
+ launcherVariableStyle?: CSSProperties;
8
+ locale: ResolvedWidgetLocale;
9
+ onOpenChange(open: boolean): void;
10
+ onPanelPreload?(): void;
11
+ };
12
+ export declare function WidgetLauncher({ bootOptions, isOpen, launcherVariableStyle, locale, onOpenChange, onPanelPreload }: WidgetLauncherProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare function MarkdownText(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,52 @@
1
+ import { InterviewInvitationChoice, InterviewSessionResponse } from '../runtime/interview/interviewTypes';
2
+ import { CustomerAgentApiMessage } from '../sdk/apiClient';
3
+ import { CustomerAgentEventBus } from '../sdk/events';
4
+ import { ResolvedWidgetLocale } from '../sdk/i18n';
5
+ import { CustomerAgentMemoryRoute } from '../sdk/navigationState';
6
+ import { CustomerAgentInterviewState, CustomerAgentSupportState, CustomerAgentTarget } from '../sdk/public-types';
7
+ import { WidgetOptions, WidgetViewport } from '../types';
8
+ export type WidgetMessage = {
9
+ id: string;
10
+ author: "visitor" | "assistant";
11
+ text: string;
12
+ };
13
+ export type WidgetPanelProps = {
14
+ activeTarget?: CustomerAgentTarget;
15
+ bootOptions?: Partial<WidgetOptions> | null;
16
+ eventBus?: CustomerAgentEventBus;
17
+ interviewRuntime?: {
18
+ chooseInvitation(id: string, choice: InterviewInvitationChoice): Promise<void>;
19
+ ensureInvitation(): Promise<string>;
20
+ getActiveSession(): InterviewSessionResponse | null;
21
+ startInvitation(id: string): Promise<{
22
+ entryId: string;
23
+ session: InterviewSessionResponse;
24
+ sessionId: string;
25
+ }>;
26
+ };
27
+ isExpanded: boolean;
28
+ isOpen: boolean;
29
+ locale: ResolvedWidgetLocale;
30
+ messages?: WidgetMessage[];
31
+ memoryRoute?: CustomerAgentMemoryRoute;
32
+ onMemoryRouteChange?(route: CustomerAgentMemoryRoute): void;
33
+ onExpandedChange(expanded: boolean): void;
34
+ onOpenChange(open: boolean): void;
35
+ runtimeState?: {
36
+ interview: CustomerAgentInterviewState;
37
+ support: CustomerAgentSupportState;
38
+ };
39
+ supportRuntime?: {
40
+ ensureSession(): Promise<{
41
+ conversationId: string;
42
+ messages: CustomerAgentApiMessage[];
43
+ }>;
44
+ getSessionSnapshot(): {
45
+ conversationId: string;
46
+ messages: CustomerAgentApiMessage[];
47
+ } | null;
48
+ invalidateSession?(): void;
49
+ };
50
+ viewport: WidgetViewport;
51
+ };
52
+ export declare function WidgetPanel({ activeTarget, bootOptions, eventBus, interviewRuntime, isExpanded, isOpen, locale, memoryRoute, messages, onMemoryRouteChange, onExpandedChange, onOpenChange, runtimeState, supportRuntime, viewport }: WidgetPanelProps): import("react/jsx-runtime").JSX.Element;