@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,31 @@
1
+ declare const _default: {
2
+ "add_emoji": "Add emoji",
3
+ "assistant_author_ai": "Agent",
4
+ "assistant_author_human": "Support",
5
+ "attachment_label": "Attach image, PDF, or MP4",
6
+ "close_chat": "Close chat",
7
+ "collapse_window": "Collapse window",
8
+ "download_transcript": "Download transcript",
9
+ "expand_window": "Expand window",
10
+ "input_placeholder": "Ask a question...",
11
+ "interview_input_placeholder": "Your answer...",
12
+ "interview_session_description": "Insights start here. We’re listening.",
13
+ "launcher_close": "Close {title}",
14
+ "launcher_open": "Open {title}",
15
+ "message_aria_label": "Message",
16
+ "more_options": "More options",
17
+ "relative_time_today": "Today",
18
+ "relative_time_yesterday": "Yesterday",
19
+ "relative_time_day": "{count} days ago",
20
+ "relative_time_hour": "{count}h ago",
21
+ "relative_time_minute": "{count}m ago",
22
+ "relative_time_now": "now",
23
+ "remove_attachment": "Remove {name}",
24
+ "send_message": "Send message",
25
+ "status_reply_time": "Agent is here. Our team is nearby.",
26
+ "support_chat_label": "{title} support chat",
27
+ "welcome_message": "Hi, I’m your support assistant. How can I help?"
28
+ }
29
+ ;
30
+
31
+ export default _default;
@@ -0,0 +1,53 @@
1
+ import { ResolvedWidgetLocale } from '../sdk/i18n';
2
+ import { CustomerAgentMemoryRoute } from '../sdk/navigationState';
3
+ import { CustomerAgentInterviewState, CustomerAgentSupportState, CustomerAgentTarget } from '../sdk/public-types';
4
+ import { WidgetOptions, WidgetViewport } from '../types';
5
+ export declare const WIDGET_FRAME_ACTION_TYPE: Readonly<{
6
+ readonly EXPAND_CHANGE: "expand-change";
7
+ readonly MEMORY_ROUTE_CHANGE: "memory-route-change";
8
+ readonly OPEN_CHANGE: "open-change";
9
+ }>;
10
+ export declare const WIDGET_FRAME_MESSAGE_TYPE: Readonly<{
11
+ readonly ACTION: "customer-agent:frame-action";
12
+ readonly STATE: "customer-agent:frame-state";
13
+ }>;
14
+ export type WidgetSurface = "launcher" | "panel";
15
+ export type WidgetFrameState = {
16
+ activeTarget?: CustomerAgentTarget;
17
+ bootOptions: Partial<WidgetOptions>;
18
+ isExpanded: boolean;
19
+ memoryRoute?: CustomerAgentMemoryRoute;
20
+ runtimeState?: {
21
+ interview: CustomerAgentInterviewState;
22
+ support: CustomerAgentSupportState;
23
+ };
24
+ locale: ResolvedWidgetLocale;
25
+ isOpen: boolean;
26
+ viewport: WidgetViewport;
27
+ };
28
+ export type WidgetFrameAction = {
29
+ open: boolean;
30
+ type: typeof WIDGET_FRAME_ACTION_TYPE.OPEN_CHANGE;
31
+ } | {
32
+ expanded: boolean;
33
+ type: typeof WIDGET_FRAME_ACTION_TYPE.EXPAND_CHANGE;
34
+ } | {
35
+ route: CustomerAgentMemoryRoute;
36
+ type: typeof WIDGET_FRAME_ACTION_TYPE.MEMORY_ROUTE_CHANGE;
37
+ };
38
+ export type WidgetFrameStateMessage = {
39
+ state: WidgetFrameState;
40
+ surface: WidgetSurface;
41
+ type: typeof WIDGET_FRAME_MESSAGE_TYPE.STATE;
42
+ widgetId: string;
43
+ };
44
+ export type WidgetFrameActionMessage = {
45
+ action: WidgetFrameAction;
46
+ surface: WidgetSurface;
47
+ type: typeof WIDGET_FRAME_MESSAGE_TYPE.ACTION;
48
+ widgetId: string;
49
+ };
50
+ export declare function createFrameStateMessage(widgetId: string, surface: WidgetSurface, state: WidgetFrameState): WidgetFrameStateMessage;
51
+ export declare function createFrameActionMessage(widgetId: string, surface: WidgetSurface, action: WidgetFrameAction): WidgetFrameActionMessage;
52
+ export declare function isFrameStateMessage(value: unknown): value is WidgetFrameStateMessage;
53
+ export declare function isFrameActionMessage(value: unknown): value is WidgetFrameActionMessage;
@@ -0,0 +1,2 @@
1
+ import { InterviewClient } from './interviewTypes';
2
+ export declare function createInterviewRuntimeClient(): InterviewClient;
@@ -0,0 +1,5 @@
1
+ import { WidgetOptions } from '../../types';
2
+ import { InterviewSessionCache } from './interviewTypes';
3
+ export declare function getInterviewIdentityKey(options: WidgetOptions): string | null;
4
+ export declare function getInterviewDiscoveryKey(options: WidgetOptions): string | null;
5
+ export declare function createLocalStorageInterviewSessionCache(): InterviewSessionCache;
@@ -0,0 +1,93 @@
1
+ import { ConversationContextPayload } from '../../sdk/conversation';
2
+ import { WidgetOptions } from '../../types';
3
+ import { CUSTOMER_AGENT_INTERVIEW_STATUS, INTERVIEW_SESSION_STATUS, CustomerAgentInterviewState, InterviewClient, InterviewInvitationChoice, InterviewSessionCache, InterviewSessionResponse } from './interviewTypes';
4
+ export type InterviewAvailablePayload = Extract<CustomerAgentInterviewState, {
5
+ status: typeof CUSTOMER_AGENT_INTERVIEW_STATUS.AVAILABLE;
6
+ }>;
7
+ export type InterviewSessionServiceDeps = {
8
+ api: InterviewClient;
9
+ buildContextPayload?: (options: WidgetOptions) => ConversationContextPayload;
10
+ cache: InterviewSessionCache;
11
+ emitAvailable(payload: InterviewAvailablePayload): void;
12
+ emitConversationCreated?(payload: InterviewConversationMeta): void;
13
+ emitSessionStarted?(payload: InterviewConversationMeta): void;
14
+ emitStateChanged(state: CustomerAgentInterviewState): void;
15
+ getOptions(): WidgetOptions;
16
+ };
17
+ export type InterviewConversationMeta = {
18
+ conversationId: string;
19
+ conversationType: "interview";
20
+ entryId: `interview/session/${string}`;
21
+ interviewSessionId: string;
22
+ };
23
+ export type InterviewSessionService = ReturnType<typeof createInterviewSessionService>;
24
+ export declare function createInterviewSessionService({ api, buildContextPayload: buildPayload, cache, emitAvailable, emitConversationCreated, emitSessionStarted, emitStateChanged, getOptions }: InterviewSessionServiceDeps): {
25
+ chooseInvitation(id: string, choice: InterviewInvitationChoice): Promise<void>;
26
+ ensureInvitation(): Promise<string>;
27
+ getState(): {
28
+ status: typeof CUSTOMER_AGENT_INTERVIEW_STATUS.CHECKING | typeof CUSTOMER_AGENT_INTERVIEW_STATUS.ERROR | typeof CUSTOMER_AGENT_INTERVIEW_STATUS.IDLE | typeof CUSTOMER_AGENT_INTERVIEW_STATUS.UNAVAILABLE;
29
+ error?: {
30
+ message: string;
31
+ };
32
+ } | {
33
+ body: string;
34
+ campaignId: string;
35
+ laterCta: string;
36
+ startCta: string;
37
+ status: typeof CUSTOMER_AGENT_INTERVIEW_STATUS.AVAILABLE;
38
+ title: string;
39
+ } | {
40
+ sessionId: string;
41
+ sessionStatus: Exclude<import('./interviewTypes').InterviewStatus, typeof INTERVIEW_SESSION_STATUS.ACTIVE>;
42
+ status: typeof CUSTOMER_AGENT_INTERVIEW_STATUS.TERMINAL;
43
+ } | {
44
+ title: string;
45
+ entryId: `interview/session/${string}`;
46
+ sessionId: string;
47
+ status: typeof CUSTOMER_AGENT_INTERVIEW_STATUS.ACTIVE;
48
+ };
49
+ getActiveSession(): InterviewSessionResponse | null;
50
+ loadReward(sessionId?: string | undefined): Promise<unknown>;
51
+ syncAvailability: () => Promise<void>;
52
+ startInvitation(id: string): Promise<{
53
+ entryId: string;
54
+ session: InterviewSessionResponse;
55
+ sessionId: string;
56
+ }>;
57
+ sendMessage(content: string): Promise<void>;
58
+ };
59
+ export declare function createDefaultInterviewSessionService(deps: Omit<InterviewSessionServiceDeps, "buildContextPayload" | "cache">): {
60
+ chooseInvitation(id: string, choice: InterviewInvitationChoice): Promise<void>;
61
+ ensureInvitation(): Promise<string>;
62
+ getState(): {
63
+ status: typeof CUSTOMER_AGENT_INTERVIEW_STATUS.CHECKING | typeof CUSTOMER_AGENT_INTERVIEW_STATUS.ERROR | typeof CUSTOMER_AGENT_INTERVIEW_STATUS.IDLE | typeof CUSTOMER_AGENT_INTERVIEW_STATUS.UNAVAILABLE;
64
+ error?: {
65
+ message: string;
66
+ };
67
+ } | {
68
+ body: string;
69
+ campaignId: string;
70
+ laterCta: string;
71
+ startCta: string;
72
+ status: typeof CUSTOMER_AGENT_INTERVIEW_STATUS.AVAILABLE;
73
+ title: string;
74
+ } | {
75
+ sessionId: string;
76
+ sessionStatus: Exclude<import('./interviewTypes').InterviewStatus, typeof INTERVIEW_SESSION_STATUS.ACTIVE>;
77
+ status: typeof CUSTOMER_AGENT_INTERVIEW_STATUS.TERMINAL;
78
+ } | {
79
+ title: string;
80
+ entryId: `interview/session/${string}`;
81
+ sessionId: string;
82
+ status: typeof CUSTOMER_AGENT_INTERVIEW_STATUS.ACTIVE;
83
+ };
84
+ getActiveSession(): InterviewSessionResponse | null;
85
+ loadReward(sessionId?: string | undefined): Promise<unknown>;
86
+ syncAvailability: () => Promise<void>;
87
+ startInvitation(id: string): Promise<{
88
+ entryId: string;
89
+ session: InterviewSessionResponse;
90
+ sessionId: string;
91
+ }>;
92
+ sendMessage(content: string): Promise<void>;
93
+ };
@@ -0,0 +1,115 @@
1
+ import { ConversationContextPayload } from '../../sdk/conversation';
2
+ import { WidgetOptions } from '../../types';
3
+ export declare const INTERVIEW_SESSION_STATUS: Readonly<{
4
+ ABANDONED: "abandoned";
5
+ ABORTED: "aborted";
6
+ ACTIVE: "active";
7
+ COMPLETED: "completed";
8
+ DISMISSED: "dismissed";
9
+ }>;
10
+ export type InterviewStatus = (typeof INTERVIEW_SESSION_STATUS)[keyof typeof INTERVIEW_SESSION_STATUS];
11
+ export declare const CUSTOMER_AGENT_INTERVIEW_STATUS: Readonly<{
12
+ ACTIVE: "active";
13
+ AVAILABLE: "available";
14
+ CHECKING: "checking";
15
+ ERROR: "error";
16
+ IDLE: "idle";
17
+ TERMINAL: "terminal";
18
+ UNAVAILABLE: "unavailable";
19
+ }>;
20
+ export type CustomerAgentInterviewStatus = (typeof CUSTOMER_AGENT_INTERVIEW_STATUS)[keyof typeof CUSTOMER_AGENT_INTERVIEW_STATUS];
21
+ export declare const INTERVIEW_INVITATION_ACTION: Readonly<{
22
+ CLOSE: "close";
23
+ LATER: "later";
24
+ START: "start";
25
+ }>;
26
+ export type InterviewInvitationAction = (typeof INTERVIEW_INVITATION_ACTION)[keyof typeof INTERVIEW_INVITATION_ACTION];
27
+ export type InterviewInvitationChoice = Exclude<InterviewInvitationAction, typeof INTERVIEW_INVITATION_ACTION.START>;
28
+ export type InterviewMessage = {
29
+ content: string;
30
+ createdAt: string;
31
+ id: string;
32
+ role: "assistant" | "user";
33
+ };
34
+ export type InterviewSessionResponse = {
35
+ messages: InterviewMessage[];
36
+ sessionId: string;
37
+ status: InterviewStatus;
38
+ };
39
+ export type InterviewInvitationCard = {
40
+ body: string;
41
+ laterCta: string;
42
+ startCta: string;
43
+ title: string;
44
+ };
45
+ export type InterviewEligibilityResponse = {
46
+ eligible: false;
47
+ status?: string;
48
+ } | {
49
+ campaignId: string;
50
+ eligible: true;
51
+ invitation: InterviewInvitationCard;
52
+ showRequestId: string;
53
+ status?: typeof CUSTOMER_AGENT_INTERVIEW_STATUS.AVAILABLE | string;
54
+ variantKey?: string | null;
55
+ };
56
+ export type CustomerAgentInterviewState = {
57
+ status: typeof CUSTOMER_AGENT_INTERVIEW_STATUS.CHECKING | typeof CUSTOMER_AGENT_INTERVIEW_STATUS.ERROR | typeof CUSTOMER_AGENT_INTERVIEW_STATUS.IDLE | typeof CUSTOMER_AGENT_INTERVIEW_STATUS.UNAVAILABLE;
58
+ error?: {
59
+ message: string;
60
+ };
61
+ } | {
62
+ body: string;
63
+ campaignId: string;
64
+ laterCta: string;
65
+ startCta: string;
66
+ status: typeof CUSTOMER_AGENT_INTERVIEW_STATUS.AVAILABLE;
67
+ title: string;
68
+ } | {
69
+ entryId: `interview/session/${string}`;
70
+ sessionId: string;
71
+ status: typeof CUSTOMER_AGENT_INTERVIEW_STATUS.ACTIVE;
72
+ title?: string;
73
+ } | {
74
+ sessionId: string;
75
+ sessionStatus: Exclude<InterviewStatus, typeof INTERVIEW_SESSION_STATUS.ACTIVE>;
76
+ status: typeof CUSTOMER_AGENT_INTERVIEW_STATUS.TERMINAL;
77
+ };
78
+ export type CachedInterviewSession = {
79
+ entryId: string;
80
+ priority: number;
81
+ sessionId: string;
82
+ title: string;
83
+ };
84
+ export type InterviewSessionCache = {
85
+ clear(options: WidgetOptions): void;
86
+ read(options: WidgetOptions): CachedInterviewSession | null;
87
+ write(options: WidgetOptions, session: CachedInterviewSession): void;
88
+ };
89
+ export type InterviewRequestOptions = {
90
+ signal?: AbortSignal;
91
+ };
92
+ export type InterviewClient = {
93
+ checkEligibility(payload: Record<string, unknown>, options?: InterviewRequestOptions): Promise<InterviewEligibilityResponse>;
94
+ chooseInvitation(id: string, payload: {
95
+ choice: InterviewInvitationChoice;
96
+ }): Promise<void>;
97
+ createInvitation(payload: Record<string, unknown>): Promise<{
98
+ invitationId: string;
99
+ }>;
100
+ getReward(sessionId: string): Promise<unknown>;
101
+ getSession(sessionId: string, options?: InterviewRequestOptions): Promise<InterviewSessionResponse>;
102
+ sendMessage(sessionId: string, payload: {
103
+ clientMessageId: string;
104
+ content: string;
105
+ locale?: string;
106
+ }): Promise<{
107
+ assistantMessage: string;
108
+ completion?: {
109
+ reason: string;
110
+ };
111
+ duplicate?: true;
112
+ sessionStatus: InterviewStatus;
113
+ }>;
114
+ startInvitation(id: string, payload: ConversationContextPayload): Promise<InterviewSessionResponse>;
115
+ };
@@ -0,0 +1,2 @@
1
+ import { SupportApiClient } from './supportTypes';
2
+ export declare function createSupportApiClient(apiOrigin: string): SupportApiClient;
@@ -0,0 +1,4 @@
1
+ import { WidgetOptions } from '../../types';
2
+ import { SupportSessionCache } from './supportTypes';
3
+ export declare function getSupportSessionKey(options: WidgetOptions): string;
4
+ export declare function createLocalStorageSupportSessionCache(): SupportSessionCache;
@@ -0,0 +1,43 @@
1
+ import { CustomerAgentApiMessage } from '../../sdk/apiClient';
2
+ import { ConversationContextPayload } from '../../sdk/conversation';
3
+ import { WidgetOptions } from '../../types';
4
+ import { CustomerAgentSupportState, SupportApiClient, SupportSessionCache } from './supportTypes';
5
+ export type SupportSessionServiceDeps = {
6
+ api: SupportApiClient;
7
+ buildContextPayload?: (options: WidgetOptions) => ConversationContextPayload;
8
+ cache: SupportSessionCache;
9
+ emitConversationCreated(conversationId: string): void;
10
+ emitStateChanged(state: CustomerAgentSupportState): void;
11
+ getOptions(): WidgetOptions;
12
+ onSessionReady?(options: WidgetOptions, session: {
13
+ conversationId: string;
14
+ messages: CustomerAgentApiMessage[];
15
+ }): void;
16
+ };
17
+ export type SupportSessionService = ReturnType<typeof createSupportSessionService>;
18
+ export declare function createSupportSessionService({ api, buildContextPayload: buildPayload, cache, emitConversationCreated, emitStateChanged, getOptions, onSessionReady }: SupportSessionServiceDeps): {
19
+ ensureSession(): Promise<{
20
+ conversationId: string;
21
+ messages: CustomerAgentApiMessage[];
22
+ }>;
23
+ getState(): CustomerAgentSupportState;
24
+ getSessionSnapshot(): {
25
+ conversationId: string;
26
+ messages: CustomerAgentApiMessage[];
27
+ } | null;
28
+ invalidateSession(): void;
29
+ syncCachedSession(): Promise<void>;
30
+ };
31
+ export declare function createDefaultSupportSessionService(deps: Omit<SupportSessionServiceDeps, "buildContextPayload" | "cache">): {
32
+ ensureSession(): Promise<{
33
+ conversationId: string;
34
+ messages: CustomerAgentApiMessage[];
35
+ }>;
36
+ getState(): CustomerAgentSupportState;
37
+ getSessionSnapshot(): {
38
+ conversationId: string;
39
+ messages: CustomerAgentApiMessage[];
40
+ } | null;
41
+ invalidateSession(): void;
42
+ syncCachedSession(): Promise<void>;
43
+ };
@@ -0,0 +1,35 @@
1
+ import { CustomerAgentApiMessage } from '../../sdk/apiClient';
2
+ import { ConversationContextPayload } from '../../sdk/conversation';
3
+ import { WidgetOptions } from '../../types';
4
+ export declare const CUSTOMER_AGENT_SUPPORT_STATUS: Readonly<{
5
+ ERROR: "error";
6
+ IDLE: "idle";
7
+ READY: "ready";
8
+ REFRESHING: "refreshing";
9
+ STARTING: "starting";
10
+ }>;
11
+ export type CustomerAgentSupportStatus = (typeof CUSTOMER_AGENT_SUPPORT_STATUS)[keyof typeof CUSTOMER_AGENT_SUPPORT_STATUS];
12
+ export type CustomerAgentSupportState = {
13
+ status: typeof CUSTOMER_AGENT_SUPPORT_STATUS.ERROR | typeof CUSTOMER_AGENT_SUPPORT_STATUS.IDLE | typeof CUSTOMER_AGENT_SUPPORT_STATUS.REFRESHING | typeof CUSTOMER_AGENT_SUPPORT_STATUS.STARTING;
14
+ error?: {
15
+ message: string;
16
+ };
17
+ } | {
18
+ status: typeof CUSTOMER_AGENT_SUPPORT_STATUS.READY;
19
+ conversationId: string;
20
+ };
21
+ export type SupportSession = {
22
+ conversationId: string;
23
+ messages: CustomerAgentApiMessage[];
24
+ };
25
+ export type SupportApiClient = {
26
+ startSession(payload: ConversationContextPayload, conversationId: string | null): Promise<SupportSession>;
27
+ updateContext?(payload: ConversationContextPayload & {
28
+ conversationId: string;
29
+ }, conversationId: string): Promise<unknown>;
30
+ };
31
+ export type SupportSessionCache = {
32
+ clear(options: WidgetOptions): void;
33
+ read(options: WidgetOptions): string | null;
34
+ write(options: WidgetOptions, conversationId: string): void;
35
+ };
@@ -0,0 +1,103 @@
1
+ export type ApiSuccess<TData> = {
2
+ ok: true;
3
+ data: TData;
4
+ meta: {
5
+ requestId: string;
6
+ serverTime: string;
7
+ version: string;
8
+ };
9
+ };
10
+ export type ApiFailure = {
11
+ ok: false;
12
+ error: {
13
+ code: string;
14
+ details?: unknown;
15
+ message: string;
16
+ };
17
+ meta?: {
18
+ requestId: string;
19
+ serverTime: string;
20
+ version: string;
21
+ };
22
+ };
23
+ export type CustomerAgentApiMessage = {
24
+ id: string;
25
+ attachments?: CustomerAgentApiAttachment[];
26
+ assistantAuthor: "llm" | "human" | null;
27
+ role: "user" | "assistant";
28
+ content: string;
29
+ createdAt: string;
30
+ };
31
+ export type CustomerAgentApiAttachment = {
32
+ expiresAt?: string;
33
+ filename: string;
34
+ id: string;
35
+ mimeType: string;
36
+ sizeBytes: number;
37
+ url: string;
38
+ };
39
+ export type UploadAttachmentResponse = {
40
+ attachmentId: string;
41
+ filename: string;
42
+ mimeType: string;
43
+ sizeBytes: number;
44
+ url: string;
45
+ };
46
+ export type StartSessionResponse = {
47
+ conversationId: string;
48
+ context: {
49
+ customerOrigin: string | null;
50
+ locale: string | null;
51
+ pagePath: string | null;
52
+ pageUrl: string | null;
53
+ visitorId: string | null;
54
+ };
55
+ messages: CustomerAgentApiMessage[];
56
+ };
57
+ export type SendMessageResponse = {
58
+ conversationId: string;
59
+ userMessage: CustomerAgentApiMessage;
60
+ assistantMessage: CustomerAgentApiMessage;
61
+ handoff: {
62
+ needed: boolean;
63
+ reason: string | null;
64
+ eventId: string | null;
65
+ };
66
+ };
67
+ export type UpdateContextResponse = {
68
+ conversationId: string;
69
+ };
70
+ export type PublicAppConfigResponse = {
71
+ appId: string;
72
+ branding: Record<string, unknown>;
73
+ businessHours: Record<string, unknown>;
74
+ supportEmail: string;
75
+ welcomeMessage: Record<string, string>;
76
+ };
77
+ type RequestOptions = {
78
+ body?: Record<string, unknown>;
79
+ conversationId?: string | null;
80
+ method?: "GET" | "PATCH" | "POST";
81
+ signal?: AbortSignal;
82
+ };
83
+ export declare class CustomerAgentApiError extends Error {
84
+ code: string;
85
+ requestId: string | null;
86
+ status: number;
87
+ constructor(message: string, options: {
88
+ code: string;
89
+ requestId?: string | null;
90
+ status: number;
91
+ });
92
+ }
93
+ export declare function createWidgetApiClient(apiBaseUrl: string): {
94
+ request: <TData>(path: string, options?: RequestOptions) => Promise<{
95
+ data: TData;
96
+ response: Response;
97
+ }>;
98
+ upload: <TData>(path: string, formData: FormData, options?: Pick<RequestOptions, "conversationId" | "signal">) => Promise<{
99
+ data: TData;
100
+ response: Response;
101
+ }>;
102
+ };
103
+ export {};
@@ -0,0 +1,4 @@
1
+ import { CustomerAgentOptions } from './public-types';
2
+ export declare function createWidgetId(): string;
3
+ export declare function resolveApiOrigin(): string;
4
+ export declare function normalizeOptions(options: CustomerAgentOptions, widgetId: string): CurrentCustomerAgentOptions;
@@ -0,0 +1,28 @@
1
+ export declare const CUSTOMER_AGENT_EVENTS: Readonly<{
2
+ readonly BUG_REPORTED: "support.bug_reported";
3
+ readonly CONVERSATION_CREATED: "conversation.created";
4
+ readonly ERROR: "error";
5
+ readonly FEEDBACK_SUBMITTED: "support.feedback_submitted";
6
+ readonly HANDOFF_REQUESTED: "support.handoff_requested";
7
+ readonly INTERVIEW_INVITATION_CLOSED: "interview.invitation_closed";
8
+ readonly INTERVIEW_INVITATION_LATER: "interview.invitation_later";
9
+ readonly INTERVIEW_INVITATION_SHOWN: "interview.invitation_shown";
10
+ readonly INTERVIEW_AVAILABLE: "interview.available";
11
+ readonly INTERVIEW_REWARD_UPDATED: "interview.reward_updated";
12
+ readonly INTERVIEW_STATE_CHANGED: "interview.state_changed";
13
+ readonly INTERVIEW_SESSION_COMPLETED: "interview.session_completed";
14
+ readonly INTERVIEW_SESSION_STARTED: "interview.session_started";
15
+ readonly MESSAGE_COMPLETED: "message.completed";
16
+ readonly MESSAGE_FAILED: "message.failed";
17
+ readonly MESSAGE_RETRY: "message.retry";
18
+ readonly MESSAGE_SEND_FAILED: "message.send_failed";
19
+ readonly MESSAGE_SENT: "message.sent";
20
+ readonly MESSAGE_STARTED: "message.started";
21
+ readonly SUPPORT_STATE_CHANGED: "support.state_changed";
22
+ readonly TRANSCRIPT_DOWNLOADED: "transcript.downloaded";
23
+ readonly WIDGET_CLOSED: "widget.closed";
24
+ readonly WIDGET_COLLAPSED: "widget.collapsed";
25
+ readonly WIDGET_EXPANDED: "widget.expanded";
26
+ readonly WIDGET_OPENED: "widget.opened";
27
+ readonly WIDGET_READY: "widget.ready";
28
+ }>;
@@ -0,0 +1,36 @@
1
+ import { WidgetContextJson, WidgetUser } from '../types';
2
+ import { CustomerAgentEventMap, CustomerAgentEventName } from './events';
3
+ import { CustomerAgentGlobal, CustomerAgentInterviewInvitationChoice, CustomerAgentOptions, CustomerAgentTarget, CustomerAgentWidget, SetContextOptions } from './public-types';
4
+ declare function boot(options: CustomerAgentOptions): CustomerAgentWidget;
5
+ declare function ensureInvitation(): Promise<{
6
+ invitationId: string;
7
+ } | null>;
8
+ declare function startInvitation(invitationId: string): Promise<{
9
+ entryId: string;
10
+ sessionId: string;
11
+ } | null>;
12
+ declare function startInterview(): Promise<{
13
+ entryId: string;
14
+ sessionId: string;
15
+ } | null>;
16
+ declare function chooseInvitation(invitationId: string, choice: CustomerAgentInterviewInvitationChoice): Promise<void>;
17
+ declare function sendInterviewMessage(content: string): Promise<void>;
18
+ declare function loadInterviewReward(sessionId?: string): Promise<unknown>;
19
+ declare function update(options: Partial<CustomerAgentOptions>): void;
20
+ declare function show(target?: CustomerAgentTarget): void;
21
+ declare function hide(): void;
22
+ declare function toggle(target?: CustomerAgentTarget): void;
23
+ declare function openEntry(entryId: string): void;
24
+ declare function shutdown(): void;
25
+ declare function identify(user: WidgetUser): void;
26
+ declare function setContext(context: WidgetContextJson, options?: SetContextOptions): void;
27
+ declare function getSession(): Promise<{
28
+ conversationId: string;
29
+ } | null>;
30
+ declare function getSupportState(): import('./public-types').CustomerAgentSupportState | null;
31
+ declare function getInterviewState(): import('./public-types').CustomerAgentInterviewState | null;
32
+ declare function getInterviewSession(): import('./public-types').CustomerAgentInterviewSession | null;
33
+ declare function getState(): import('./public-types').CustomerAgentState | null;
34
+ declare function on<TEventName extends CustomerAgentEventName>(eventName: TEventName, handler: (event: CustomerAgentEventMap[TEventName]) => void): () => void;
35
+ export declare const CustomerAgent: CustomerAgentGlobal;
36
+ export { boot, chooseInvitation, ensureInvitation, getInterviewState, getInterviewSession, getSession, getState, getSupportState, hide, identify, on, openEntry, loadInterviewReward, sendInterviewMessage, setContext, show, shutdown, startInterview, startInvitation, toggle, update };
@@ -0,0 +1,56 @@
1
+ import { ThreadMessageLike } from '@assistant-ui/react';
2
+ import { WidgetOptions } from '../types';
3
+ import { CustomerAgentApiAttachment, CustomerAgentApiMessage, SendMessageResponse, UpdateContextResponse } from './apiClient';
4
+ export type ConversationContextPayload = {
5
+ appId: string;
6
+ customerOrigin?: string;
7
+ deviceInfo?: Record<string, unknown>;
8
+ locale?: string;
9
+ pagePath?: string;
10
+ pageUrl?: string;
11
+ userContext?: Record<string, unknown>;
12
+ visitorId?: string;
13
+ widgetId?: string;
14
+ };
15
+ export type CustomerAgentConversationSession = {
16
+ cacheKey: string;
17
+ conversationId: string;
18
+ messages: CustomerAgentApiMessage[];
19
+ };
20
+ type EnsureSessionOptions = {
21
+ onConversationCreated?(conversationId: string): void;
22
+ onSessionInvalidated?(conversationId: string): void;
23
+ };
24
+ export type UploadedWidgetAttachment = CustomerAgentApiAttachment;
25
+ export declare class CustomerAgentSessionInvalidatedError extends Error {
26
+ readonly conversationId: string;
27
+ constructor(conversationId: string);
28
+ }
29
+ export declare function buildContextPayload(options: WidgetOptions): ConversationContextPayload;
30
+ export declare function toThreadMessages(messages: readonly CustomerAgentApiMessage[]): ThreadMessageLike[];
31
+ export declare function getLatestUserMessageText(messages: readonly {
32
+ content: readonly unknown[];
33
+ role: string;
34
+ }[]): string;
35
+ export declare class WidgetConversation {
36
+ private apiOrigin;
37
+ private client;
38
+ private lastContextFingerprint;
39
+ private session;
40
+ private sessionPromise;
41
+ private getClient;
42
+ clear(options: WidgetOptions): void;
43
+ hydrateSession(options: WidgetOptions, session: Pick<CustomerAgentConversationSession, "conversationId" | "messages">): void;
44
+ ensureSession(options: WidgetOptions, sessionOptions?: EnsureSessionOptions): Promise<CustomerAgentConversationSession>;
45
+ sendMessage(options: WidgetOptions, message: string, attachments: readonly {
46
+ id: string;
47
+ }[], signal: AbortSignal, sessionOptions?: EnsureSessionOptions): Promise<SendMessageResponse>;
48
+ refreshSession(options: WidgetOptions, signal?: AbortSignal): Promise<CustomerAgentConversationSession | null>;
49
+ updateContext(options: WidgetOptions): Promise<UpdateContextResponse | null>;
50
+ uploadAttachment(options: WidgetOptions, file: File, sessionOptions?: EnsureSessionOptions): Promise<UploadedWidgetAttachment>;
51
+ private startSession;
52
+ private postMessage;
53
+ private getHydratedSession;
54
+ }
55
+ export declare const widgetConversation: WidgetConversation;
56
+ export {};