@chatsystem/client 1.2.5 → 1.3.1
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 +23 -0
- package/dist/index.cjs +61 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +58 -70
- package/dist/index.mjs +22537 -22398
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,73 +1,18 @@
|
|
|
1
1
|
import { CompanySettingsDTO } from '@chatsystem/shared';
|
|
2
2
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
* Embeds
|
|
6
|
+
* Embeds one ChatSystem widget in a React application.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
8
|
+
* This remains the recommended API for a single visual widget. Use
|
|
9
|
+
* `WidgetRuntime` with several `WidgetView` children only when the same Agent
|
|
10
|
+
* conversation must be visible in several layouts on one page.
|
|
9
11
|
*/
|
|
10
|
-
export declare function App({ cssHref, appToken, agentId,
|
|
12
|
+
export declare function App({ cssHref, displayMode, appToken, agentId, shouldDisplayLogs, apiUrl, identityProvider, runtimeAdapter, }: AppProps): JSX_2.Element;
|
|
11
13
|
|
|
12
|
-
/** Public configuration for the ChatSystem
|
|
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;
|
|
14
|
+
/** Public configuration for the backwards-compatible ChatSystem widget. */
|
|
15
|
+
export declare type AppProps = Omit<WidgetRuntimeProps, "children"> & WidgetViewProps;
|
|
71
16
|
|
|
72
17
|
/**
|
|
73
18
|
* API-owned commercial presentation settings. Branding is deliberately not a
|
|
@@ -85,6 +30,7 @@ export declare type CompanySettingsWithBranding = CompanySettingsDTO & {
|
|
|
85
30
|
};
|
|
86
31
|
};
|
|
87
32
|
|
|
33
|
+
/** Supported visual presentations for a ChatSystem widget view. */
|
|
88
34
|
declare enum DisplayModeEnum {
|
|
89
35
|
LAUNCHER = "launcher",
|
|
90
36
|
CHATBOX = "chatbox"
|
|
@@ -92,14 +38,10 @@ declare enum DisplayModeEnum {
|
|
|
92
38
|
|
|
93
39
|
export declare type DisplayModesTypes = `${DisplayModeEnum}`;
|
|
94
40
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Optional URL for a prebuilt widget stylesheet. When omitted, the package
|
|
99
|
-
* injects its bundled CSS into the Shadow DOM.
|
|
100
|
-
*/
|
|
41
|
+
export declare type ShadowControls = Readonly<{
|
|
42
|
+
/** Optional URL for a prebuilt widget stylesheet. */
|
|
101
43
|
cssHref?: string;
|
|
102
|
-
}
|
|
44
|
+
}>;
|
|
103
45
|
|
|
104
46
|
/**
|
|
105
47
|
* Connects the ChatSystem widget to the host website's existing authentication
|
|
@@ -163,6 +105,15 @@ export declare type WidgetIdentityRequest = {
|
|
|
163
105
|
requiredCapabilities?: string[];
|
|
164
106
|
};
|
|
165
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Owns one ChatSystem conversation and all of its mutable execution state.
|
|
110
|
+
*
|
|
111
|
+
* Render several `WidgetView` children to expose the same Agent conversation
|
|
112
|
+
* in different layouts. A prompt, stream or stop action remains singular and
|
|
113
|
+
* is reflected by every view inside this boundary.
|
|
114
|
+
*/
|
|
115
|
+
export declare function WidgetRuntime({ appToken, agentId, shouldDisplayLogs, apiUrl, identityProvider, runtimeAdapter, children, }: WidgetRuntimeProps): JSX_2.Element;
|
|
116
|
+
|
|
166
117
|
/**
|
|
167
118
|
* Reuses the complete ChatSystem conversation UI with a different server
|
|
168
119
|
* boundary.
|
|
@@ -181,6 +132,29 @@ export declare interface WidgetRuntimeAdapter {
|
|
|
181
132
|
onAssistantResponseCompleted?(response: Response): void | Promise<void>;
|
|
182
133
|
}
|
|
183
134
|
|
|
135
|
+
export declare type WidgetRuntimeProps = Readonly<{
|
|
136
|
+
/** Public ChatSystem app token identifying the customer installation. */
|
|
137
|
+
appToken: string;
|
|
138
|
+
/** Optional agent to use instead of the company's default agent. */
|
|
139
|
+
agentId?: number;
|
|
140
|
+
/** Enables diagnostic widget logs. Keep disabled in production. */
|
|
141
|
+
shouldDisplayLogs?: boolean;
|
|
142
|
+
/** Optional ChatSystem API base URL for supported custom environments. */
|
|
143
|
+
apiUrl?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Optional bridge to the host website's authenticated session.
|
|
146
|
+
*
|
|
147
|
+
* Its `getToken()` implementation must call a same-origin customer endpoint
|
|
148
|
+
* that exchanges the existing host session for a short-lived ChatSystem
|
|
149
|
+
* widget identity JWT. Never expose a company API key, session cookie or the
|
|
150
|
+
* host application's own access token to this client component.
|
|
151
|
+
*/
|
|
152
|
+
identityProvider?: WidgetIdentityProvider;
|
|
153
|
+
/** Optional alternate transport for first-party embedded experiences. */
|
|
154
|
+
runtimeAdapter?: WidgetRuntimeAdapter;
|
|
155
|
+
children: ReactNode;
|
|
156
|
+
}>;
|
|
157
|
+
|
|
184
158
|
export declare type WidgetSettingsRequest = {
|
|
185
159
|
apiUrl: string;
|
|
186
160
|
appToken: string;
|
|
@@ -197,4 +171,18 @@ export declare type WidgetTextPromptRequest = {
|
|
|
197
171
|
signal: AbortSignal;
|
|
198
172
|
};
|
|
199
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Renders one visual presentation of the surrounding `WidgetRuntime`.
|
|
176
|
+
*
|
|
177
|
+
* The Shadow DOM and launcher open state belong to this view. Conversation,
|
|
178
|
+
* loading and cancellation state remain owned by the runtime, so mounting or
|
|
179
|
+
* closing another view cannot interrupt the shared Agent response.
|
|
180
|
+
*/
|
|
181
|
+
export declare function WidgetView({ cssHref, displayMode, }: WidgetViewProps): JSX_2.Element;
|
|
182
|
+
|
|
183
|
+
export declare type WidgetViewProps = Readonly<{
|
|
184
|
+
/** Displays either the launcher widget or the inline chatbox. */
|
|
185
|
+
displayMode?: DisplayModesTypes;
|
|
186
|
+
}> & ShadowControls;
|
|
187
|
+
|
|
200
188
|
export { }
|