@chatcops/widget 0.6.0 → 1.0.0-rc.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.
- package/README.md +2 -1
- package/dist/api/client.d.ts +17 -2
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/protocol.d.ts +7 -1
- package/dist/api/protocol.d.ts.map +1 -1
- package/dist/api/turnstile.d.ts.map +1 -1
- package/dist/api/types.d.ts +7 -0
- package/dist/api/types.d.ts.map +1 -1
- package/dist/chatcops.esm.js +1094 -499
- package/dist/chatcops.full.min.js +1 -0
- package/dist/chatcops.min.js +1 -1
- package/dist/chatcops.panel.js +1 -0
- package/dist/chunks/prechat-form-DiHgHUnU.js +1 -0
- package/dist/chunks/turnstile-CAnVL3fK.js +1 -0
- package/dist/dom/bubble.d.ts +3 -0
- package/dist/dom/bubble.d.ts.map +1 -1
- package/dist/dom/fab.d.ts +4 -1
- package/dist/dom/fab.d.ts.map +1 -1
- package/dist/dom/icons.d.ts +4 -0
- package/dist/dom/icons.d.ts.map +1 -0
- package/dist/dom/input.d.ts +1 -0
- package/dist/dom/input.d.ts.map +1 -1
- package/dist/dom/messages.d.ts +38 -1
- package/dist/dom/messages.d.ts.map +1 -1
- package/dist/dom/panel.d.ts +8 -0
- package/dist/dom/panel.d.ts.map +1 -1
- package/dist/dom/prechat-form.d.ts.map +1 -1
- package/dist/dom/shadow.d.ts +10 -1
- package/dist/dom/shadow.d.ts.map +1 -1
- package/dist/i18n.d.ts +7 -1
- package/dist/i18n.d.ts.map +1 -1
- package/dist/index.d.ts +41 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/loader/index.d.ts +2 -0
- package/dist/loader/index.d.ts.map +1 -0
- package/dist/loader/loader.d.ts +71 -0
- package/dist/loader/loader.d.ts.map +1 -0
- package/dist/locales/ar.d.ts +4 -0
- package/dist/locales/ar.d.ts.map +1 -0
- package/dist/locales/ar.js +1 -0
- package/dist/locales/de.d.ts +4 -0
- package/dist/locales/de.d.ts.map +1 -0
- package/dist/locales/de.js +1 -0
- package/dist/locales/es.d.ts +4 -0
- package/dist/locales/es.d.ts.map +1 -0
- package/dist/locales/es.js +1 -0
- package/dist/locales/fr.d.ts +4 -0
- package/dist/locales/fr.d.ts.map +1 -0
- package/dist/locales/fr.js +1 -0
- package/dist/locales/he.d.ts +4 -0
- package/dist/locales/he.d.ts.map +1 -0
- package/dist/locales/he.js +1 -0
- package/dist/locales/hi.d.ts +4 -0
- package/dist/locales/hi.d.ts.map +1 -0
- package/dist/locales/hi.js +1 -0
- package/dist/locales/it.d.ts +4 -0
- package/dist/locales/it.d.ts.map +1 -0
- package/dist/locales/it.js +1 -0
- package/dist/locales/ja.d.ts +4 -0
- package/dist/locales/ja.d.ts.map +1 -0
- package/dist/locales/ja.js +1 -0
- package/dist/locales/ko.d.ts +4 -0
- package/dist/locales/ko.d.ts.map +1 -0
- package/dist/locales/ko.js +1 -0
- package/dist/locales/nl.d.ts +4 -0
- package/dist/locales/nl.d.ts.map +1 -0
- package/dist/locales/nl.js +1 -0
- package/dist/locales/pt.d.ts +4 -0
- package/dist/locales/pt.d.ts.map +1 -0
- package/dist/locales/pt.js +1 -0
- package/dist/locales/ur.d.ts +4 -0
- package/dist/locales/ur.d.ts.map +1 -0
- package/dist/locales/ur.js +1 -0
- package/dist/locales/zh.d.ts +4 -0
- package/dist/locales/zh.d.ts.map +1 -0
- package/dist/locales/zh.js +1 -0
- package/dist/panel.d.ts +6 -0
- package/dist/panel.d.ts.map +1 -0
- package/dist/script-config.d.ts +5 -0
- package/dist/script-config.d.ts.map +1 -0
- package/dist/storage.d.ts +30 -10
- package/dist/storage.d.ts.map +1 -1
- package/dist/theme.d.ts +15 -0
- package/dist/theme.d.ts.map +1 -1
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/widget.d.ts +124 -15
- package/dist/widget.d.ts.map +1 -1
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -95,7 +95,8 @@ ChatCops.init({
|
|
|
95
95
|
placeholder: 'Type a message...',
|
|
96
96
|
|
|
97
97
|
// Behavior
|
|
98
|
-
|
|
98
|
+
persistence: 'local', // 'local' | 'session' | 'none', default: 'local'
|
|
99
|
+
historyTtlDays: 30, // drop saved chats older than this
|
|
99
100
|
maxMessages: 50, // max persisted messages
|
|
100
101
|
pageContext: true, // send page URL/title to API
|
|
101
102
|
autoOpen: 5000, // auto-open after ms (popup only)
|
package/dist/api/client.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type KeyStore } from '../storage.js';
|
|
1
2
|
import type { WidgetChatRequest, WidgetChatChunk } from './types.js';
|
|
2
3
|
export interface ChatClientOptions {
|
|
3
4
|
apiUrl: string;
|
|
@@ -5,6 +6,10 @@ export interface ChatClientOptions {
|
|
|
5
6
|
timeout?: number;
|
|
6
7
|
/** Cloudflare Turnstile site key, when the server checks Turnstile before issuing a session. */
|
|
7
8
|
turnstileSiteKey?: string;
|
|
9
|
+
/** The host site's signed token for a signed-in visitor, sent when asking for a session. */
|
|
10
|
+
userToken?: string;
|
|
11
|
+
/** Where the session token is kept. Defaults to localStorage; the widget passes its own store. */
|
|
12
|
+
store?: KeyStore;
|
|
8
13
|
}
|
|
9
14
|
export interface SendMessageOptions {
|
|
10
15
|
signal?: AbortSignal;
|
|
@@ -15,10 +20,20 @@ export declare class ChatClient {
|
|
|
15
20
|
private apiUrl;
|
|
16
21
|
private timeout;
|
|
17
22
|
private sessionKey;
|
|
18
|
-
/** The last token, kept across page loads so the server can resume the conversation. */
|
|
19
|
-
private saved
|
|
23
|
+
/** The last token, kept across page loads so the server can resume the conversation. Read on first use. */
|
|
24
|
+
private saved?;
|
|
25
|
+
private store;
|
|
20
26
|
private turnstileSiteKey?;
|
|
27
|
+
private userToken?;
|
|
21
28
|
constructor(options: ChatClientOptions);
|
|
29
|
+
/**
|
|
30
|
+
* The signed-in visitor's identity token for the next session, or none.
|
|
31
|
+
* The session token from before is dropped, so the next message gets one
|
|
32
|
+
* for the new identity (the server starts a new conversation for a
|
|
33
|
+
* different user).
|
|
34
|
+
*/
|
|
35
|
+
setUserToken(token: string | undefined): void;
|
|
36
|
+
get identity(): string | undefined;
|
|
22
37
|
sendMessage(request: WidgetChatRequest, options?: SendMessageOptions): AsyncGenerator<WidgetChatChunk>;
|
|
23
38
|
}
|
|
24
39
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/api/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAErE,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gGAAgG;IAChG,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,4FAA4F;IAC5F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kGAAkG;IAClG,KAAK,CAAC,EAAE,QAAQ,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAQD,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,UAAU,CAAS;IAC3B,2GAA2G;IAC3G,OAAO,CAAC,KAAK,CAAC,CAAmB;IACjC,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAClC,OAAO,CAAC,SAAS,CAAC,CAAS;gBAEf,OAAO,EAAE,iBAAiB;IAStC;;;;;OAKG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAO7C,IAAI,QAAQ,IAAI,MAAM,GAAG,SAAS,CAEjC;IAEM,WAAW,CAChB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,GAAE,kBAAuB,GAC/B,cAAc,CAAC,eAAe,CAAC;CA8KnC"}
|
package/dist/api/protocol.d.ts
CHANGED
|
@@ -25,9 +25,15 @@ export type WirePart = {
|
|
|
25
25
|
} | {
|
|
26
26
|
type: 'finish';
|
|
27
27
|
reason: string;
|
|
28
|
+
} | {
|
|
29
|
+
type: 'source';
|
|
30
|
+
sourceId: string;
|
|
31
|
+
url: string;
|
|
32
|
+
title?: string;
|
|
33
|
+
snippet?: string;
|
|
28
34
|
}
|
|
29
35
|
/** Parts the widget doesn't use yet. */
|
|
30
36
|
| {
|
|
31
|
-
type: 'text-start' | 'text-end' | '
|
|
37
|
+
type: 'text-start' | 'text-end' | 'tool-call' | 'tool-result' | 'handoff' | 'agent-message' | 'suggestions';
|
|
32
38
|
};
|
|
33
39
|
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/api/protocol.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAChB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,CAAC,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACzE;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACxD;IAAE,IAAI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Y,GAAG,UAAU,GAAG,WAAW,GAAG,aAAa,GAAG,SAAS,GAAG,eAAe,GAAG,aAAa,CAAA;CAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turnstile.d.ts","sourceRoot":"","sources":["../../src/api/turnstile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"turnstile.d.ts","sourceRoot":"","sources":["../../src/api/turnstile.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAwBrE"}
|
package/dist/api/types.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export interface WidgetChatRequest {
|
|
|
11
11
|
title: string;
|
|
12
12
|
description?: string;
|
|
13
13
|
contentSnippet?: string;
|
|
14
|
+
/** What the site added with setContext(). */
|
|
15
|
+
data?: Record<string, string>;
|
|
14
16
|
};
|
|
15
17
|
locale?: string;
|
|
16
18
|
userData?: Record<string, string>;
|
|
@@ -28,5 +30,10 @@ export interface WidgetChatChunk {
|
|
|
28
30
|
leadCaptured?: boolean;
|
|
29
31
|
leadData?: Record<string, unknown>;
|
|
30
32
|
suggestedActions?: string[];
|
|
33
|
+
/** A page the reply cited (protocol v1 `source` part). */
|
|
34
|
+
source?: {
|
|
35
|
+
url: string;
|
|
36
|
+
title?: string;
|
|
37
|
+
};
|
|
31
38
|
}
|
|
32
39
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/api/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iGAAiG;IACjG,UAAU,CAAC,EAAE,OAAO,GAAG;QAAE,kBAAkB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