@ezychat/web 0.1.46 → 0.1.48
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-lib/chunks/admin-CpYxtKzJ.js +694 -0
- package/dist-lib/chunks/admin-Da2uR7mY.js +695 -0
- package/dist-lib/chunks/{app-C2A7ZZsu.js → app-3jWCMPbu.js} +3 -1
- package/dist-lib/chunks/{app-RX8Fy2Oz.js → app-Diwr0AD0.js} +3 -1
- package/dist-lib/chunks/{inbox-DccyncVL.js → inbox-DtLIGOCo.js} +29 -14
- package/dist-lib/chunks/{inbox-Bdg6faLa.js → inbox-u9BCZ1IH.js} +29 -14
- package/dist-lib/ezychat-web.css +1 -1
- package/dist-lib/index.js +10987 -4997
- package/dist-lib/types/admin/AdminLayout.d.ts +14 -1
- package/dist-lib/types/admin/AiContextPanel.d.ts +10 -5
- package/dist-lib/types/admin/AiEditDialog.d.ts +6 -2
- package/dist-lib/types/admin/AiMemberPage.d.ts +6 -0
- package/dist-lib/types/admin/AiTryIt.d.ts +7 -2
- package/dist-lib/types/admin/InboxAccess.d.ts +9 -0
- package/dist-lib/types/admin/InboxesPage.d.ts +3 -0
- package/dist-lib/types/admin/PresetBadge.d.ts +8 -0
- package/dist-lib/types/admin/agent-path.d.ts +6 -0
- package/dist-lib/types/admin/ai-status.d.ts +15 -1
- package/dist-lib/types/admin/inbox-status.d.ts +16 -0
- package/dist-lib/types/api/ai.d.ts +194 -6
- package/dist-lib/types/api/inbox-mutations.d.ts +70 -0
- package/dist-lib/types/api/queries.d.ts +78 -3
- package/dist-lib/types/extensions/agent-section.d.ts +18 -0
- package/dist-lib/types/extensions/index.d.ts +1 -0
- package/dist-lib/types/extensions/types.d.ts +1 -1
- package/dist-lib/types/i18n/resources.d.ts +222 -3
- package/dist-lib/types/inbox/ChatFilters.d.ts +4 -1
- package/dist-lib/types/inbox/ChatListItem.d.ts +4 -2
- package/dist-lib/types/inbox/ConversationHeader.d.ts +4 -2
- package/dist-lib/types/inbox/InboxChip.d.ts +6 -0
- package/dist-lib/types/inbox/WaBanner.d.ts +6 -1
- package/dist-lib/types/inbox/useDirectory.d.ts +26 -4
- package/dist-lib/types/inbox/useVisibleInboxes.d.ts +12 -0
- package/dist-lib/types/index.d.ts +1 -1
- package/dist-lib/types/lib/whatsapp-format.d.ts +5 -0
- package/dist-lib/types/setup/AiAssistantStep.d.ts +3 -2
- package/dist-lib/types/wa/PhoneLink.d.ts +7 -2
- package/package.json +2 -2
- package/dist-lib/chunks/admin-CO4a2wgk.js +0 -620
- package/dist-lib/chunks/admin-DviFuAwJ.js +0 -621
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { type LucideIcon } from 'lucide-react';
|
|
2
2
|
import { type WebExtension, type WebExtensionAdminSection } from '../extensions';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Every core admin section. `labelKey` is a translation key in the `admin` namespace. WhatsApp and
|
|
5
|
+
* Inboxes never show together: see `visibleAdminNav`.
|
|
6
|
+
*/
|
|
4
7
|
export declare const ADMIN_NAV: readonly [{
|
|
5
8
|
readonly to: "members";
|
|
6
9
|
readonly labelKey: "nav.members";
|
|
@@ -13,6 +16,10 @@ export declare const ADMIN_NAV: readonly [{
|
|
|
13
16
|
readonly to: "whatsapp";
|
|
14
17
|
readonly labelKey: "nav.whatsapp";
|
|
15
18
|
readonly icon: LucideIcon;
|
|
19
|
+
}, {
|
|
20
|
+
readonly to: "inboxes";
|
|
21
|
+
readonly labelKey: "inboxes.title";
|
|
22
|
+
readonly icon: LucideIcon;
|
|
16
23
|
}, {
|
|
17
24
|
readonly to: "tunnel";
|
|
18
25
|
readonly labelKey: "nav.tunnel";
|
|
@@ -26,6 +33,12 @@ export declare const ADMIN_NAV: readonly [{
|
|
|
26
33
|
readonly labelKey: "nav.audit";
|
|
27
34
|
readonly icon: LucideIcon;
|
|
28
35
|
}];
|
|
36
|
+
export type AdminNavItem = (typeof ADMIN_NAV)[number];
|
|
37
|
+
/**
|
|
38
|
+
* The sections in the nav: **Inboxes** replaces **WhatsApp** only in an edition that allows more than
|
|
39
|
+
* one WhatsApp number (Lite allows one, so it keeps WhatsApp).
|
|
40
|
+
*/
|
|
41
|
+
export declare function visibleAdminNav(multiInbox: boolean): AdminNavItem[];
|
|
29
42
|
/** The core section an extension admin route declares for this path (e.g. `members`). */
|
|
30
43
|
export declare function extensionSectionOf(extensions: readonly WebExtension[], pathname: string): WebExtensionAdminSection | undefined;
|
|
31
44
|
/**
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import type { TFunction } from 'i18next';
|
|
1
2
|
import { type AiDocument } from '@ezychat/shared';
|
|
3
|
+
/** An AI agent API error in the admin's language (`ai.agents.errors.*`); others as usual. */
|
|
4
|
+
export declare function agentErrorMessage(error: unknown, t: TFunction<'admin'>): string;
|
|
2
5
|
/**
|
|
3
|
-
* Business context as a list of items (uploaded files and text content), like a
|
|
4
|
-
* knowledge panel: search, multi-select delete, and Add ▾ (upload or
|
|
5
|
-
*
|
|
6
|
+
* The Business context of ONE agent as a list of items (uploaded files and text content), like a
|
|
7
|
+
* project knowledge panel: search, the Internal filter, multi-select delete, and Add ▾ (upload or
|
|
8
|
+
* text). An Internal item helps the agent decide and is never told to customers.
|
|
6
9
|
*/
|
|
7
|
-
export declare function AiContextPanel({
|
|
10
|
+
export declare function AiContextPanel({ agentId, documents, disabled, }: {
|
|
11
|
+
agentId: number;
|
|
8
12
|
documents: AiDocument[];
|
|
9
|
-
ensureMember: () => Promise<boolean>;
|
|
10
13
|
disabled?: boolean;
|
|
11
14
|
}): import("react").JSX.Element;
|
|
15
|
+
/** "Internal" badge: used to decide, never told to customers. */
|
|
16
|
+
export declare function InternalBadge(): import("react").JSX.Element;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { type AiEditField } from '@ezychat/shared';
|
|
1
|
+
import { type AiAgentPreset, type AiEditField } from '@ezychat/shared';
|
|
2
2
|
/**
|
|
3
3
|
* Edit with AI: the admin describes a change to one box, reviews the suggested rewrite as a line
|
|
4
4
|
* diff and applies it to the page's draft. Applying never saves; the page's Save does.
|
|
5
5
|
*/
|
|
6
|
-
export declare function AiEditDialog({ field, current, open, onOpenChange, onApply, }: {
|
|
6
|
+
export declare function AiEditDialog({ field, current, open, onOpenChange, onApply, agentId, preset, }: {
|
|
7
7
|
field: AiEditField;
|
|
8
8
|
/** The box's current (possibly unsaved) text. */
|
|
9
9
|
current: string;
|
|
10
10
|
open: boolean;
|
|
11
11
|
onOpenChange: (open: boolean) => void;
|
|
12
12
|
onApply: (text: string) => void;
|
|
13
|
+
/** The agent whose Business context informs the rewrite (none: the inbox-1 agent). */
|
|
14
|
+
agentId?: number;
|
|
15
|
+
/** The agent's preset, so a FAQ agent is not pushed toward sales. */
|
|
16
|
+
preset?: AiAgentPreset;
|
|
13
17
|
}): import("react").JSX.Element;
|
|
@@ -1 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Members ▸ AI agent: `/admin/members/ai/:agentId` edits one agent; `/admin/members/ai/new?preset=`
|
|
3
|
+
* creates one. Name, starting point, Business context (with Internal items), Try it, the role and
|
|
4
|
+
* hand-over rules, the fixed safety rules, and in an edition with several inboxes the inbox and
|
|
5
|
+
* Delete.
|
|
6
|
+
*/
|
|
1
7
|
export declare function AiMemberPage(): import("react").JSX.Element;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { AiKnowledgeDraft } from './ai-status';
|
|
2
2
|
/**
|
|
3
3
|
* Asks the AI a test question with the page's current (possibly unsaved) name and instructions;
|
|
4
|
-
* the server answers from the saved Business context items.
|
|
4
|
+
* the server answers from the saved Business context items of `agentId` (none: the inbox-1 agent).
|
|
5
|
+
* `ready` false: the AI connection does not work yet, so asking is off.
|
|
5
6
|
*/
|
|
6
|
-
export declare function AiTryIt({ draft }: {
|
|
7
|
+
export declare function AiTryIt({ draft, agentId, ready, onAnswered, }: {
|
|
7
8
|
draft: AiKnowledgeDraft;
|
|
9
|
+
agentId?: number;
|
|
10
|
+
ready?: boolean;
|
|
11
|
+
/** Called after the model answered a test question (the agent page's Next steps). */
|
|
12
|
+
onAnswered?: () => void;
|
|
8
13
|
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Inbox, User } from '@ezychat/shared';
|
|
2
|
+
/**
|
|
3
|
+
* Members → Inbox access: which inboxes a member may open. Admins always see every inbox; an agent
|
|
4
|
+
* sees only the chats (and notifications) of the inboxes ticked here. `inboxes` are the active ones.
|
|
5
|
+
*/
|
|
6
|
+
export declare function InboxAccessCell({ user, inboxes }: Readonly<{
|
|
7
|
+
user: User;
|
|
8
|
+
inboxes: Inbox[];
|
|
9
|
+
}>): import("react").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type LucideIcon } from 'lucide-react';
|
|
2
|
+
import type { AiAgentPreset } from '@ezychat/shared';
|
|
3
|
+
/** The icon of each agent preset (picker, badges). */
|
|
4
|
+
export declare const PRESET_ICON: Record<AiAgentPreset, LucideIcon>;
|
|
5
|
+
/** "Sales agent", "FAQ agent", "Custom agent". */
|
|
6
|
+
export declare function PresetBadge({ preset }: Readonly<{
|
|
7
|
+
preset: AiAgentPreset;
|
|
8
|
+
}>): import("react").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AiMemberStatus } from '@ezychat/shared';
|
|
2
|
+
/**
|
|
3
|
+
* Where "set up the AI agent" links go: the only agent's page, a new agent while there is none, or
|
|
4
|
+
* Members (which lists every agent) when there are several.
|
|
5
|
+
*/
|
|
6
|
+
export declare function aiAgentsPath(status: Pick<AiMemberStatus, 'agents'>): string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TFunction } from 'i18next';
|
|
2
|
+
import { type AiAgentPreset, type AiDocument, type AiMemberStatus, type AiSettings } from '@ezychat/shared';
|
|
2
3
|
/** Only the official ChatGPT sign-in hosts may be opened from the app. */
|
|
3
4
|
export declare function officialLoginUrl(raw: string | null): string | null;
|
|
4
5
|
/** The saved connection can answer customers right now. */
|
|
@@ -10,3 +11,16 @@ export type AiKnowledgeDraft = Pick<AiSettings, 'displayName' | 'instructions'>
|
|
|
10
11
|
export declare function hasKnowledge(documents: readonly AiDocument[]): boolean;
|
|
11
12
|
export type AiPill = 'off' | 'on' | 'needsConnection' | 'needsKnowledge';
|
|
12
13
|
export declare function memberPill(status: AiMemberStatus): AiPill;
|
|
14
|
+
export type PresetTexts = {
|
|
15
|
+
instructions: string;
|
|
16
|
+
handoffRules: string;
|
|
17
|
+
};
|
|
18
|
+
type PresetField = keyof PresetTexts;
|
|
19
|
+
/** A preset's starting texts in the admin's language (`ai.defaults.<preset>.*`); Custom is blank. */
|
|
20
|
+
export declare function presetDefaults(preset: AiAgentPreset, t: TFunction<'admin'>): PresetTexts;
|
|
21
|
+
/**
|
|
22
|
+
* True when `text` is an unedited starting text of any preset: the English one the server keeps,
|
|
23
|
+
* or the copy in any language whose catalog is loaded. A blank text is never a default.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isPresetDefault(text: string, field: PresetField): boolean;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { WaState } from '@ezychat/shared';
|
|
2
|
+
import type { StatusTone } from '../components/app';
|
|
3
|
+
/** What the inbox card says next to its status: scan the QR code, or the phone is offline. */
|
|
4
|
+
export type InboxNotice = 'scan' | 'offline' | 'replaced' | null;
|
|
5
|
+
export interface InboxCardStatus {
|
|
6
|
+
tone: StatusTone;
|
|
7
|
+
/** Translation key in the `admin` namespace. */
|
|
8
|
+
labelKey: string;
|
|
9
|
+
notice: InboxNotice;
|
|
10
|
+
/** The phone must scan a QR code (or enter a pairing code) before the inbox works. */
|
|
11
|
+
needsLink: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** WhatsApp connection state of one inbox → the status its card shows. */
|
|
14
|
+
export declare function inboxCardStatus(state: WaState): InboxCardStatus;
|
|
15
|
+
/** Phone-number digits from WhatsApp (`60112233445`) → `+60112233445`; anything else as it is. */
|
|
16
|
+
export declare function formatInboxNumber(number: string | null): string | null;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type QueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { type AiAgentBody, type AiMemberBody, type AiConnectionBody, type AiContextPatchBody, type AiContextTextBody, type AiEditBody } from '@ezychat/shared';
|
|
2
4
|
export declare const aiMemberKey: readonly ["ai-member"];
|
|
3
5
|
export declare function useAiMember(): import("@tanstack/react-query").UseQueryResult<{
|
|
4
6
|
member: {
|
|
@@ -12,6 +14,9 @@ export declare function useAiMember(): import("@tanstack/react-query").UseQueryR
|
|
|
12
14
|
locale: "en" | "ms" | "zh-CN" | null;
|
|
13
15
|
kind?: "human" | "ai" | undefined;
|
|
14
16
|
aiRole?: "sales" | undefined;
|
|
17
|
+
aiAgentId?: number | undefined;
|
|
18
|
+
aiDeleted?: boolean | undefined;
|
|
19
|
+
inboxIds?: number[] | undefined;
|
|
15
20
|
} | null;
|
|
16
21
|
settings: {
|
|
17
22
|
displayName: string;
|
|
@@ -36,7 +41,18 @@ export declare function useAiMember(): import("@tanstack/react-query").UseQueryR
|
|
|
36
41
|
characters: number;
|
|
37
42
|
createdAt: number;
|
|
38
43
|
updatedAt: number;
|
|
44
|
+
internal: boolean;
|
|
39
45
|
}[];
|
|
46
|
+
agents: {
|
|
47
|
+
id: number;
|
|
48
|
+
userId: number;
|
|
49
|
+
displayName: string;
|
|
50
|
+
enabled: boolean;
|
|
51
|
+
preset: "sales" | "custom" | "faq";
|
|
52
|
+
inboxId: number | null;
|
|
53
|
+
documentCount: number;
|
|
54
|
+
}[];
|
|
55
|
+
maxAgents: number;
|
|
40
56
|
}, Error>;
|
|
41
57
|
/** One Business context item with its text (full for text items, a preview for files). */
|
|
42
58
|
export declare function useAiDocument(id: number | null): import("@tanstack/react-query").UseQueryResult<{
|
|
@@ -47,6 +63,7 @@ export declare function useAiDocument(id: number | null): import("@tanstack/reac
|
|
|
47
63
|
characters: number;
|
|
48
64
|
createdAt: number;
|
|
49
65
|
updatedAt: number;
|
|
66
|
+
internal: boolean;
|
|
50
67
|
text: string;
|
|
51
68
|
truncated: boolean;
|
|
52
69
|
}, Error>;
|
|
@@ -64,14 +81,17 @@ export declare function useAiTest(): import("@tanstack/react-query").UseMutation
|
|
|
64
81
|
reply: string | null;
|
|
65
82
|
error: string | null;
|
|
66
83
|
}, Error, void, unknown>;
|
|
67
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Try it: answers from the page's current knowledge; never touches chats or WhatsApp. With
|
|
86
|
+
* `agentId` the answer uses that agent's saved items (and its path); without, the inbox-1 agent.
|
|
87
|
+
*/
|
|
68
88
|
export declare function useAiTry(): import("@tanstack/react-query").UseMutationResult<{
|
|
69
89
|
ok: boolean;
|
|
70
90
|
reply: string | null;
|
|
71
91
|
action: "answer" | "ask_resolution" | "resolve" | "handoff" | "no_reply" | null;
|
|
72
92
|
model: string | null;
|
|
73
93
|
error: string | null;
|
|
74
|
-
handoffReason?: "asked_for_human" | "missing_facts" | "sensitive" | "needs_action" | "business_rule" | "unsupported_message" | "ai_unavailable" | "lookup_failed" | null | undefined;
|
|
94
|
+
handoffReason?: "asked_for_human" | "missing_facts" | "sensitive" | "needs_action" | "business_rule" | "unsupported_message" | "ai_unavailable" | "lookup_failed" | "confidential_leak" | null | undefined;
|
|
75
95
|
lookups?: {
|
|
76
96
|
title: string;
|
|
77
97
|
sourceLabel: string;
|
|
@@ -87,10 +107,13 @@ export declare function useAiTry(): import("@tanstack/react-query").UseMutationR
|
|
|
87
107
|
instructions: string;
|
|
88
108
|
handoffRules?: string | undefined;
|
|
89
109
|
};
|
|
110
|
+
agentId?: number | undefined;
|
|
90
111
|
}, unknown>;
|
|
91
|
-
/**
|
|
92
|
-
|
|
93
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Edit with AI: a suggested rewrite of one box; nothing is saved (the page's Save does that).
|
|
114
|
+
* Pass a signal so closing the popup stops the (paid) model call. `agentId`: whose items inform it.
|
|
115
|
+
*/
|
|
116
|
+
export declare function useAiEdit(agentId?: number): import("@tanstack/react-query").UseMutationResult<{
|
|
94
117
|
ok: boolean;
|
|
95
118
|
text: string | null;
|
|
96
119
|
error: string | null;
|
|
@@ -146,6 +169,9 @@ export declare function useAiMemberAction(): import("@tanstack/react-query").Use
|
|
|
146
169
|
locale: "en" | "ms" | "zh-CN" | null;
|
|
147
170
|
kind?: "human" | "ai" | undefined;
|
|
148
171
|
aiRole?: "sales" | undefined;
|
|
172
|
+
aiAgentId?: number | undefined;
|
|
173
|
+
aiDeleted?: boolean | undefined;
|
|
174
|
+
inboxIds?: number[] | undefined;
|
|
149
175
|
} | null;
|
|
150
176
|
settings: {
|
|
151
177
|
displayName: string;
|
|
@@ -170,5 +196,167 @@ export declare function useAiMemberAction(): import("@tanstack/react-query").Use
|
|
|
170
196
|
characters: number;
|
|
171
197
|
createdAt: number;
|
|
172
198
|
updatedAt: number;
|
|
199
|
+
internal: boolean;
|
|
200
|
+
}[];
|
|
201
|
+
agents: {
|
|
202
|
+
id: number;
|
|
203
|
+
userId: number;
|
|
204
|
+
displayName: string;
|
|
205
|
+
enabled: boolean;
|
|
206
|
+
preset: "sales" | "custom" | "faq";
|
|
207
|
+
inboxId: number | null;
|
|
208
|
+
documentCount: number;
|
|
173
209
|
}[];
|
|
210
|
+
maxAgents: number;
|
|
174
211
|
}, Error, AiMemberAction, unknown>;
|
|
212
|
+
/** `GET /api/ai/agents` and `DELETE /api/ai/agents/:agentId`: every agent and the edition limit. */
|
|
213
|
+
export declare const AiAgentList: z.ZodObject<{
|
|
214
|
+
agents: z.ZodArray<z.ZodObject<{
|
|
215
|
+
id: z.ZodNumber;
|
|
216
|
+
userId: z.ZodNumber;
|
|
217
|
+
displayName: z.ZodString;
|
|
218
|
+
enabled: z.ZodBoolean;
|
|
219
|
+
preset: z.ZodEnum<{
|
|
220
|
+
sales: "sales";
|
|
221
|
+
custom: "custom";
|
|
222
|
+
faq: "faq";
|
|
223
|
+
}>;
|
|
224
|
+
inboxId: z.ZodNullable<z.ZodNumber>;
|
|
225
|
+
documentCount: z.ZodNumber;
|
|
226
|
+
}, z.core.$strip>>;
|
|
227
|
+
maxAgents: z.ZodNumber;
|
|
228
|
+
}, z.core.$strip>;
|
|
229
|
+
export type AiAgentList = z.infer<typeof AiAgentList>;
|
|
230
|
+
export declare const aiAgentsKey: readonly ["ai-agents"];
|
|
231
|
+
export declare const aiAgentKey: (agentId: number) => readonly ["ai-agent", number];
|
|
232
|
+
/** One item with its text, under its agent (the agent is part of the key and of the path). */
|
|
233
|
+
export declare const aiAgentDocumentKey: (agentId: number, id: number) => readonly ["ai-document", number, number];
|
|
234
|
+
export declare function useAiAgents(): import("@tanstack/react-query").UseQueryResult<{
|
|
235
|
+
agents: {
|
|
236
|
+
id: number;
|
|
237
|
+
userId: number;
|
|
238
|
+
displayName: string;
|
|
239
|
+
enabled: boolean;
|
|
240
|
+
preset: "sales" | "custom" | "faq";
|
|
241
|
+
inboxId: number | null;
|
|
242
|
+
documentCount: number;
|
|
243
|
+
}[];
|
|
244
|
+
maxAgents: number;
|
|
245
|
+
}, Error>;
|
|
246
|
+
/** One agent with its settings and items; `null` (a new agent) reads nothing. */
|
|
247
|
+
export declare function useAiAgent(agentId: number | null): import("@tanstack/react-query").UseQueryResult<{
|
|
248
|
+
agent: {
|
|
249
|
+
id: number;
|
|
250
|
+
userId: number;
|
|
251
|
+
displayName: string;
|
|
252
|
+
enabled: boolean;
|
|
253
|
+
preset: "sales" | "custom" | "faq";
|
|
254
|
+
inboxId: number | null;
|
|
255
|
+
documentCount: number;
|
|
256
|
+
};
|
|
257
|
+
settings: {
|
|
258
|
+
displayName: string;
|
|
259
|
+
mode: "api" | "chatgpt";
|
|
260
|
+
enabled: boolean;
|
|
261
|
+
model: string;
|
|
262
|
+
instructions: string;
|
|
263
|
+
handoffRules?: string | undefined;
|
|
264
|
+
};
|
|
265
|
+
documents: {
|
|
266
|
+
id: number;
|
|
267
|
+
name: string;
|
|
268
|
+
kind: "text" | "file";
|
|
269
|
+
size: number;
|
|
270
|
+
characters: number;
|
|
271
|
+
createdAt: number;
|
|
272
|
+
updatedAt: number;
|
|
273
|
+
internal: boolean;
|
|
274
|
+
}[];
|
|
275
|
+
}, Error>;
|
|
276
|
+
/** One Business context item of an agent with its text (full for text, a preview for files). */
|
|
277
|
+
export declare function useAiAgentDocument(agentId: number, id: number | null): import("@tanstack/react-query").UseQueryResult<{
|
|
278
|
+
id: number;
|
|
279
|
+
name: string;
|
|
280
|
+
kind: "text" | "file";
|
|
281
|
+
size: number;
|
|
282
|
+
characters: number;
|
|
283
|
+
createdAt: number;
|
|
284
|
+
updatedAt: number;
|
|
285
|
+
internal: boolean;
|
|
286
|
+
text: string;
|
|
287
|
+
truncated: boolean;
|
|
288
|
+
}, Error>;
|
|
289
|
+
export type AiAgentAction = {
|
|
290
|
+
kind: 'create';
|
|
291
|
+
body: AiAgentBody;
|
|
292
|
+
} | {
|
|
293
|
+
kind: 'save';
|
|
294
|
+
body: AiAgentBody;
|
|
295
|
+
} | {
|
|
296
|
+
kind: 'delete';
|
|
297
|
+
} | {
|
|
298
|
+
kind: 'upload';
|
|
299
|
+
file: File;
|
|
300
|
+
internal?: boolean;
|
|
301
|
+
} | {
|
|
302
|
+
kind: 'addText';
|
|
303
|
+
body: AiContextTextBody;
|
|
304
|
+
} | {
|
|
305
|
+
kind: 'updateText';
|
|
306
|
+
id: number;
|
|
307
|
+
body: AiContextPatchBody;
|
|
308
|
+
} | {
|
|
309
|
+
kind: 'remove';
|
|
310
|
+
id: number;
|
|
311
|
+
} | {
|
|
312
|
+
kind: 'removeMany';
|
|
313
|
+
ids: number[];
|
|
314
|
+
}
|
|
315
|
+
/** Binds the agent to an inbox (Admin → Inboxes' route); null frees the inbox it answers now. */
|
|
316
|
+
| {
|
|
317
|
+
kind: 'setInbox';
|
|
318
|
+
inboxId: number | null;
|
|
319
|
+
};
|
|
320
|
+
/** Everything that shows agents: the list, every agent, the old AI member view, members, inboxes. */
|
|
321
|
+
export declare function refreshAgents(qc: QueryClient): void;
|
|
322
|
+
/** Changes one agent (or creates one with `agentId` null) and its Business context items. */
|
|
323
|
+
export declare function useAiAgentAction(agentId: number | null): import("@tanstack/react-query").UseMutationResult<{
|
|
324
|
+
agents: {
|
|
325
|
+
id: number;
|
|
326
|
+
userId: number;
|
|
327
|
+
displayName: string;
|
|
328
|
+
enabled: boolean;
|
|
329
|
+
preset: "sales" | "custom" | "faq";
|
|
330
|
+
inboxId: number | null;
|
|
331
|
+
documentCount: number;
|
|
332
|
+
}[];
|
|
333
|
+
maxAgents: number;
|
|
334
|
+
} | {
|
|
335
|
+
agent: {
|
|
336
|
+
id: number;
|
|
337
|
+
userId: number;
|
|
338
|
+
displayName: string;
|
|
339
|
+
enabled: boolean;
|
|
340
|
+
preset: "sales" | "custom" | "faq";
|
|
341
|
+
inboxId: number | null;
|
|
342
|
+
documentCount: number;
|
|
343
|
+
};
|
|
344
|
+
settings: {
|
|
345
|
+
displayName: string;
|
|
346
|
+
mode: "api" | "chatgpt";
|
|
347
|
+
enabled: boolean;
|
|
348
|
+
model: string;
|
|
349
|
+
instructions: string;
|
|
350
|
+
handoffRules?: string | undefined;
|
|
351
|
+
};
|
|
352
|
+
documents: {
|
|
353
|
+
id: number;
|
|
354
|
+
name: string;
|
|
355
|
+
kind: "text" | "file";
|
|
356
|
+
size: number;
|
|
357
|
+
characters: number;
|
|
358
|
+
createdAt: number;
|
|
359
|
+
updatedAt: number;
|
|
360
|
+
internal: boolean;
|
|
361
|
+
}[];
|
|
362
|
+
}, Error, AiAgentAction, unknown>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { UpdateInboxBody } from '@ezychat/shared';
|
|
2
|
+
import { type WaAction } from './queries';
|
|
3
|
+
export declare function useCreateInbox(): import("@tanstack/react-query").UseMutationResult<{
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
tone: "success" | "primary" | "warning" | "info";
|
|
7
|
+
number: string | null;
|
|
8
|
+
status: {
|
|
9
|
+
state: "open" | "qr" | "disconnected" | "connecting" | "logged_out" | "replaced" | "blocked";
|
|
10
|
+
me: {
|
|
11
|
+
jid: string;
|
|
12
|
+
name: string | null;
|
|
13
|
+
lid?: string | null | undefined;
|
|
14
|
+
} | null;
|
|
15
|
+
qr: string | null;
|
|
16
|
+
lastError: string | null;
|
|
17
|
+
};
|
|
18
|
+
removed: boolean;
|
|
19
|
+
aiAgentId: number | null;
|
|
20
|
+
memberIds?: number[] | undefined;
|
|
21
|
+
}, Error, {
|
|
22
|
+
name: string;
|
|
23
|
+
memberIds?: number[] | undefined;
|
|
24
|
+
aiAgentId?: number | null | undefined;
|
|
25
|
+
}, unknown>;
|
|
26
|
+
export declare function useUpdateInbox(): import("@tanstack/react-query").UseMutationResult<{
|
|
27
|
+
id: number;
|
|
28
|
+
name: string;
|
|
29
|
+
tone: "success" | "primary" | "warning" | "info";
|
|
30
|
+
number: string | null;
|
|
31
|
+
status: {
|
|
32
|
+
state: "open" | "qr" | "disconnected" | "connecting" | "logged_out" | "replaced" | "blocked";
|
|
33
|
+
me: {
|
|
34
|
+
jid: string;
|
|
35
|
+
name: string | null;
|
|
36
|
+
lid?: string | null | undefined;
|
|
37
|
+
} | null;
|
|
38
|
+
qr: string | null;
|
|
39
|
+
lastError: string | null;
|
|
40
|
+
};
|
|
41
|
+
removed: boolean;
|
|
42
|
+
aiAgentId: number | null;
|
|
43
|
+
memberIds?: number[] | undefined;
|
|
44
|
+
}, Error, {
|
|
45
|
+
id: number;
|
|
46
|
+
body: UpdateInboxBody;
|
|
47
|
+
}, unknown>;
|
|
48
|
+
export declare function useRemoveInbox(): import("@tanstack/react-query").UseMutationResult<unknown, Error, number, unknown>;
|
|
49
|
+
/** Log out, link again or take over the phone of one inbox. */
|
|
50
|
+
export declare function useInboxWaAction(inboxId: number): import("@tanstack/react-query").UseMutationResult<unknown, Error, WaAction, unknown>;
|
|
51
|
+
/** Link one inbox by phone number: the 8-character code to enter in WhatsApp → Linked devices. */
|
|
52
|
+
export declare function useInboxPairingCode(inboxId: number): import("@tanstack/react-query").UseMutationResult<{
|
|
53
|
+
code: string;
|
|
54
|
+
}, Error, string, unknown>;
|
|
55
|
+
/** Members → Inbox access: the inboxes one agent may open. */
|
|
56
|
+
export declare function useSetUserInboxes(userId: number): import("@tanstack/react-query").UseMutationResult<{
|
|
57
|
+
id: number;
|
|
58
|
+
username: string;
|
|
59
|
+
displayName: string;
|
|
60
|
+
role: "admin" | "agent";
|
|
61
|
+
mustChangePassword: boolean;
|
|
62
|
+
disabled: boolean;
|
|
63
|
+
createdAt: number;
|
|
64
|
+
locale: "en" | "ms" | "zh-CN" | null;
|
|
65
|
+
kind?: "human" | "ai" | undefined;
|
|
66
|
+
aiRole?: "sales" | undefined;
|
|
67
|
+
aiAgentId?: number | undefined;
|
|
68
|
+
aiDeleted?: boolean | undefined;
|
|
69
|
+
inboxIds?: number[] | undefined;
|
|
70
|
+
}, Error, number[], unknown>;
|