@chatsystem/client 1.2.6 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,73 +1,19 @@
1
1
  import { CompanySettingsDTO } from '@chatsystem/shared';
2
+ import { InteractiveWidgetResultDTO } from '@chatsystem/shared';
2
3
  import { JSX as JSX_2 } from 'react/jsx-runtime';
4
+ import { ReactNode } from 'react';
3
5
 
4
6
  /**
5
- * Embeds the ChatSystem chatbot in a React application.
7
+ * Embeds one ChatSystem widget in a React application.
6
8
  *
7
- * Identity integration is optional. Without `identityProvider`, all existing
8
- * anonymous behavior remains unchanged.
9
+ * This remains the recommended API for a single visual widget. Use
10
+ * `WidgetRuntime` with several `WidgetView` children only when the same Agent
11
+ * conversation must be visible in several layouts on one page.
9
12
  */
10
- export declare function App({ cssHref, appToken, agentId, displayMode, shouldDisplayLogs, ...contentProps }: AppProps): JSX_2.Element;
13
+ export declare function App({ cssHref, displayMode, appToken, agentId, shouldDisplayLogs, apiUrl, identityProvider, runtimeAdapter, }: AppProps): JSX_2.Element;
11
14
 
12
- /** Public configuration for the ChatSystem React widget. */
13
- export declare type AppProps = {
14
- /**
15
- * Public ChatSystem app token identifying the customer installation.
16
- * This is not a secret and does not authenticate the end user.
17
- */
18
- appToken: string;
19
- /** Optional agent to use instead of the company's default agent. */
20
- agentId?: number;
21
- /** Displays either the launcher widget or the inline chatbox. */
22
- displayMode?: DisplayModesTypes;
23
- /** Enables diagnostic widget logs. Keep disabled in normal production use. */
24
- shouldDisplayLogs?: boolean;
25
- /**
26
- * Optional ChatSystem API base URL. Omit it for the standard hosted API.
27
- *
28
- * This is primarily useful for internal testing and explicitly supported
29
- * self-hosted deployments. HTTPS is mandatory except for localhost.
30
- */
31
- apiUrl?: string;
32
- /**
33
- * Optional bridge to the host website's existing authenticated session.
34
- *
35
- * Implement this in the customer's frontend integration code, normally next
36
- * to the component that renders `<App />`. Its `getToken()` method should
37
- * call one same-origin customer endpoint, such as
38
- * `/api/chatsystem/identity`. That customer endpoint authenticates the user
39
- * with the host's existing cookie/session/SSO and returns a short-lived
40
- * ChatSystem widget identity JWT.
41
- *
42
- * Never return the company API key, the host's primary access token, session
43
- * cookie, or SSO token. The widget keeps the returned ChatSystem JWT in
44
- * memory only. Omit this property to keep the widget fully anonymous.
45
- *
46
- * @example
47
- * ```tsx
48
- * <App
49
- * appToken="public-app-token"
50
- * identityProvider={{
51
- * getToken: async ({ interactive }) => {
52
- * const response = await fetch('/api/chatsystem/identity', {
53
- * credentials: 'include',
54
- * });
55
- * if (!response.ok) return null;
56
- * return (await response.json()).token ?? null;
57
- * },
58
- * subscribe: (onIdentityChanged) =>
59
- * customerAuth.onAuthStateChanged(onIdentityChanged),
60
- * }}
61
- * />
62
- * ```
63
- */
64
- identityProvider?: WidgetIdentityProvider;
65
- /**
66
- * Optional alternate server boundary for first-party embedded experiences.
67
- * The canonical widget still owns settings, messages, streaming and scroll.
68
- */
69
- runtimeAdapter?: WidgetRuntimeAdapter;
70
- } & ShadowControls;
15
+ /** Public configuration for the backwards-compatible ChatSystem widget. */
16
+ export declare type AppProps = Omit<WidgetRuntimeProps, "children"> & WidgetViewProps;
71
17
 
72
18
  /**
73
19
  * API-owned commercial presentation settings. Branding is deliberately not a
@@ -85,6 +31,7 @@ export declare type CompanySettingsWithBranding = CompanySettingsDTO & {
85
31
  };
86
32
  };
87
33
 
34
+ /** Supported visual presentations for a ChatSystem widget view. */
88
35
  declare enum DisplayModeEnum {
89
36
  LAUNCHER = "launcher",
90
37
  CHATBOX = "chatbox"
@@ -92,14 +39,10 @@ declare enum DisplayModeEnum {
92
39
 
93
40
  export declare type DisplayModesTypes = `${DisplayModeEnum}`;
94
41
 
95
- /** Controls how the widget's Shadow DOM receives its stylesheet. */
96
- export declare type ShadowControls = {
97
- /**
98
- * Optional URL for a prebuilt widget stylesheet. When omitted, the package
99
- * injects its bundled CSS into the Shadow DOM.
100
- */
42
+ export declare type ShadowControls = Readonly<{
43
+ /** Optional URL for a prebuilt widget stylesheet. */
101
44
  cssHref?: string;
102
- };
45
+ }>;
103
46
 
104
47
  /**
105
48
  * Connects the ChatSystem widget to the host website's existing authentication
@@ -163,6 +106,29 @@ export declare type WidgetIdentityRequest = {
163
106
  requiredCapabilities?: string[];
164
107
  };
165
108
 
109
+ declare type WidgetInteractionResultRequest = {
110
+ apiUrl: string;
111
+ appToken: string;
112
+ continuationId: string;
113
+ discussionId: number;
114
+ submissionId: string;
115
+ result: InteractiveWidgetResultDTO;
116
+ resultToken: string;
117
+ authorizationToken?: string;
118
+ signal: AbortSignal;
119
+ };
120
+
121
+ declare type WidgetInteractionResumeRequest = Omit<WidgetInteractionResultRequest, "submissionId" | "result">;
122
+
123
+ /**
124
+ * Owns one ChatSystem conversation and all of its mutable execution state.
125
+ *
126
+ * Render several `WidgetView` children to expose the same Agent conversation
127
+ * in different layouts. A prompt, stream or stop action remains singular and
128
+ * is reflected by every view inside this boundary.
129
+ */
130
+ export declare function WidgetRuntime({ appToken, agentId, shouldDisplayLogs, apiUrl, identityProvider, runtimeAdapter, children, }: WidgetRuntimeProps): JSX_2.Element;
131
+
166
132
  /**
167
133
  * Reuses the complete ChatSystem conversation UI with a different server
168
134
  * boundary.
@@ -177,10 +143,37 @@ export declare type WidgetIdentityRequest = {
177
143
  export declare interface WidgetRuntimeAdapter {
178
144
  loadCompanySettings(request: WidgetSettingsRequest): Promise<CompanySettingsWithBranding>;
179
145
  sendTextPrompt(request: WidgetTextPromptRequest): Promise<Response>;
146
+ /** Optional transport: its presence advertises V2 interactive continuation. */
147
+ submitInteractionResult?(request: WidgetInteractionResultRequest): Promise<Response>;
148
+ /** Resumes an already accepted submission without retransmitting its values. */
149
+ resumeInteraction?(request: WidgetInteractionResumeRequest): Promise<Response>;
180
150
  /** Called after a successful response stream has been fully consumed. */
181
151
  onAssistantResponseCompleted?(response: Response): void | Promise<void>;
182
152
  }
183
153
 
154
+ export declare type WidgetRuntimeProps = Readonly<{
155
+ /** Public ChatSystem app token identifying the customer installation. */
156
+ appToken: string;
157
+ /** Optional agent to use instead of the company's default agent. */
158
+ agentId?: number;
159
+ /** Enables diagnostic widget logs. Keep disabled in production. */
160
+ shouldDisplayLogs?: boolean;
161
+ /** Optional ChatSystem API base URL for supported custom environments. */
162
+ apiUrl?: string;
163
+ /**
164
+ * Optional bridge to the host website's authenticated session.
165
+ *
166
+ * Its `getToken()` implementation must call a same-origin customer endpoint
167
+ * that exchanges the existing host session for a short-lived ChatSystem
168
+ * widget identity JWT. Never expose a company API key, session cookie or the
169
+ * host application's own access token to this client component.
170
+ */
171
+ identityProvider?: WidgetIdentityProvider;
172
+ /** Optional alternate transport for first-party embedded experiences. */
173
+ runtimeAdapter?: WidgetRuntimeAdapter;
174
+ children: ReactNode;
175
+ }>;
176
+
184
177
  export declare type WidgetSettingsRequest = {
185
178
  apiUrl: string;
186
179
  appToken: string;
@@ -197,4 +190,18 @@ export declare type WidgetTextPromptRequest = {
197
190
  signal: AbortSignal;
198
191
  };
199
192
 
193
+ /**
194
+ * Renders one visual presentation of the surrounding `WidgetRuntime`.
195
+ *
196
+ * The Shadow DOM and launcher open state belong to this view. Conversation,
197
+ * loading and cancellation state remain owned by the runtime, so mounting or
198
+ * closing another view cannot interrupt the shared Agent response.
199
+ */
200
+ export declare function WidgetView({ cssHref, displayMode, }: WidgetViewProps): JSX_2.Element;
201
+
202
+ export declare type WidgetViewProps = Readonly<{
203
+ /** Displays either the launcher widget or the inline chatbox. */
204
+ displayMode?: DisplayModesTypes;
205
+ }> & ShadowControls;
206
+
200
207
  export { }