@ezychat/web 0.1.57 → 0.1.59

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.
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Settings → AI: the team's phrase list for instant grey text (design:
3
+ * docs/features/ai-phrase-dictionary/design.md). The AI builds it in the background; admins see its
4
+ * state, rebuild it and add, edit or delete phrases. With several AI agents, one list per agent.
5
+ */
6
+ export declare function PhraseDictionarySection(): import("react").JSX.Element;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Settings → AI: the team-wide switch for AI reply suggestions. On by default on a new install with
3
+ * an AI connection, off after an update (a note says so); disabled without a connection.
4
+ */
5
+ export declare function ReplySuggestionsSection(): import("react").JSX.Element;
@@ -0,0 +1,67 @@
1
+ /** The team-wide switch and what the composer shows (any signed-in user may read it). */
2
+ export declare const replySuggestionsKey: readonly ["ai", "replySuggestions"];
3
+ export declare function useReplySuggestionsStatus(enabled?: boolean): import("@tanstack/react-query").UseQueryResult<{
4
+ enabled: boolean;
5
+ connected: boolean;
6
+ state: "unavailable" | "on" | "off";
7
+ upgraded: boolean;
8
+ }, Error>;
9
+ /** Up to 2 drafts for a direct chat (nothing is sent). */
10
+ export declare function fetchSuggestions(jid: string, signal: AbortSignal): Promise<{
11
+ suggestions: {
12
+ label: string;
13
+ text: string;
14
+ }[];
15
+ noAnswer: boolean;
16
+ handoffRule: string | null;
17
+ }>;
18
+ /** The chat's phrase list, matched in the composer on every key (empty while suggestions are off). */
19
+ export declare function usePhraseList(jid: string | null, enabled: boolean): import("@tanstack/react-query").UseQueryResult<{
20
+ phrases: {
21
+ text: string;
22
+ id: number;
23
+ language: "en" | "ms" | "zh";
24
+ }[];
25
+ }, Error>;
26
+ /** Tab / Accept (true) or Esc (false) on a phrase's grey text: it moves up or down the list. */
27
+ export declare function sendPhraseFeedback(jid: string, id: number, accepted: boolean): void;
28
+ export declare const phrasesAdminKey: readonly ["ai", "phrasesAdmin"];
29
+ /** Admins: the phrase list and its status for one agent (default: the agent of inbox 1). */
30
+ export declare function usePhrasesAdmin(agentId: number | null): import("@tanstack/react-query").UseQueryResult<{
31
+ agentId: number | null;
32
+ status: {
33
+ state: "error" | "ready" | "empty" | "building";
34
+ count: number;
35
+ languages: {
36
+ language: "en" | "ms" | "zh";
37
+ count: number;
38
+ }[];
39
+ updatedAt: number | null;
40
+ trigger: "context" | "manual" | "start" | "replies" | "weekly" | null;
41
+ newReplies: number;
42
+ nextAfterReplies: number;
43
+ aiCallsToday: number;
44
+ aiCallsLimit: number;
45
+ };
46
+ phrases: {
47
+ id: number;
48
+ text: string;
49
+ language: "en" | "ms" | "zh";
50
+ source: "admin" | "context" | "team";
51
+ uses: number;
52
+ fact: boolean;
53
+ }[];
54
+ }, Error>;
55
+ export declare const suggestModelKey: readonly ["ai", "suggestModel"];
56
+ /** Admins: the model for suggestions, its choices and what calls use now. */
57
+ export declare function useSuggestModel(enabled: boolean): import("@tanstack/react-query").UseQueryResult<{
58
+ model: string;
59
+ fastModel: string;
60
+ agentModel: string;
61
+ models: string[];
62
+ resolved: string;
63
+ }, Error>;
64
+ /** The rest of the sentence being typed, or null. */
65
+ export declare function fetchCompletion(jid: string, text: string, signal: AbortSignal): Promise<{
66
+ completion: string | null;
67
+ }>;
@@ -465,6 +465,23 @@ export declare const enResources: {
465
465
  cancel: string;
466
466
  previewUnavailable: string;
467
467
  };
468
+ suggest: {
469
+ button: string;
470
+ region: string;
471
+ loading: string;
472
+ retry: string;
473
+ close: string;
474
+ noAnswer: string;
475
+ addContext: string;
476
+ handoff: string;
477
+ replaceTitle: string;
478
+ replace: string;
479
+ keep: string;
480
+ accept: string;
481
+ tabHint: string;
482
+ completionStatus: string;
483
+ unavailable: string;
484
+ };
468
485
  };
469
486
  quickReplies: {
470
487
  title: string;
@@ -1335,6 +1352,67 @@ export declare const enResources: {
1335
1352
  title: string;
1336
1353
  description: string;
1337
1354
  };
1355
+ replySuggestions: {
1356
+ title: string;
1357
+ description: string;
1358
+ enable: string;
1359
+ cost: string;
1360
+ noConnection: string;
1361
+ upgraded: string;
1362
+ model: string;
1363
+ modelFast: string;
1364
+ modelAgent: string;
1365
+ modelFastHint: string;
1366
+ modelSlowHint: string;
1367
+ };
1368
+ phrases: {
1369
+ title: string;
1370
+ description: string;
1371
+ agent: string;
1372
+ off: string;
1373
+ building: string;
1374
+ empty: string;
1375
+ error: string;
1376
+ count: string;
1377
+ updated: string;
1378
+ trigger: {
1379
+ start: string;
1380
+ context: string;
1381
+ replies: string;
1382
+ manual: string;
1383
+ weekly: string;
1384
+ };
1385
+ next: string;
1386
+ calls: string;
1387
+ view: string;
1388
+ build: string;
1389
+ rebuild: string;
1390
+ privacy: string;
1391
+ listTitle: string;
1392
+ listDescription: string;
1393
+ search: string;
1394
+ language: string;
1395
+ all: string;
1396
+ lang: {
1397
+ en: string;
1398
+ ms: string;
1399
+ zh: string;
1400
+ };
1401
+ add: string;
1402
+ edit: string;
1403
+ delete: string;
1404
+ cancel: string;
1405
+ save: string;
1406
+ text: string;
1407
+ noMatch: string;
1408
+ source: {
1409
+ context: string;
1410
+ team: string;
1411
+ admin: string;
1412
+ };
1413
+ uses: string;
1414
+ fact: string;
1415
+ };
1338
1416
  };
1339
1417
  resolveAll: {
1340
1418
  title: string;
@@ -1,5 +1,5 @@
1
1
  import type React from 'react';
2
- import type { QuickReply } from '@ezychat/shared';
2
+ import { type QuickReply, type ReplyPhraseListItem } from '@ezychat/shared';
3
3
  export interface ComposerProps {
4
4
  quickReplies: QuickReply[];
5
5
  onSend(text: string): void;
@@ -26,5 +26,17 @@ export interface ComposerProps {
26
26
  preview: string;
27
27
  } | null;
28
28
  onCancelReply?(): void;
29
+ /**
30
+ * AI reply suggestions in this chat (direct chats only; null = off). `unavailable` shows the
31
+ * button disabled. The chips clear when `lastCustomerMessageId` changes (a new customer message).
32
+ */
33
+ aiSuggest?: {
34
+ chatJid: string;
35
+ lastCustomerMessageId: string | null;
36
+ isAdmin: boolean;
37
+ state: 'on' | 'unavailable';
38
+ /** The team's phrase list, matched on every key (docs/features/ai-phrase-dictionary). */
39
+ phrases?: readonly ReplyPhraseListItem[];
40
+ } | null;
29
41
  }
30
- export declare function Composer({ quickReplies, onSend, onAttach, onVoiceNote, onTyping, confirmSend, disabled, placeholder, replyTo, onCancelReply, }: ComposerProps): React.JSX.Element;
42
+ export declare function Composer({ quickReplies, onSend, onAttach, onVoiceNote, onTyping, confirmSend, disabled, placeholder, replyTo, onCancelReply, aiSuggest, }: ComposerProps): React.JSX.Element;
@@ -0,0 +1,23 @@
1
+ import type React from 'react';
2
+ import type { ReplySuggestion, ReplySuggestionsResult } from '@ezychat/shared';
3
+ export type SuggestionStrip = {
4
+ phase: 'loading';
5
+ } | {
6
+ phase: 'ready';
7
+ result: ReplySuggestionsResult;
8
+ } | {
9
+ phase: 'error';
10
+ message: string;
11
+ };
12
+ /**
13
+ * AI reply suggestions: the strip above the composer after "Suggest reply". Up to two
14
+ * chips (a short label; a tap puts the full draft in the composer), or a note when the business
15
+ * context has no answer or a hand-off rule matches. The strip scrolls inside itself, never the page.
16
+ */
17
+ export declare function ReplySuggestions({ strip, isAdmin, onPick, onRetry, onClose, }: {
18
+ strip: SuggestionStrip;
19
+ isAdmin: boolean;
20
+ onPick(suggestion: ReplySuggestion): void;
21
+ onRetry(): void;
22
+ onClose(): void;
23
+ }): React.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ezychat/web",
3
- "version": "0.1.57",
3
+ "version": "0.1.59",
4
4
  "type": "module",
5
5
  "description": "EzyChat core: the team inbox web app (React) as a library, with createInboxApp and its extension API.",
6
6
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "build:lib": "node ../../scripts/build-web-lib.mjs"
41
41
  },
42
42
  "dependencies": {
43
- "@ezychat/shared": "0.1.57",
43
+ "@ezychat/shared": "0.1.59",
44
44
  "@fontsource-variable/inter": "^5.3.0",
45
45
  "@tanstack/react-query": "^5.104.5",
46
46
  "@types/react": "^19.3.0",